RemoteProcessCall.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <zeus/WebServer.hpp>
11 #include <zeus/debug.hpp>
12 
13 namespace zeus {
18  public:
23  protected:
24  std::vector<zeus::AbstractFunction*> m_listFunction;
25  protected:
26  std::string m_description;
27  public:
32  void setDescription(const std::string& _desc);
37  std::string getDescription();
38  protected:
39  std::string m_version;
40  public:
45  void setVersion(const std::string& _vers);
50  std::string getVersion();
51  protected:
52  std::vector<std::pair<std::string,std::string>> m_authors;
53  public:
59  void addAuthor(const std::string& _name, const std::string& _email);
64  const std::vector<std::pair<std::string,std::string>>& getAuthors() const;
69  std::vector<std::string> getAuthors2();
70  protected:
71  std::string m_type;
72  public:
78  std::string getType();
84  void setType(const std::string& _type, uint16_t _version);
85  public:
91  std::vector<std::string> getFunctions();
97  AbstractFunction* getFunction(std::string _funcName);
98  private:
99  std::vector<std::string> getFunctionSignature(std::string _funcName);
100  std::string getFunctionPrototype(std::string _funcName);
101  std::string getFunctionDescription(std::string _funcName);
102  protected:
108  virtual bool isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName);
109  public:
115  // Add global fuction (no link with this class)
116  template<class ZEUS_RETURN_VALUE,
117  class... ZEUS_FUNC_ARGS_TYPE>
118  zeus::AbstractFunction* advertise(const std::string& _name,
119  ZEUS_RETURN_VALUE (*_func)(ZEUS_FUNC_ARGS_TYPE... _args)) {
120  for (auto &it : m_listFunction) {
121  if (it == nullptr) {
122  continue;
123  }
124  if (it->getName() == _name) {
125  ZEUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
126  return nullptr;
127  }
128  }
130  if (tmp == nullptr) {
131  ZEUS_ERROR("can not create abstract function ... '" << _name << "'");
132  return nullptr;
133  }
135  ZEUS_INFO("Add function '" << _name << "' in global mode");
136  m_listFunction.push_back(tmp);
137  return tmp;
138  }
144  // Add Local fuction (depend on this class)
145  template<class ZEUS_RETURN_VALUE,
146  class ZEUS_CLASS_TYPE,
147  class... ZEUS_FUNC_ARGS_TYPE>
148  zeus::AbstractFunction* advertise(std::string _name,
149  ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args)) {
150  _name = "sys." + _name;
151  for (auto &it : m_listFunction) {
152  if (it == nullptr) {
153  continue;
154  }
155  if (it->getName() == _name) {
156  ZEUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
157  return nullptr;
158  }
159  }
161  if (tmp == nullptr) {
162  ZEUS_ERROR("can not create abstract function ... '" << _name << "'");
163  return nullptr;
164  }
166  ZEUS_INFO("Add function '" << _name << "' in local mode");
167  m_listFunction.push_back(tmp);
168  return tmp;
169  }
170  };
171 }
172 
void setType(enum type _type)
Set the type of the call that must be done for this function.
std::string m_description
Description of the service.
Definition: RemoteProcessCall.hpp:26
This is a global function.
AbstractFunction * getFunction(std::string _funcName)
void setDescription(const std::string &_desc)
Set service description.
std::string m_version
Version of the service.
Definition: RemoteProcessCall.hpp:39
zeus::AbstractFunction * advertise(const std::string &_name, ZEUS_RETURN_VALUE(*_func)(ZEUS_FUNC_ARGS_TYPE... _args))
Definition: RemoteProcessCall.hpp:118
std::string getDescription()
Get service description.
void setType(const std::string &_type, uint16_t _version)
Interface to store a function and call it after with a zeus::Buffer.
Definition: AbstractFunction.hpp:23
std::string getVersion()
Get the Version of the service.
RemoteProcessCall()
Basic constructor.
std::vector< std::string > getAuthors2()
Get simple list of authors.
void setVersion(const std::string &_vers)
Set the Version of the service.
std::vector< std::string > getFunctions()
zeus::AbstractFunction * createAbstractFunctionDirect(const std::string &_name, ZEUS_RETURN(*_fffp)(ZEUS_TYPES...))
Create a function information with the function type.
Definition: AbstractFunctionTypeDirect.hpp:145
virtual bool isFunctionAuthorized(uint64_t _clientSessionID, const std::string &_funcName)
const std::vector< std::pair< std::string, std::string > > & getAuthors() const
Get the list of the Authors.
Main zeus library namespace.
Definition: AbstractFunction.hpp:15
AbstractFunction * createAbstractFunctionClass(const std::string &_name, ZEUS_RETURN(ZEUS_CLASS_TYPE::*_fffp)(ZEUS_TYPES...))
Create a function information with the function type.
Definition: AbstractFunctionTypeClass.hpp:157
void addAuthor(const std::string &_name, const std::string &_email)
List of autors of the module (name, email)
zeus::AbstractFunction * advertise(std::string _name, ZEUS_RETURN_VALUE(ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args))
Definition: RemoteProcessCall.hpp:148
std::string m_type
Generic type of the service.
Definition: RemoteProcessCall.hpp:71
This is a local fucntion.
std::vector< zeus::AbstractFunction * > m_listFunction
List of all functions callable.
Definition: RemoteProcessCall.hpp:24
Local declaration of call local data.
Definition: RemoteProcessCall.hpp:17