MCPcopy Create free account
hub / github.com/breach/thrust / API

Class API

src/api/api.h:29–97  ·  view source on GitHub ↗

## API This objects reprensents the ThrustShell API. It lives on the Browser UI thread and is used by object there as well as the APIServer.

Source from the content-addressed store, hash-verified

27// This objects reprensents the ThrustShell API. It lives on the Browser UI thread
28// and is used by object there as well as the APIServer.
29class API {
30public:
31 typedef base::Callback<void(const std::string& error,
32 scoped_ptr<base::DictionaryValue> result)> MethodCallback;
33 typedef base::Callback<void(scoped_ptr<base::DictionaryValue> event)> EventCallback;
34
35 /****************************************************************************/
36 /* PUBLIC INTERFACE */
37 /****************************************************************************/
38 API();
39 virtual ~API();
40
41 static API* Get();
42
43 // ### InstallBinding
44 //
45 // Installs a new binding for the API
46 void InstallBinding(const std::string& type,
47 APIBindingFactory* factory);
48
49 // ### Create
50 //
51 // Creates a new object and return its `_target` id
52 int Create(const std::string type,
53 scoped_ptr<base::DictionaryValue> args);
54
55 // ### Delete
56 //
57 // Deletes the object designated by the target passed
58 void Delete(unsigned int target);
59
60 // ### CallMethod
61 //
62 // Call the method specified on the objcet represented by the provided target
63 // id. The result of the call is returnd asynchronously to the callback.
64 void CallMethod(unsigned int target,
65 std::string method,
66 scoped_ptr<base::DictionaryValue> args,
67 const API::MethodCallback& callback);
68
69 // ### SetRemote
70 //
71 // Sets the remote for a given biding represented by its target id. The Remote
72 // is not owned by the API and should be nullified on deletion
73 void SetRemote(unsigned int target,
74 APIBindingRemote* remote);
75
76 // ### GetBinding
77 //
78 // Retrieves a binding based on its id
79 APIBinding* GetBinding(unsigned int target);
80
81 // ### GetRemote
82 //
83 // Retrieves a remote binding for this id
84 APIBindingRemote* GetRemote(unsigned int target);
85
86private:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected