FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
1 /**********************************************************\
2 Original Author: Richard Bateman (taxilian)
4 Created: Oct 29, 2009
5 License: Dual license model; choose one of two:
6  New BSD License
8  - or -
9  GNU Lesser General Public License, version 2.1
12 Copyright 2009 Richard Bateman, Firebreath development team
13 \**********************************************************/
15 #pragma once
19 #include "JSAPIImpl.h"
21 namespace FB {
31  class JSAPISimple :
32  public FB::JSAPIImpl
33  {
34  public:
35  JSAPISimple(void);
36  virtual ~JSAPISimple(void);
38  public:
39  void getMemberNames(std::vector<std::string> &nameVector) const;
40  size_t getMemberCount() const;
61  virtual void registerMethod(const std::string& name, CallMethodPtr func);
90  virtual void registerProperty(const std::string& name, GetPropPtr getFunc, SetPropPtr setFunc);
92  // Methods to query existance of members on the API
93  virtual bool HasMethod(const std::string& methodName) const;
94  virtual bool HasProperty(const std::string& propertyName) const;
95  virtual bool HasProperty(int idx) const;
97  // Methods to manage properties on the API
98  virtual variant GetProperty(const std::string& propertyName);
99  virtual void SetProperty(const std::string& propertyName, const variant& value);
100  virtual void RemoveProperty(const std::string& propertyName);
101  virtual variant GetProperty(int idx);
102  virtual void SetProperty(int idx, const variant& value);
103  virtual void RemoveProperty(int idx);
105  // Methods to manage methods on the API
106  virtual variant Invoke(const std::string& methodName, const std::vector<variant>& args);
107  virtual variant Construct(const std::vector<variant>& args);
109  public:
121  virtual variant callFireEvent(const std::vector<variant>& args);
133  virtual variant callToString(const std::vector<variant>& args);
142  virtual variant getValid();
144  protected:
145  MethodMap m_methodMap;
146  PropertyMap m_propertyMap;
147  bool m_allowRemoveProperty;
148  };
150 };
152 #endif
JavaScript API base class implementation – provides basic functionality for C++ JSAPI objects...
Definition: JSAPIImpl.h:49
Simple JSAPI implementation for those who for whatever reason don't want to use JSAPIAuto.
Definition: JSAPISimple.h:31
virtual void registerMethod(const std::string &name, CallMethodPtr func)
Register a method to be exposed to javascript.
Definition: JSAPISimple.cpp:80
Accepts any datatype, used in all interactions with javascript. Provides tools for getting back out t...
Definition: variant.h:198
variant(JSAPI::* CallMethodPtr)(const std::vector< variant > &)
Defines an alias representing a function ptr for a method on a FB::JSAPISimple object.
Definition: APITypes.h:242
size_t getMemberCount() const
Gets the member count.
Definition: JSAPISimple.cpp:73
virtual variant Construct(const std::vector< variant > &args)
Called by the browser to construct the JSAPI object.
void(JSAPI::* SetPropPtr)(const variant &value)
Defines an alias representing a function pointer for a property setter on a FB::JSAPISimple object...
Definition: APITypes.h:260
virtual variant callToString(const std::vector< variant > &args)
Called when a string representation of the object requested. Always returns "JSAPI Javascript Object"...
Definition: JSAPISimple.cpp:49
virtual void RemoveProperty(const std::string &propertyName)
Removes a property.
variant(JSAPI::* GetPropPtr)()
Defines an alias representing a function pointer for a property getter on a FB::JSAPISimple object...
Definition: APITypes.h:258
virtual void registerProperty(const std::string &name, GetPropPtr getFunc, SetPropPtr setFunc)
Register a property to be exposed to javascript.
Definition: JSAPISimple.cpp:85
virtual variant getValid()
Returns true to indicate that the JSAPI interface is working.
Definition: JSAPISimple.cpp:54
virtual variant GetProperty(const std::string &propertyName)
Gets a property value.
std::map< std::string, MethodInfo > MethodMap
Defines an alias representing a map of methods used by FB::JSAPISimple.
Definition: APITypes.h:252
virtual void SetProperty(const std::string &propertyName, const variant &value)
Sets the value of a property.
virtual bool HasProperty(const std::string &propertyName) const
Query if 'propertyName' is a valid property.
std::map< std::string, PropertyInfo > PropertyMap
Defines an alias representing a map of properties used by FB::JSAPISimple.
Definition: APITypes.h:271
void getMemberNames(std::vector< std::string > &nameVector) const
Called by the browser to enumerate the members of this JSAPI object.
Definition: JSAPISimple.cpp:59
virtual variant callFireEvent(const std::vector< variant > &args)
Example function for testing fireEvent.
Definition: JSAPISimple.cpp:34
virtual variant Invoke(const std::string &methodName, const std::vector< variant > &args)
Called by the browser to invoke a method on the JSAPI object.
virtual bool HasMethod(const std::string &methodName) const
Query if the JSAPI object has the 'methodName' method.
Definition: JSAPISimple.cpp:92