Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
Diff: mbed/mod/ModJsonRpc.h
- Revision:
- 76:b375b3d750d8
- Parent:
- 75:2a18df0ef111
- Child:
- 81:e5e4f2264d24
diff -r 2a18df0ef111 -r b375b3d750d8 mbed/mod/ModJsonRpc.h
--- a/mbed/mod/ModJsonRpc.h Sat Jun 14 15:55:57 2014 +0000
+++ b/mbed/mod/ModJsonRpc.h Sat Jun 14 17:42:11 2014 +0000
@@ -20,6 +20,24 @@
*/
class ModJsonRpc:ModBaseClass
{
+ public:
+ class BasicRpcObject
+ {
+ public:
+ void* obj;
+ BasicRpcObject(void* i_ptr) : obj(i_ptr){};
+ virtual ~BasicRpcObject(){}
+ };
+ template< class T > class RpcObject : public BasicRpcObject{
+ public:
+ RpcObject(T* i_ptr) : BasicRpcObject(i_ptr){};
+ virtual ~RpcObject(){delete (static_cast<T*>(this->obj));}
+ };
+ template< class T > class RpcArray : public BasicRpcObject{
+ public:
+ RpcArray(T* i_ptr) : BasicRpcObject(i_ptr){};
+ virtual ~RpcArray(){delete[] (static_cast<T*>(this->obj));}
+ };
private:
public:
const static int PARSE_ERROR=NyLPC_TJsonRpcErrorCode_PARSE_ERROR;
@@ -29,7 +47,7 @@
const static int INTERNAL_ERROR=NyLPC_TJsonRpcErrorCode_INTERNAL_ERROR;
const static int SERVER_ERROR_BASE=NyLPC_TJsonRpcErrorCode_SERVER_ERROR_BASE;
private:
- void** _objects;
+ BasicRpcObject** _objects;
const struct NyLPC_TJsonRpcClassDef** _rpc_table;
protected:
NyLPC_TcModJsonRpc_t* _mod;
@@ -52,9 +70,9 @@
public:
//for development
- int addObject(void* i_object);
+ int addObject(BasicRpcObject* i_object);
void* getObject(int i_oid);
bool putResult(unsigned int i_id,const char* i_params_fmt,...);
bool putError(unsigned int i_id,int i_code);
};
-}
\ No newline at end of file
+}
MiMic Webservice library