FutureBase.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <zeus/FutureData.hpp>
9 
10 namespace zeus {
14  class FutureBase {
15  public:
16  ememory::SharedPtr<zeus::FutureData> m_data; // Reference on the data
17  public:
22  FutureBase(const zeus::FutureBase& _base);
26  FutureBase();
33  FutureBase(uint32_t _transactionId, zeus::FutureData::ObserverFinish _callback=nullptr, uint32_t _clientId=0);
42  FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Buffer> _returnData, zeus::FutureData::ObserverFinish _callback=nullptr, uint32_t _clientId=0);
59  void setSynchronous();
64  uint32_t getTransactionId() const;
69  uint32_t getClientId() const;
74  bool hasError() const;
79  std::string getErrorType() const;
84  std::string getErrorHelp() const;
89  bool isValid() const;
94  bool isFinished() const;
99  const FutureBase& wait() const;
105  const FutureBase& waitFor(std::chrono::microseconds _delta = std::chrono::seconds(30)) const;
111  const FutureBase& waitUntil(std::chrono::steady_clock::time_point _endTime) const;
121  std::chrono::nanoseconds getTransmitionTime() const;
122  };
123 }
124 
std::function< bool(zeus::FutureBase)> ObserverFinish
Define an Observer: function pointer.
Definition: FutureData.hpp:21
std::string getErrorHelp() const
get help of the error
Generic zeus Future interface to get data asynchronously.
Definition: FutureBase.hpp:14
uint32_t getTransactionId() const
Get the transaction Id of the Future.
const FutureBase & waitFor(std::chrono::microseconds _delta=std::chrono::seconds(30)) const
Wait the Future receive data.
zeus::FutureBase operator=(const zeus::FutureBase &_base)
Asignement operator with an other future.
bool isValid() const
Check if the Futur is a valid data.
bool hasError() const
check if the answer have an error
ememory::SharedPtr< zeus::Buffer > getRaw()
Get the Buffer receive.
void setSynchronous()
Set the future syncronous.
uint32_t getClientId() const
Get the client Id of the Future.
std::chrono::nanoseconds getTransmitionTime() const
Get duration of the current trasaction take.
const FutureBase & wait() const
Wait the Future receive data.
bool appendData(ememory::SharedPtr< zeus::Buffer > _returnValue)
Add data on the call/answer.
Main zeus library namespace.
Definition: AbstractFunction.hpp:15
FutureBase()
contructor of a FutureBase
bool isFinished() const
Check if the futur have finish receiving data.
std::string getErrorType() const
get type of the error
const FutureBase & waitUntil(std::chrono::steady_clock::time_point _endTime) const
Wait the Future receive data.