ServiceRemote.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <zeus/WebServer.hpp>
9 #include <zeus/debug.hpp>
11 #include <zeus/ServiceRemote.hpp>
12 #include <zeus/Future.hpp>
13 #include <zeus/WebServer.hpp>
14 
15 namespace zeus {
16  class Client;
22  class ServiceRemote {
23  private:
24  ememory::SharedPtr<zeus::WebServer> m_interfaceClient;
25  std::string m_name;
26  uint32_t m_serviceId;
27  bool m_isLinked;
28  public:
34  ServiceRemote(ememory::SharedPtr<zeus::WebServer> _clientLink, const std::string& _name);
46  bool exist();
47  public:
53  template<class... _ARGS>
54  zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
55  if (m_interfaceClient == nullptr) {
57  if (ret != nullptr) {
58  ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
59  }
60  return zeus::FutureBase(0, ret);
61  }
62  return m_interfaceClient->callService(m_serviceId, _functionName, _args...);
63  }
69  template<class... _ARGS>
70  zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
71  if (m_interfaceClient == nullptr) {
73  if (ret != nullptr) {
74  ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
75  }
76  return zeus::FutureBase(0, ret, _callback);
77  }
78  return m_interfaceClient->callServiceAction(m_serviceId, _functionName, _args..., _callback);
79  }
80  };
81 }
82 
std::function< bool(zeus::FutureBase)> ObserverFinish
Define an Observer: function pointer.
Definition: FutureData.hpp:21
zeus::FutureBase callAction(const std::string &_functionName, _ARGS &&... _args, zeus::FutureData::ObserverFinish _callback)
Definition: ServiceRemote.hpp:70
Definition: ServiceRemote.hpp:22
zeus::FutureBase callService(uint32_t _serviceId, const std::string &_functionName, _ARGS &&... _args)
Definition: WebServer.hpp:271
static ememory::SharedPtr< zeus::BufferAnswer > create()
Create a shared pointer on the BufferAnswer.
Generic zeus Future interface to get data asynchronously.
Definition: FutureBase.hpp:14
void addError(const std::string &_value, const std::string &_comment)
Ann an error on the message answer.
zeus::FutureBase call(const std::string &_functionName, _ARGS &&... _args)
Definition: ServiceRemote.hpp:54
Main zeus library namespace.
Definition: AbstractFunction.hpp:15
ServiceRemote(ememory::SharedPtr< zeus::WebServer > _clientLink, const std::string &_name)
zeus::FutureBase callServiceAction(uint32_t _serviceId, const std::string &_functionName, _ARGS &&... _args, zeus::FutureData::ObserverFinish _callback)
Definition: WebServer.hpp:282