diff options
Diffstat (limited to 'src/rpc-server/commands/trex_rpc_cmds.h')
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmds.h | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h index 39ccf27a..5c425856 100644 --- a/src/rpc-server/commands/trex_rpc_cmds.h +++ b/src/rpc-server/commands/trex_rpc_cmds.h @@ -30,60 +30,33 @@ limitations under the License. /******************* test section ************/ /** - * add - * + * syntactic sugar for creating a simple command */ -class TrexRpcCmdTestAdd : public TrexRpcCommand { -public: - TrexRpcCmdTestAdd() : TrexRpcCommand("test_add") {} -protected: - virtual trex_rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); -}; +#define TREX_RPC_CMD_DEFINE(class_name, cmd_name) \ + class class_name : public TrexRpcCommand { \ + public: \ + class_name () : TrexRpcCommand(cmd_name) {} \ + protected: \ + virtual trex_rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); \ + } -/** - * sub - * - */ -class TrexRpcCmdTestSub : public TrexRpcCommand { -public: - TrexRpcCmdTestSub() : TrexRpcCommand("test_sub") {} ; -protected: - virtual trex_rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); -}; /** - * ping - * + * test cmds */ -class TrexRpcCmdPing : public TrexRpcCommand { -public: - TrexRpcCmdPing() : TrexRpcCommand("ping") {}; -protected: - virtual trex_rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); -}; +TREX_RPC_CMD_DEFINE(TrexRpcCmdTestAdd, "test_add"); +TREX_RPC_CMD_DEFINE(TrexRpcCmdTestSub, "test_sub"); /** - * get all registered commands - * + * general cmds */ -class TrexRpcCmdGetReg : public TrexRpcCommand { -public: - TrexRpcCmdGetReg() : TrexRpcCommand("get_reg_cmds") {}; -protected: - virtual trex_rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); -}; +TREX_RPC_CMD_DEFINE(TrexRpcCmdPing, "ping"); +TREX_RPC_CMD_DEFINE(TrexRpcCmdGetReg, "get_reg_cmds"); +TREX_RPC_CMD_DEFINE(TrexRpcCmdGetStatus, "get_status"); /** - * get status - * + * stream cmds */ -class TrexRpcCmdGetStatus : public TrexRpcCommand { -public: - TrexRpcCmdGetStatus() : TrexRpcCommand("get_status") {}; -protected: - virtual trex_rpc_cmd_rc_e _run(const Json::Value ¶ms, Json::Value &result); -}; - +TREX_RPC_CMD_DEFINE(TrexRpcCmdAddStream, "add_stream"); -/**************** test section end *************/ #endif /* __TREX_RPC_CMD_H__ */ |