[DEV/DOC] add basic comment and some change (NOT WORK)

This commit is contained in:
Edouard DUPIN 2016-06-24 23:24:42 +02:00
parent 7ee8e2332c
commit f76787a7d2
14 changed files with 158 additions and 245 deletions

View File

@ -68,13 +68,13 @@ bool zeus::Client::connectTo(const std::string& _address) {
return ret.get(); return ret.get();
} }
bool connect(const std::string& _address) { bool zeus::Client::connect(const std::string& _address) {
bool ret = connectTo(_address); bool ret = connectTo(_address);
if (ret==false) { if (ret==false) {
return false; return false;
} }
zeus::Future<bool> retIdentify = call("anonymous").wait(); zeus::Future<bool> retIdentify = call("anonymous").wait();
if (retIdentify.haveError() == true) { if (retIdentify.hasError() == true) {
disconnect(); disconnect();
return false; return false;
} }
@ -84,13 +84,13 @@ bool connect(const std::string& _address) {
return retIdentify.get(); 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); bool ret = connectTo(_address);
if (ret==false) { if (ret==false) {
return false; return false;
} }
zeus::Future<bool> retIdentify = call("auth", _userPassword).wait(); zeus::Future<bool> retIdentify = call("auth", _userPassword).wait();
if (retIdentify.haveError() == true) { if (retIdentify.hasError() == true) {
disconnect(); disconnect();
return false; return false;
} }
@ -100,13 +100,13 @@ bool connect(const std::string& _address, const std::string& _userPassword) {
return retIdentify.get(); 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); bool ret = connectTo(_address);
if (ret==false) { if (ret==false) {
return false; return false;
} }
zeus::Future<bool> retIdentify = call("identify", _clientName, _clientTocken).wait(); zeus::Future<bool> retIdentify = call("identify", _clientName, _clientTocken).wait();
if (retIdentify.haveError() == true) { if (retIdentify.hasError() == true) {
disconnect(); disconnect();
return false; return false;
} }

View File

@ -106,7 +106,7 @@ namespace zeus {
if (m_interfaceClient == nullptr) { if (m_interfaceClient == nullptr) {
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create(); ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
ret->addError("NULLPTR", "call " + _functionName + " with no interface open"); 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...); return m_interfaceClient->call(_functionName, _args...);
} }
@ -122,7 +122,7 @@ namespace zeus {
if (m_interfaceClient == nullptr) { if (m_interfaceClient == nullptr) {
ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create(); ememory::SharedPtr<zeus::Buffer> ret = zeus::Buffer::create();
ret->addError("NULLPTR", "call " + _functionName + " with no interface open"); 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); return m_interfaceClient->callAction(_functionName, _args..., _callback);
} }

View File

@ -16,14 +16,14 @@ zeus::FutureBase::FutureBase() {
m_data = nullptr; 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>(); m_data = std::make_shared<zeus::FutureData>();
if (m_data == nullptr) { if (m_data == nullptr) {
return; return;
} }
m_data->m_sendTime = std::chrono::steady_clock::now(); m_data->m_sendTime = std::chrono::steady_clock::now();
m_data->m_transactionId = _transactionId; m_data->m_transactionId = _transactionId;
m_data->m_isFinished = false; m_data->m_clientId = _clientId;
m_data->m_isSynchronous = false; m_data->m_isSynchronous = false;
m_data->m_callbackFinish = _callback; m_data->m_callbackFinish = _callback;
} }
@ -35,29 +35,28 @@ ememory::SharedPtr<zeus::Buffer> zeus::FutureBase::getRaw() {
return m_data->m_returnData; 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>(); m_data = std::make_shared<zeus::FutureData>();
if (m_data == nullptr) { if (m_data == nullptr) {
return; return;
} }
m_data->m_sendTime = std::chrono::steady_clock::now(); m_data->m_sendTime = std::chrono::steady_clock::now();
m_data->m_transactionId = _transactionId; m_data->m_transactionId = _transactionId;
m_data->m_isFinished = _isFinished;
m_data->m_isSynchronous = false; m_data->m_isSynchronous = false;
m_data->m_returnData = _returnData; m_data->m_returnData = _returnData;
m_data->m_callbackFinish = _callback; m_data->m_callbackFinish = _callback;
if (m_data->m_isFinished == true) { if (isFinished() == true) {
m_data->m_receiveTime = std::chrono::steady_clock::now(); m_data->m_receiveTime = std::chrono::steady_clock::now();
if (m_data->m_callbackFinish != nullptr) { if (m_data->m_callbackFinish != nullptr) {
m_data->m_callbackFinish(*this); m_data->m_callbackFinish(*this);
} }
} }
} }
std::chrono::nanoseconds zeus::FutureBase::getTransmitionTime() { std::chrono::nanoseconds zeus::FutureBase::getTransmitionTime() const {
if (m_data == nullptr) { if (m_data == nullptr) {
return std::chrono::nanoseconds(0); return std::chrono::nanoseconds(0);
} }
if (m_data->m_isFinished == false) { if (isFinished() == false) {
return std::chrono::nanoseconds(0); return std::chrono::nanoseconds(0);
} }
return m_data->m_receiveTime - m_data->m_sendTime; return m_data->m_receiveTime - m_data->m_sendTime;
@ -68,7 +67,7 @@ zeus::FutureBase zeus::FutureBase::operator= (const zeus::FutureBase& _base) {
return *this; 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) { if (m_data == nullptr) {
ZEUS_ERROR(" Not a valid future ..."); ZEUS_ERROR(" Not a valid future ...");
return true; return true;
@ -88,11 +87,13 @@ bool zeus::FutureBase::setAnswer(const ememory::SharedPtr<zeus::Buffer>& _value)
} else { } else {
m_data->m_returnData = _value; 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) { if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this); return m_data->m_callbackFinish(*this);
} }
return m_data->m_isFinished; return m_data->m_returnData->getPartFinish();
} }
void zeus::FutureBase::setSynchronous() { void zeus::FutureBase::setSynchronous() {
if (m_data == nullptr) { if (m_data == nullptr) {
@ -101,21 +102,28 @@ void zeus::FutureBase::setSynchronous() {
m_data->m_isSynchronous = true; m_data->m_isSynchronous = true;
} }
uint64_t zeus::FutureBase::getTransactionId() { uint32_t zeus::FutureBase::getTransactionId() const {
if (m_data == nullptr) { if (m_data == nullptr) {
return 0; return 0;
} }
return m_data->m_transactionId; 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) { if (m_data == nullptr) {
return true; return true;
} }
return m_data->m_returnData->hasError(); return m_data->m_returnData->hasError();
} }
std::string zeus::FutureBase::getErrorType() { std::string zeus::FutureBase::getErrorType() const {
if ( m_data == nullptr if ( m_data == nullptr
|| m_data->m_returnData == nullptr) { || m_data->m_returnData == nullptr) {
return "NULL_PTR"; return "NULL_PTR";
@ -123,7 +131,7 @@ std::string zeus::FutureBase::getErrorType() {
return m_data->m_returnData->getError(); return m_data->m_returnData->getError();
} }
std::string zeus::FutureBase::getErrorHelp() { std::string zeus::FutureBase::getErrorHelp() const {
if ( m_data == nullptr if ( m_data == nullptr
|| m_data->m_returnData == nullptr) { || m_data->m_returnData == nullptr) {
return "Thsi is a nullptr future"; return "Thsi is a nullptr future";
@ -139,10 +147,13 @@ bool zeus::FutureBase::isFinished() const {
if (m_data == nullptr) { if (m_data == nullptr) {
return true; 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) { while (isFinished() == false) {
// TODO : Do it better ... like messaging/mutex_locked ... // TODO : Do it better ... like messaging/mutex_locked ...
usleep(10000); usleep(10000);
@ -150,7 +161,7 @@ zeus::FutureBase& zeus::FutureBase::wait() {
return *this; 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(); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
while ( std::chrono::steady_clock::now() - start < _delta while ( std::chrono::steady_clock::now() - start < _delta
&& isFinished() == false) { && isFinished() == false) {
@ -161,7 +172,7 @@ zeus::FutureBase& zeus::FutureBase::waitFor(std::chrono::microseconds _delta) {
return *this; 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 while ( std::chrono::steady_clock::now() < _endTime
&& isFinished() == false) { && isFinished() == false) {
// TODO : Do it better ... like messaging/mutex_locked ... // 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; 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;
}

View File

@ -28,17 +28,18 @@ namespace zeus {
* @brief Contructor of the FutureBase with an ofserver * @brief Contructor of the FutureBase with an ofserver
* @param[in] _transactionId Transaction waiting answer * @param[in] _transactionId Transaction waiting answer
* @param[in] _callback Observer pointer * @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 * @brief Contructor of the FutureBase for direct error answer
* @param[in] _transactionId Transaction waiting answer * @param[in] _transactionId Transaction waiting answer
* @param[in] _isFinished set state finish or not * @param[in] _isFinished set state finish or not
* @param[in] _returnData Set return value * @param[in] _returnData Set return value
* @param[in] _callback Observer pointer * @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 * @brief Asignement operator with an other future
* @param[in] _base Generic base Future * @param[in] _base Generic base Future
@ -46,11 +47,11 @@ namespace zeus {
*/ */
zeus::FutureBase operator= (const zeus::FutureBase& _base); 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 * @param[in] _returnValue Returned buffer
* @return return true if an error occured * @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 * @brief Set the future syncronous
* @note this mean that the system call the observer every time a packet arrive in the Future * @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 * @brief Get the transaction Id of the Future
* @return Transaction Id requested or 0 * @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 * @brief check if the answer have an error
* @return return true if an error is registered * @return return true if an error is registered
*/ */
bool hasError(); bool hasError() const;
/** /**
* @brief get type of the error * @brief get type of the error
* @return the string of the error type * @return the string of the error type
*/ */
std::string getErrorType(); std::string getErrorType() const;
/** /**
* @brief get help of the error * @brief get help of the error
* @return the string of the error help * @return the string of the error help
*/ */
std::string getErrorHelp(); std::string getErrorHelp() const;
/** /**
* @brief Check if the Futur is a valid data * @brief Check if the Futur is a valid data
* @return return true if the data is valid * @return return true if the data is valid
@ -90,19 +96,19 @@ namespace zeus {
* @brief Wait the Future receive data * @brief Wait the Future receive data
* @return reference on the current futur * @return reference on the current futur
*/ */
FutureBase& wait(); const FutureBase& wait() const;
/** /**
* @brief Wait the Future receive data * @brief Wait the Future receive data
* @param[in] _delta delay to wait the data arrive * @param[in] _delta delay to wait the data arrive
* @return reference on the current futur * @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 * @brief Wait the Future receive data
* @param[in] _endTime tiem to wait the data * @param[in] _endTime tiem to wait the data
* @return reference on the current futur * @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 * @brief Get the Buffer receive
* @return pointer on the receive data * @return pointer on the receive data
@ -112,62 +118,7 @@ namespace zeus {
* @brief Get duration of the current trasaction take * @brief Get duration of the current trasaction take
* @return Tile in nanosecond to wait answer * @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; std::chrono::nanoseconds getTransmitionTime() const;
/**
* @brief
* @param[in]
* @return
*/
ememory::SharedPtr<zeus::Buffer> getRaw() const;
}; };
} }

View File

@ -13,17 +13,20 @@
namespace zeus { namespace zeus {
class FutureBase; class FutureBase;
/**
* @brief Data interface of the future (the future can be copied, but the data need to stay...
*/
class FutureData { class FutureData {
public: public:
using ObserverFinish = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer using ObserverFinish = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
public: public:
uint64_t m_transactionId; uint32_t m_transactionId; //!< waiting answer data
bool m_isSynchronous; uint32_t m_clientId; //!< need to anser at this client.
bool m_isFinished; bool m_isSynchronous; //!< the future is synchronous. (call when receive data)
ememory::SharedPtr<zeus::Buffer> m_returnData; ememory::SharedPtr<zeus::Buffer> m_returnData; //!< all buffer concatenate or last buffer if synchronous
ObserverFinish m_callbackFinish; ObserverFinish m_callbackFinish; //!< ofserver of the finish data
std::chrono::steady_clock::time_point m_sendTime; std::chrono::steady_clock::time_point m_sendTime; //!< time when the future has been sended request
std::chrono::steady_clock::time_point m_receiveTime; std::chrono::steady_clock::time_point m_receiveTime; //!< time when the future has receve answer
}; };
} }

View File

@ -93,8 +93,9 @@ bool zeus::ParamType::operator != (const uint16_t& _value) const {
#define generate_basic_type(_type, _name, _id, _num, _vect) \ #define generate_basic_type(_type, _name, _id, _num, _vect) \
namespace zeus { \ namespace zeus { \
template<> zeus::ParamType createType<_type>() {\ template<> const zeus::ParamType& createType<_type>() {\
return zeus::ParamType(_name, _id, _num, _vect); \ static zeus::ParamType type(_name, _id, _num, _vect); \
return type; \
} \ } \
} }

View File

@ -9,106 +9,100 @@
namespace zeus { namespace zeus {
/** /**
* @brief * @brief generisation of type of the type of the parameter
* @param[in]
* @return
*/ */
class ParamType { class ParamType {
protected: protected:
const std::string m_typeName; const std::string m_typeName; //!< generic type
const uint16_t m_id; const uint16_t m_id; //!< simplification ID (if possible)
const bool m_isNumber; const bool m_isNumber; //!< if the element is a number (convertion possible)
const bool m_isVector; const bool m_isVector; //!< if the element is a vector (convertion possible)
public: public:
/** /**
* @brief * @brief contructor onf a generic name parameter
* @param[in] * @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 * @return
*/ */
ParamType(const char* _name = "", uint16_t _id=0, bool _isNumber=false, bool _isVector=false); ParamType(const char* _name = "", uint16_t _id=0, bool _isNumber=false, bool _isVector=false);
/** /**
* @brief * @copydoc zeus::ParamType::ParamType
* @param[in]
* @return
*/ */
ParamType(const std::string& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false); ParamType(const std::string& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false);
/** /**
* @brief * @brief Get name of tha parameter
* @param[in] * @return string describing the TYPE
* @return
*/ */
const std::string& getName() const; const std::string& getName() const;
/** /**
* @brief * @brief Get generic Id of the type
* @param[in] * @return unsigned int containing the type
* @return
*/ */
uint16_t getId() const; uint16_t getId() const;
/** /**
* @brief * @brief Egality comparaison with an other parameter
* @param[in] * @param[in] _obj Other parameter to compare type
* @return * @return true if the 2 object are identical
*/ */
bool operator == (const ParamType& _obj) const; bool operator == (const ParamType& _obj) const;
/** /**
* @brief * @brief Difference comparaison with an other parameter
* @param[in] * @param[in] _obj Other parameter to compare type
* @return * @return true if the 2 object are different
*/ */
bool operator != (const ParamType& _obj) const; bool operator != (const ParamType& _obj) const;
/** /**
* @brief * @brief Egality comparaison with an other parameter
* @param[in] * @param[in] _obj Other parameter to compare type in strin
* @return * @return true if the 2 object are identical
*/ */
bool operator == (const std::string& _value) const; bool operator == (const std::string& _value) const;
/** /**
* @brief * @brief Difference comparaison with an other parameter
* @param[in] * @param[in] _obj Other parameter to compare type in string
* @return * @return true if the 2 object are different
*/ */
bool operator != (const std::string& _value) const; bool operator != (const std::string& _value) const;
/** /**
* @brief * @brief Egality comparaison with an other parameter
* @param[in] * @param[in] _obj Other parameter to compare type enum integer
* @return * @return true if the 2 object are identical
*/ */
bool operator == (const uint16_t& _value) const; bool operator == (const uint16_t& _value) const;
/** /**
* @brief * @brief Difference comparaison with an other parameter
* @param[in] * @param[in] _obj Other parameter to compare type enum integer
* @return * @return true if the 2 object are different
*/ */
bool operator != (const uint16_t& _value) const; bool operator != (const uint16_t& _value) const;
/** /**
* @brief * @brief Check if the type is a number
* @param[in] * @return return true if the type is a number
* @return
*/ */
bool isNumber() const; bool isNumber() const;
/** /**
* @brief * @brief Check if the type is a vector
* @param[in] * @return return true if the type is a vector
* @return
*/ */
bool isVector() const; bool isVector() const;
}; };
extern const uint16_t paramTypeObject; extern const uint16_t paramTypeObject; //!< van not automatic create a type with the string named object
extern const uint16_t paramTypeRaw; extern const uint16_t paramTypeRaw; //!< Raw type (special case of data)
/** /**
* @brief * @brief Create human readable stream to debug
* @param[in] * @param[in] _os the stream to inject data
* @return * @param[in] _obj Object to display
* @return The inpout stream
*/ */
std::ostream& operator <<(std::ostream& _os, const zeus::ParamType& _obj); std::ostream& operator <<(std::ostream& _os, const zeus::ParamType& _obj);
/** /**
* @brief * @brief Template to automaticly get the type of an generic std type without create a dynamic element
* @param[in] * @return generic parameter created
* @return
*/ */
template<class ZEUS_TYPE> template<class ZEUS_TYPE>
ParamType createType(); const ParamType& createType();
/** /**
* @brief Check the compatibility of 2 parameter type * @brief Check the compatibility of 2 parameter type
* @param[in] _first First parameter to check * @param[in] _first First parameter to check

View File

@ -12,73 +12,63 @@
namespace zeus { namespace zeus {
/** /**
* @brief * @brief Local declaration of call local data
* @param[in]
* @return
*/ */
class RemoteProcessCall { class RemoteProcessCall {
public: public:
/** /**
* @brief * @brief Basic constructor
* @param[in]
* @return
*/ */
RemoteProcessCall(); RemoteProcessCall();
protected: protected:
std::vector<zeus::AbstractFunction*> m_listFunction; std::vector<zeus::AbstractFunction*> m_listFunction; //!< List of all functions callable
protected: protected:
std::string m_description; std::string m_description; //!< Description of the service
public: public:
/** /**
* @brief * @brief Set service description
* @param[in] * @param[in] _desc String with the describe of the service
* @return
*/ */
void setDescription(const std::string& _desc); void setDescription(const std::string& _desc);
/** /**
* @brief * @brief Get service description
* @param[in] * @return String with the describe of the service
* @return
*/ */
std::string getDescription(); std::string getDescription();
protected: protected:
std::string m_version; std::string m_version; //!< Version of the service
public: public:
/** /**
* @brief * @brief Set the Version of the service
* @param[in] * @param[in] _vers String containing the version (form: 1.0[.x[.y]][-dev]
* @return
*/ */
void setVersion(const std::string& _desc); void setVersion(const std::string& _vers);
/** /**
* @brief * @brief Get the Version of the service
* @param[in] * @return String containing the version (form: 1.0[.x[.y]][-dev]
* @return
*/ */
std::string getVersion(); std::string getVersion();
protected: 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: public:
/** /**
* @brief * @brief Add an author on this service
* @param[in] * @param[in] _name Nazme of the Author: (Surname NAME)
* @return * @param[in] _email email of the author to add
*/ */
void addAuthor(const std::string& _name, const std::string& _email); void addAuthor(const std::string& _name, const std::string& _email);
/** /**
* @brief * @brief Get the list of the Authors
* @param[in] * @return Lisl of authors in a pair of name and email
* @return
*/ */
const std::vector<std::pair<std::string,std::string>>& getAuthors() const; const std::vector<std::pair<std::string,std::string>>& getAuthors() const;
/** /**
* @brief * @brief Get simple list of authors
* @param[in] * @return List Of user and email in form: "john WHO <jhon.who@here.net>"
* @return
*/ */
std::vector<std::string> getAuthors2(); std::vector<std::string> getAuthors2();
protected: protected:
std::string m_type; std::string m_type; //!< Generic type of the service
public: public:
/** /**
* @brief * @brief

View File

@ -52,12 +52,12 @@ void zeus::Service::onClientData(const ememory::SharedPtr<zeus::Buffer>& _value)
} }
++it; ++it;
} }
zeus::FutureCall futCall(clientId, tmpID, _value); zeus::FutureBase futData(tmpID, _value, nullptr, clientId);
if (futCall.isFinished() == true) { if (futData.isFinished() == true) {
ZEUS_INFO("Call Binary .."); ZEUS_INFO("Call Binary ..");
callBinary(futCall.getRaw()); callBinary(futData.getRaw());
} else { } else {
m_callMultiData.push_back(futCall); m_callMultiData.push_back(futData);
} }
} }

View File

@ -106,7 +106,7 @@ namespace zeus {
ememory::SharedPtr<zeus::WebServer> m_interfaceClient; ememory::SharedPtr<zeus::WebServer> m_interfaceClient;
uint32_t m_id; uint32_t m_id;
std::vector<std::string> m_newData; std::vector<std::string> m_newData;
std::vector<zeus::FutureCall> m_callMultiData; std::vector<zeus::FutureBase> m_callMultiData;
public: public:
/** /**
* @brief * @brief

View File

@ -57,7 +57,7 @@ namespace zeus {
if (ret != nullptr) { if (ret != nullptr) {
ret->addError("NULLPTR", "call " + _functionName + " with no interface open"); 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...); return m_interfaceClient->callService(m_serviceId, _functionName, _args...);
} }
@ -73,7 +73,7 @@ namespace zeus {
if (ret != nullptr) { if (ret != nullptr) {
ret->addError("NULLPTR", "call " + _functionName + " with no interface open"); 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); return m_interfaceClient->callServiceAction(m_serviceId, _functionName, _args..., _callback);
} }

View File

@ -197,7 +197,7 @@ void zeus::WebServer::ping() {
} }
void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer) { void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer) {
ZEUS_VERBOSE("Receive :" << _buffer); ZEUS_VERBOSE("Receive :" << *_buffer);
zeus::FutureBase future; zeus::FutureBase future;
uint64_t tid = _buffer->getTransactionId(); uint64_t tid = _buffer->getTransactionId();
if (tid == 0) { if (tid == 0) {
@ -210,7 +210,7 @@ void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer)
if (it.isValid() == false) { if (it.isValid() == false) {
continue; continue;
} }
it.setAnswer(obj); it.appendData(obj);
} }
m_pendingCall.clear(); m_pendingCall.clear();
} else { } else {
@ -242,7 +242,7 @@ void zeus::WebServer::newBuffer(const ememory::SharedPtr<zeus::Buffer>& _buffer)
} }
return; return;
} }
bool ret = future.setAnswer(_buffer); bool ret = future.appendData(_buffer);
if (ret == true) { if (ret == true) {
std::unique_lock<std::mutex> lock(m_pendingCallMutex); std::unique_lock<std::mutex> lock(m_pendingCallMutex);
auto it = m_pendingCall.begin(); 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(); ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
obj->setType(zeus::Buffer::typeMessage::answer); obj->setType(zeus::Buffer::typeMessage::answer);
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)"); 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); 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(); ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
obj->setType(zeus::Buffer::typeMessage::answer); obj->setType(zeus::Buffer::typeMessage::answer);
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)"); 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(); uint64_t id = getId();
_buffer->setTransactionId(id); _buffer->setTransactionId(id);

View File

@ -10,6 +10,7 @@
static std::vector<std::pair<std::string, std::string>> mineList = { static std::vector<std::pair<std::string, std::string>> mineList = {
/* Video files */ /* Video files */
{ "webm", "video/webm"},
{ "asf", "video/x-ms-asf"}, { "asf", "video/x-ms-asf"},
{ "avc", "video/avi"}, { "avc", "video/avi"},
{ "avi", "video/avi"}, { "avi", "video/avi"},
@ -42,6 +43,7 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
{ "iso", "video/mpeg2"}, { "iso", "video/mpeg2"},
/* Audio files */ /* Audio files */
{ "weba", "audio/webm"},
{ "3gp", "audio/3gpp"}, { "3gp", "audio/3gpp"},
{ "aac", "audio/x-aac"}, { "aac", "audio/x-aac"},
{ "ac3", "audio/x-ac3"}, { "ac3", "audio/x-ac3"},
@ -72,6 +74,7 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
{ "flac", "audio/x-flac"}, { "flac", "audio/x-flac"},
/* Images files */ /* Images files */
{ "webp", "image/webp"},
{ "bmp", "image/bmp"}, { "bmp", "image/bmp"},
{ "ico", "image/x-icon"}, { "ico", "image/x-icon"},
{ "gif", "image/gif"}, { "gif", "image/gif"},

View File

@ -8,15 +8,15 @@
namespace zeus { namespace zeus {
/** /**
* @brief * @brief get the mine type with the file extention
* @param[in] * @param[in] _extention file extention (without the '.')
* @return * @return The generic mine tipe in http format
*/ */
std::string getMineType(const std::string& _extention); std::string getMineType(const std::string& _extention);
/** /**
* @brief * @brief Retrive the extention of a file with his mine type
* @param[in] * @param[in] _mineType Mine tipe in http format
* @return * @return file extention (without the '.')
*/ */
std::string getExtention(const std::string& _mineType); std::string getExtention(const std::string& _mineType);
}; };