[DEV/DOC] add basic comment and some change (NOT WORK)
This commit is contained in:
parent
7ee8e2332c
commit
f76787a7d2
@ -68,13 +68,13 @@ bool zeus::Client::connectTo(const std::string& _address) {
|
||||
return ret.get();
|
||||
}
|
||||
|
||||
bool connect(const std::string& _address) {
|
||||
bool zeus::Client::connect(const std::string& _address) {
|
||||
bool ret = connectTo(_address);
|
||||
if (ret==false) {
|
||||
return false;
|
||||
}
|
||||
zeus::Future<bool> retIdentify = call("anonymous").wait();
|
||||
if (retIdentify.haveError() == true) {
|
||||
if (retIdentify.hasError() == true) {
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
@ -84,13 +84,13 @@ bool connect(const std::string& _address) {
|
||||
return retIdentify.get();
|
||||
}
|
||||
|
||||
bool connect(const std::string& _address, const std::string& _userPassword) {
|
||||
bool zeus::Client::connect(const std::string& _address, const std::string& _userPassword) {
|
||||
bool ret = connectTo(_address);
|
||||
if (ret==false) {
|
||||
return false;
|
||||
}
|
||||
zeus::Future<bool> retIdentify = call("auth", _userPassword).wait();
|
||||
if (retIdentify.haveError() == true) {
|
||||
if (retIdentify.hasError() == true) {
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
@ -100,13 +100,13 @@ bool connect(const std::string& _address, const std::string& _userPassword) {
|
||||
return retIdentify.get();
|
||||
}
|
||||
|
||||
bool connect(const std::string& _address, const std::string& _clientName, const std::string& _clientTocken) {
|
||||
bool zeus::Client::connect(const std::string& _address, const std::string& _clientName, const std::string& _clientTocken) {
|
||||
bool ret = connectTo(_address);
|
||||
if (ret==false) {
|
||||
return false;
|
||||
}
|
||||
zeus::Future<bool> retIdentify = call("identify", _clientName, _clientTocken).wait();
|
||||
if (retIdentify.haveError() == true) {
|
||||
if (retIdentify.hasError() == true) {
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace zeus {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return zeus::FutureBase(0, true, ret);
|
||||
return zeus::FutureBase(0, ret);
|
||||
}
|
||||
return m_interfaceClient->call(_functionName, _args...);
|
||||
}
|
||||
@ -122,7 +122,7 @@ namespace zeus {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return zeus::FutureBase(0, true, ret, _callback);
|
||||
return zeus::FutureBase(0, ret, _callback);
|
||||
}
|
||||
return m_interfaceClient->callAction(_functionName, _args..., _callback);
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ zeus::FutureBase::FutureBase() {
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
zeus::FutureBase::FutureBase(uint64_t _transactionId, zeus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureBase::FutureBase(uint32_t _transactionId, zeus::FutureData::ObserverFinish _callback, uint32_t _clientId) {
|
||||
m_data = std::make_shared<zeus::FutureData>();
|
||||
if (m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_data->m_sendTime = std::chrono::steady_clock::now();
|
||||
m_data->m_transactionId = _transactionId;
|
||||
m_data->m_isFinished = false;
|
||||
m_data->m_clientId = _clientId;
|
||||
m_data->m_isSynchronous = false;
|
||||
m_data->m_callbackFinish = _callback;
|
||||
}
|
||||
@ -35,29 +35,28 @@ ememory::SharedPtr<zeus::Buffer> zeus::FutureBase::getRaw() {
|
||||
return m_data->m_returnData;
|
||||
}
|
||||
|
||||
zeus::FutureBase::FutureBase(uint64_t _transactionId, bool _isFinished, const ememory::SharedPtr<zeus::Buffer>& _returnData, zeus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureBase::FutureBase(uint32_t _transactionId, const ememory::SharedPtr<zeus::Buffer>& _returnData, zeus::FutureData::ObserverFinish _callback, uint32_t _clientId) {
|
||||
m_data = std::make_shared<zeus::FutureData>();
|
||||
if (m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_data->m_sendTime = std::chrono::steady_clock::now();
|
||||
m_data->m_transactionId = _transactionId;
|
||||
m_data->m_isFinished = _isFinished;
|
||||
m_data->m_isSynchronous = false;
|
||||
m_data->m_returnData = _returnData;
|
||||
m_data->m_callbackFinish = _callback;
|
||||
if (m_data->m_isFinished == true) {
|
||||
if (isFinished() == true) {
|
||||
m_data->m_receiveTime = std::chrono::steady_clock::now();
|
||||
if (m_data->m_callbackFinish != nullptr) {
|
||||
m_data->m_callbackFinish(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::chrono::nanoseconds zeus::FutureBase::getTransmitionTime() {
|
||||
std::chrono::nanoseconds zeus::FutureBase::getTransmitionTime() const {
|
||||
if (m_data == nullptr) {
|
||||
return std::chrono::nanoseconds(0);
|
||||
}
|
||||
if (m_data->m_isFinished == false) {
|
||||
if (isFinished() == false) {
|
||||
return std::chrono::nanoseconds(0);
|
||||
}
|
||||
return m_data->m_receiveTime - m_data->m_sendTime;
|
||||
@ -68,7 +67,7 @@ zeus::FutureBase zeus::FutureBase::operator= (const zeus::FutureBase& _base) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool zeus::FutureBase::setAnswer(const ememory::SharedPtr<zeus::Buffer>& _value) {
|
||||
bool zeus::FutureBase::appendData(const ememory::SharedPtr<zeus::Buffer>& _value) {
|
||||
if (m_data == nullptr) {
|
||||
ZEUS_ERROR(" Not a valid future ...");
|
||||
return true;
|
||||
@ -88,11 +87,13 @@ bool zeus::FutureBase::setAnswer(const ememory::SharedPtr<zeus::Buffer>& _value)
|
||||
} else {
|
||||
m_data->m_returnData = _value;
|
||||
}
|
||||
m_data->m_isFinished = _value->getPartFinish();
|
||||
if (m_data->m_returnData == nullptr) {
|
||||
return true;
|
||||
}
|
||||
if (m_data->m_callbackFinish != nullptr) {
|
||||
return m_data->m_callbackFinish(*this);
|
||||
}
|
||||
return m_data->m_isFinished;
|
||||
return m_data->m_returnData->getPartFinish();
|
||||
}
|
||||
void zeus::FutureBase::setSynchronous() {
|
||||
if (m_data == nullptr) {
|
||||
@ -101,21 +102,28 @@ void zeus::FutureBase::setSynchronous() {
|
||||
m_data->m_isSynchronous = true;
|
||||
}
|
||||
|
||||
uint64_t zeus::FutureBase::getTransactionId() {
|
||||
uint32_t zeus::FutureBase::getTransactionId() const {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_transactionId;
|
||||
}
|
||||
|
||||
bool zeus::FutureBase::hasError() {
|
||||
uint32_t zeus::FutureBase::getClientId() const {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_clientId;
|
||||
}
|
||||
|
||||
bool zeus::FutureBase::hasError() const {
|
||||
if (m_data == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return m_data->m_returnData->hasError();
|
||||
}
|
||||
|
||||
std::string zeus::FutureBase::getErrorType() {
|
||||
std::string zeus::FutureBase::getErrorType() const {
|
||||
if ( m_data == nullptr
|
||||
|| m_data->m_returnData == nullptr) {
|
||||
return "NULL_PTR";
|
||||
@ -123,7 +131,7 @@ std::string zeus::FutureBase::getErrorType() {
|
||||
return m_data->m_returnData->getError();
|
||||
}
|
||||
|
||||
std::string zeus::FutureBase::getErrorHelp() {
|
||||
std::string zeus::FutureBase::getErrorHelp() const {
|
||||
if ( m_data == nullptr
|
||||
|| m_data->m_returnData == nullptr) {
|
||||
return "Thsi is a nullptr future";
|
||||
@ -139,10 +147,13 @@ bool zeus::FutureBase::isFinished() const {
|
||||
if (m_data == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return m_data->m_isFinished;
|
||||
if (m_data->m_returnData == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return m_data->m_returnData->getPartFinish();
|
||||
}
|
||||
|
||||
zeus::FutureBase& zeus::FutureBase::wait() {
|
||||
const zeus::FutureBase& zeus::FutureBase::wait() const {
|
||||
while (isFinished() == false) {
|
||||
// TODO : Do it better ... like messaging/mutex_locked ...
|
||||
usleep(10000);
|
||||
@ -150,7 +161,7 @@ zeus::FutureBase& zeus::FutureBase::wait() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
zeus::FutureBase& zeus::FutureBase::waitFor(std::chrono::microseconds _delta) {
|
||||
const zeus::FutureBase& zeus::FutureBase::waitFor(std::chrono::microseconds _delta) const {
|
||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
||||
while ( std::chrono::steady_clock::now() - start < _delta
|
||||
&& isFinished() == false) {
|
||||
@ -161,7 +172,7 @@ zeus::FutureBase& zeus::FutureBase::waitFor(std::chrono::microseconds _delta) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
zeus::FutureBase& zeus::FutureBase::waitUntil(std::chrono::steady_clock::time_point _endTime) {
|
||||
const zeus::FutureBase& zeus::FutureBase::waitUntil(std::chrono::steady_clock::time_point _endTime) const {
|
||||
while ( std::chrono::steady_clock::now() < _endTime
|
||||
&& isFinished() == false) {
|
||||
// TODO : Do it better ... like messaging/mutex_locked ...
|
||||
@ -170,43 +181,3 @@ zeus::FutureBase& zeus::FutureBase::waitUntil(std::chrono::steady_clock::time_po
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
zeus::FutureCall::FutureCall(uint64_t _clientId, uint64_t _transactionId, const ememory::SharedPtr<zeus::Buffer>& _callValue) :
|
||||
m_transactionId(_transactionId),
|
||||
m_clientId(_clientId),
|
||||
m_isFinished(false) {
|
||||
m_data = _callValue;
|
||||
m_isFinished = m_data->getPartFinish();
|
||||
}
|
||||
|
||||
void zeus::FutureCall::appendData(const ememory::SharedPtr<zeus::Buffer>& _value) {
|
||||
if (_value->getType() == zeus::Buffer::typeMessage::data) {
|
||||
if (m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_data->appendBufferData(_value);
|
||||
} else {
|
||||
m_data = _value;
|
||||
}
|
||||
m_isFinished = _value->getPartFinish();
|
||||
}
|
||||
|
||||
uint64_t zeus::FutureCall::getTransactionId() const {
|
||||
return m_transactionId;
|
||||
}
|
||||
|
||||
uint64_t zeus::FutureCall::getClientId() const {
|
||||
return m_clientId;
|
||||
}
|
||||
|
||||
bool zeus::FutureCall::isFinished() const {
|
||||
return m_isFinished;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<zeus::Buffer> zeus::FutureCall::getRaw() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds zeus::FutureCall::getTransmitionTime() const {
|
||||
return m_answerTime - m_receiveTime;
|
||||
}
|
||||
|
@ -28,17 +28,18 @@ namespace zeus {
|
||||
* @brief Contructor of the FutureBase with an ofserver
|
||||
* @param[in] _transactionId Transaction waiting answer
|
||||
* @param[in] _callback Observer pointer
|
||||
* @param[in] _clientId Client/sevice Id waiting answer
|
||||
*/
|
||||
FutureBase(uint64_t _transactionId, zeus::FutureData::ObserverFinish _callback=nullptr);
|
||||
FutureBase(uint32_t _transactionId, zeus::FutureData::ObserverFinish _callback=nullptr, uint32_t _clientId=0);
|
||||
/**
|
||||
* @brief Contructor of the FutureBase for direct error answer
|
||||
* @param[in] _transactionId Transaction waiting answer
|
||||
* @param[in] _isFinished set state finish or not
|
||||
* @param[in] _returnData Set return value
|
||||
* @param[in] _callback Observer pointer
|
||||
* @return
|
||||
* @param[in] _clientId Client/sevice Id waiting answer
|
||||
*/
|
||||
FutureBase(uint64_t _transactionId, bool _isFinished, const ememory::SharedPtr<zeus::Buffer>& _returnData, zeus::FutureData::ObserverFinish _callback=nullptr);
|
||||
FutureBase(uint32_t _transactionId, const ememory::SharedPtr<zeus::Buffer>& _returnData, zeus::FutureData::ObserverFinish _callback=nullptr, uint32_t _clientId=0);
|
||||
/**
|
||||
* @brief Asignement operator with an other future
|
||||
* @param[in] _base Generic base Future
|
||||
@ -46,11 +47,11 @@ namespace zeus {
|
||||
*/
|
||||
zeus::FutureBase operator= (const zeus::FutureBase& _base);
|
||||
/**
|
||||
* @brief specify answer of the call
|
||||
* @brief Add data on the call/answer
|
||||
* @param[in] _returnValue Returned buffer
|
||||
* @return return true if an error occured
|
||||
*/
|
||||
bool setAnswer(const ememory::SharedPtr<zeus::Buffer>& _returnValue);
|
||||
bool appendData(const ememory::SharedPtr<zeus::Buffer>& _returnValue);
|
||||
/**
|
||||
* @brief Set the future syncronous
|
||||
* @note this mean that the system call the observer every time a packet arrive in the Future
|
||||
@ -60,22 +61,27 @@ namespace zeus {
|
||||
* @brief Get the transaction Id of the Future
|
||||
* @return Transaction Id requested or 0
|
||||
*/
|
||||
uint64_t getTransactionId();
|
||||
uint32_t getTransactionId() const;
|
||||
/**
|
||||
* @brief Get the client Id of the Future
|
||||
* @return Client id requested or 0
|
||||
*/
|
||||
uint32_t getClientId() const;
|
||||
/**
|
||||
* @brief check if the answer have an error
|
||||
* @return return true if an error is registered
|
||||
*/
|
||||
bool hasError();
|
||||
bool hasError() const;
|
||||
/**
|
||||
* @brief get type of the error
|
||||
* @return the string of the error type
|
||||
*/
|
||||
std::string getErrorType();
|
||||
std::string getErrorType() const;
|
||||
/**
|
||||
* @brief get help of the error
|
||||
* @return the string of the error help
|
||||
*/
|
||||
std::string getErrorHelp();
|
||||
std::string getErrorHelp() const;
|
||||
/**
|
||||
* @brief Check if the Futur is a valid data
|
||||
* @return return true if the data is valid
|
||||
@ -90,19 +96,19 @@ namespace zeus {
|
||||
* @brief Wait the Future receive data
|
||||
* @return reference on the current futur
|
||||
*/
|
||||
FutureBase& wait();
|
||||
const FutureBase& wait() const;
|
||||
/**
|
||||
* @brief Wait the Future receive data
|
||||
* @param[in] _delta delay to wait the data arrive
|
||||
* @return reference on the current futur
|
||||
*/
|
||||
FutureBase& waitFor(std::chrono::microseconds _delta = std::chrono::seconds(30));
|
||||
const FutureBase& waitFor(std::chrono::microseconds _delta = std::chrono::seconds(30)) const;
|
||||
/**
|
||||
* @brief Wait the Future receive data
|
||||
* @param[in] _endTime tiem to wait the data
|
||||
* @return reference on the current futur
|
||||
*/
|
||||
FutureBase& waitUntil(std::chrono::steady_clock::time_point _endTime);
|
||||
const FutureBase& waitUntil(std::chrono::steady_clock::time_point _endTime) const;
|
||||
/**
|
||||
* @brief Get the Buffer receive
|
||||
* @return pointer on the receive data
|
||||
@ -112,62 +118,7 @@ namespace zeus {
|
||||
* @brief Get duration of the current trasaction take
|
||||
* @return Tile in nanosecond to wait answer
|
||||
*/
|
||||
std::chrono::nanoseconds getTransmitionTime();
|
||||
};
|
||||
/**
|
||||
* @brief Receiving call futur
|
||||
*/
|
||||
class FutureCall {
|
||||
private:
|
||||
uint64_t m_transactionId;
|
||||
uint64_t m_clientId;
|
||||
bool m_isFinished;
|
||||
ememory::SharedPtr<zeus::Buffer> m_data;
|
||||
std::chrono::steady_clock::time_point m_receiveTime;
|
||||
std::chrono::steady_clock::time_point m_answerTime;
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
FutureCall(uint64_t _clientId, uint64_t _transactionId, const ememory::SharedPtr<zeus::Buffer>& _callValue);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
void appendData(const ememory::SharedPtr<zeus::Buffer>& _callValue);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
uint64_t getTransactionId() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
uint64_t getClientId() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
bool isFinished() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
std::chrono::nanoseconds getTransmitionTime() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
ememory::SharedPtr<zeus::Buffer> getRaw() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -13,17 +13,20 @@
|
||||
|
||||
namespace zeus {
|
||||
class FutureBase;
|
||||
/**
|
||||
* @brief Data interface of the future (the future can be copied, but the data need to stay...
|
||||
*/
|
||||
class FutureData {
|
||||
public:
|
||||
using ObserverFinish = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
|
||||
public:
|
||||
uint64_t m_transactionId;
|
||||
bool m_isSynchronous;
|
||||
bool m_isFinished;
|
||||
ememory::SharedPtr<zeus::Buffer> m_returnData;
|
||||
ObserverFinish m_callbackFinish;
|
||||
std::chrono::steady_clock::time_point m_sendTime;
|
||||
std::chrono::steady_clock::time_point m_receiveTime;
|
||||
uint32_t m_transactionId; //!< waiting answer data
|
||||
uint32_t m_clientId; //!< need to anser at this client.
|
||||
bool m_isSynchronous; //!< the future is synchronous. (call when receive data)
|
||||
ememory::SharedPtr<zeus::Buffer> m_returnData; //!< all buffer concatenate or last buffer if synchronous
|
||||
ObserverFinish m_callbackFinish; //!< ofserver of the finish data
|
||||
std::chrono::steady_clock::time_point m_sendTime; //!< time when the future has been sended request
|
||||
std::chrono::steady_clock::time_point m_receiveTime; //!< time when the future has receve answer
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -93,8 +93,9 @@ bool zeus::ParamType::operator != (const uint16_t& _value) const {
|
||||
|
||||
#define generate_basic_type(_type, _name, _id, _num, _vect) \
|
||||
namespace zeus { \
|
||||
template<> zeus::ParamType createType<_type>() {\
|
||||
return zeus::ParamType(_name, _id, _num, _vect); \
|
||||
template<> const zeus::ParamType& createType<_type>() {\
|
||||
static zeus::ParamType type(_name, _id, _num, _vect); \
|
||||
return type; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -9,106 +9,100 @@
|
||||
|
||||
namespace zeus {
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief generisation of type of the type of the parameter
|
||||
*/
|
||||
class ParamType {
|
||||
protected:
|
||||
const std::string m_typeName;
|
||||
const uint16_t m_id;
|
||||
const bool m_isNumber;
|
||||
const bool m_isVector;
|
||||
const std::string m_typeName; //!< generic type
|
||||
const uint16_t m_id; //!< simplification ID (if possible)
|
||||
const bool m_isNumber; //!< if the element is a number (convertion possible)
|
||||
const bool m_isVector; //!< if the element is a vector (convertion possible)
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @brief contructor onf a generic name parameter
|
||||
* @param[in] _name Name of the parameter
|
||||
* @param[in] _id Generic Id of the parameter
|
||||
* @param[in] _isNumber set true of the type is a number
|
||||
* @param[in] _isVector set true of the type is a vector element
|
||||
* @return
|
||||
*/
|
||||
ParamType(const char* _name = "", uint16_t _id=0, bool _isNumber=false, bool _isVector=false);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @copydoc zeus::ParamType::ParamType
|
||||
*/
|
||||
ParamType(const std::string& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Get name of tha parameter
|
||||
* @return string describing the TYPE
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Get generic Id of the type
|
||||
* @return unsigned int containing the type
|
||||
*/
|
||||
uint16_t getId() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Egality comparaison with an other parameter
|
||||
* @param[in] _obj Other parameter to compare type
|
||||
* @return true if the 2 object are identical
|
||||
*/
|
||||
bool operator == (const ParamType& _obj) const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Difference comparaison with an other parameter
|
||||
* @param[in] _obj Other parameter to compare type
|
||||
* @return true if the 2 object are different
|
||||
*/
|
||||
bool operator != (const ParamType& _obj) const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Egality comparaison with an other parameter
|
||||
* @param[in] _obj Other parameter to compare type in strin
|
||||
* @return true if the 2 object are identical
|
||||
*/
|
||||
bool operator == (const std::string& _value) const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Difference comparaison with an other parameter
|
||||
* @param[in] _obj Other parameter to compare type in string
|
||||
* @return true if the 2 object are different
|
||||
*/
|
||||
bool operator != (const std::string& _value) const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Egality comparaison with an other parameter
|
||||
* @param[in] _obj Other parameter to compare type enum integer
|
||||
* @return true if the 2 object are identical
|
||||
*/
|
||||
bool operator == (const uint16_t& _value) const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Difference comparaison with an other parameter
|
||||
* @param[in] _obj Other parameter to compare type enum integer
|
||||
* @return true if the 2 object are different
|
||||
*/
|
||||
bool operator != (const uint16_t& _value) const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Check if the type is a number
|
||||
* @return return true if the type is a number
|
||||
*/
|
||||
bool isNumber() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Check if the type is a vector
|
||||
* @return return true if the type is a vector
|
||||
*/
|
||||
bool isVector() const;
|
||||
};
|
||||
extern const uint16_t paramTypeObject;
|
||||
extern const uint16_t paramTypeRaw;
|
||||
extern const uint16_t paramTypeObject; //!< van not automatic create a type with the string named object
|
||||
extern const uint16_t paramTypeRaw; //!< Raw type (special case of data)
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Create human readable stream to debug
|
||||
* @param[in] _os the stream to inject data
|
||||
* @param[in] _obj Object to display
|
||||
* @return The inpout stream
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, const zeus::ParamType& _obj);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Template to automaticly get the type of an generic std type without create a dynamic element
|
||||
* @return generic parameter created
|
||||
*/
|
||||
template<class ZEUS_TYPE>
|
||||
ParamType createType();
|
||||
const ParamType& createType();
|
||||
/**
|
||||
* @brief Check the compatibility of 2 parameter type
|
||||
* @param[in] _first First parameter to check
|
||||
|
@ -12,73 +12,63 @@
|
||||
|
||||
namespace zeus {
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Local declaration of call local data
|
||||
*/
|
||||
class RemoteProcessCall {
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Basic constructor
|
||||
*/
|
||||
RemoteProcessCall();
|
||||
protected:
|
||||
std::vector<zeus::AbstractFunction*> m_listFunction;
|
||||
std::vector<zeus::AbstractFunction*> m_listFunction; //!< List of all functions callable
|
||||
protected:
|
||||
std::string m_description;
|
||||
std::string m_description; //!< Description of the service
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Set service description
|
||||
* @param[in] _desc String with the describe of the service
|
||||
*/
|
||||
void setDescription(const std::string& _desc);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Get service description
|
||||
* @return String with the describe of the service
|
||||
*/
|
||||
std::string getDescription();
|
||||
protected:
|
||||
std::string m_version;
|
||||
std::string m_version; //!< Version of the service
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Set the Version of the service
|
||||
* @param[in] _vers String containing the version (form: 1.0[.x[.y]][-dev]
|
||||
*/
|
||||
void setVersion(const std::string& _desc);
|
||||
void setVersion(const std::string& _vers);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Get the Version of the service
|
||||
* @return String containing the version (form: 1.0[.x[.y]][-dev]
|
||||
*/
|
||||
std::string getVersion();
|
||||
protected:
|
||||
std::vector<std::pair<std::string,std::string>> m_authors;
|
||||
std::vector<std::pair<std::string,std::string>> m_authors;//! List of autors of the module (name, email)
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Add an author on this service
|
||||
* @param[in] _name Nazme of the Author: (Surname NAME)
|
||||
* @param[in] _email email of the author to add
|
||||
*/
|
||||
void addAuthor(const std::string& _name, const std::string& _email);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Get the list of the Authors
|
||||
* @return Lisl of authors in a pair of name and email
|
||||
*/
|
||||
const std::vector<std::pair<std::string,std::string>>& getAuthors() const;
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Get simple list of authors
|
||||
* @return List Of user and email in form: "john WHO <jhon.who@here.net>"
|
||||
*/
|
||||
std::vector<std::string> getAuthors2();
|
||||
protected:
|
||||
std::string m_type;
|
||||
std::string m_type; //!< Generic type of the service
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
|
@ -52,12 +52,12 @@ void zeus::Service::onClientData(const ememory::SharedPtr<zeus::Buffer>& _value)
|
||||
}
|
||||
++it;
|
||||
}
|
||||
zeus::FutureCall futCall(clientId, tmpID, _value);
|
||||
if (futCall.isFinished() == true) {
|
||||
zeus::FutureBase futData(tmpID, _value, nullptr, clientId);
|
||||
if (futData.isFinished() == true) {
|
||||
ZEUS_INFO("Call Binary ..");
|
||||
callBinary(futCall.getRaw());
|
||||
callBinary(futData.getRaw());
|
||||
} else {
|
||||
m_callMultiData.push_back(futCall);
|
||||
m_callMultiData.push_back(futData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace zeus {
|
||||
ememory::SharedPtr<zeus::WebServer> m_interfaceClient;
|
||||
uint32_t m_id;
|
||||
std::vector<std::string> m_newData;
|
||||
std::vector<zeus::FutureCall> m_callMultiData;
|
||||
std::vector<zeus::FutureBase> m_callMultiData;
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
|
@ -57,7 +57,7 @@ namespace zeus {
|
||||
if (ret != nullptr) {
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
}
|
||||
return zeus::FutureBase(0, true, ret);
|
||||
return zeus::FutureBase(0, ret);
|
||||
}
|
||||
return m_interfaceClient->callService(m_serviceId, _functionName, _args...);
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace zeus {
|
||||
if (ret != nullptr) {
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
}
|
||||
return zeus::FutureBase(0, true, ret, _callback);
|
||||
return zeus::FutureBase(0, ret, _callback);
|
||||
}
|
||||
return m_interfaceClient->callServiceAction(m_serviceId, _functionName, _args..., _callback);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ void zeus::WebServer::ping() {
|
||||
}
|
||||
|
||||
void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer) {
|
||||
ZEUS_VERBOSE("Receive :" << _buffer);
|
||||
ZEUS_VERBOSE("Receive :" << *_buffer);
|
||||
zeus::FutureBase future;
|
||||
uint64_t tid = _buffer->getTransactionId();
|
||||
if (tid == 0) {
|
||||
@ -210,7 +210,7 @@ void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer)
|
||||
if (it.isValid() == false) {
|
||||
continue;
|
||||
}
|
||||
it.setAnswer(obj);
|
||||
it.appendData(obj);
|
||||
}
|
||||
m_pendingCall.clear();
|
||||
} else {
|
||||
@ -242,7 +242,7 @@ void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer)
|
||||
}
|
||||
return;
|
||||
}
|
||||
bool ret = future.setAnswer(_buffer);
|
||||
bool ret = future.appendData(_buffer);
|
||||
if (ret == true) {
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
auto it = m_pendingCall.begin();
|
||||
@ -308,7 +308,7 @@ zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
|
||||
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
|
||||
obj->setType(zeus::Buffer::typeMessage::answer);
|
||||
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||
return zeus::FutureBase(_transactionId, true, obj, _callback);
|
||||
return zeus::FutureBase(_transactionId, obj, _callback);
|
||||
}
|
||||
zeus::FutureBase tmpFuture(_transactionId, _callback);
|
||||
{
|
||||
@ -332,7 +332,7 @@ zeus::FutureBase zeus::WebServer::callForward(uint32_t _clientId,
|
||||
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
|
||||
obj->setType(zeus::Buffer::typeMessage::answer);
|
||||
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||
return zeus::FutureBase(0, true, obj, _callback);
|
||||
return zeus::FutureBase(0, obj, _callback);
|
||||
}
|
||||
uint64_t id = getId();
|
||||
_buffer->setTransactionId(id);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
static std::vector<std::pair<std::string, std::string>> mineList = {
|
||||
/* Video files */
|
||||
{ "webm", "video/webm"},
|
||||
{ "asf", "video/x-ms-asf"},
|
||||
{ "avc", "video/avi"},
|
||||
{ "avi", "video/avi"},
|
||||
@ -42,6 +43,7 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
|
||||
{ "iso", "video/mpeg2"},
|
||||
|
||||
/* Audio files */
|
||||
{ "weba", "audio/webm"},
|
||||
{ "3gp", "audio/3gpp"},
|
||||
{ "aac", "audio/x-aac"},
|
||||
{ "ac3", "audio/x-ac3"},
|
||||
@ -72,6 +74,7 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
|
||||
{ "flac", "audio/x-flac"},
|
||||
|
||||
/* Images files */
|
||||
{ "webp", "image/webp"},
|
||||
{ "bmp", "image/bmp"},
|
||||
{ "ico", "image/x-icon"},
|
||||
{ "gif", "image/gif"},
|
||||
|
@ -8,15 +8,15 @@
|
||||
|
||||
namespace zeus {
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief get the mine type with the file extention
|
||||
* @param[in] _extention file extention (without the '.')
|
||||
* @return The generic mine tipe in http format
|
||||
*/
|
||||
std::string getMineType(const std::string& _extention);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
* @return
|
||||
* @brief Retrive the extention of a file with his mine type
|
||||
* @param[in] _mineType Mine tipe in http format
|
||||
* @return file extention (without the '.')
|
||||
*/
|
||||
std::string getExtention(const std::string& _mineType);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user