]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_API_CPP/api/src/CommandTO.hpp
Salome HOME
API c++
[modules/gde.git] / projects / GDE_API_CPP / api / src / CommandTO.hpp
1 #ifndef GDE_COMMAND_TO_HPP
2 #define GDE_COMMAND_TO_HPP
3
4 #include <string>
5 #include <map>
6
7 namespace gde {
8
9   class CommandTO {
10
11     typedef std::map<std::string, std::string> ParametersMap;
12
13   public:
14     CommandTO(int method = -1,
15               std::string data = std::string(),
16               const ParametersMap& parameters=ParametersMap())
17       : _method(method), _data(data), _parameters(parameters) {}
18     CommandTO(const CommandTO&);
19     ~CommandTO() {}
20
21     inline std::string getData() const { return _data; }
22     inline void setData(std::string data) { this->_data = data; }
23
24     inline int getMethod() const { return _method; }
25     inline void setMethod(int method) { this->_method = method; }
26
27     template <typename T> T getParameter(std::string name);
28     template <typename T> void setParameter(std::string name, const T& value, bool replaceIfExist=true);
29
30     static CommandTO fromJson(std::string json);
31     std::string toJson();
32
33   private:
34     int _method;
35     std::string _data; // JSON format
36     ParametersMap _parameters;
37   };
38
39 };
40
41 #endif