[DEV/DEBUG] add etk::typeInfo declaration and correct add and remove object in list not thread safe

This commit is contained in:
Edouard DUPIN 2017-10-14 11:27:20 +02:00
parent 046e270179
commit e8a09ef7d2
27 changed files with 275 additions and 116 deletions

View File

@ -7,6 +7,9 @@
#include <zeus/debug.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::AbstractFunction);
static int32_t firstCall(bool& _value) {
_value = false;
return 51;

View File

@ -41,7 +41,7 @@ namespace zeus {
ret = (*_pointer.*_func)(notifs, _obj->getParameter<ZEUS_TYPES>(idParam--)...);
}
if (_interfaceClient == nullptr) {
ZEUS_ERROR("Nullptr for _interfaceWeb");
ZEUS_ERROR("Nullptr for _interfaceClient");
return;
}
_interfaceClient->addAsync([=](WebServer* _interface) {
@ -75,7 +75,7 @@ namespace zeus {
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
}
if (_interfaceClient == nullptr) {
ZEUS_ERROR("Nullptr for _interfaceWeb");
ZEUS_ERROR("Nullptr for _interfaceClient");
return;
}
_interfaceClient->addAsync([=](WebServer* _interface) {
@ -109,7 +109,7 @@ namespace zeus {
(*_pointer.*_func)(notifs, _obj->getParameter<ZEUS_TYPES>(idParam--)...);
}
if (_interfaceClient == nullptr) {
ZEUS_ERROR("Nullptr for _interfaceWeb");
ZEUS_ERROR("Nullptr for _interfaceClient");
return;
}
_interfaceClient->addAsync([=](WebServer* _interface) {
@ -142,7 +142,7 @@ namespace zeus {
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
}
if (_interfaceClient == nullptr) {
ZEUS_ERROR("Nullptr for _interfaceWeb");
ZEUS_ERROR("Nullptr for _interfaceClient");
return;
}
_interfaceClient->addAsync([=](WebServer* _interface) {

View File

@ -11,6 +11,10 @@
static const etk::String protocolError = "PROTOCOL-ERROR";
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::Client);
void zeus::Client::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) {
m_interfaceWeb->answerError(_transactionId, 0, ZEUS_ID_SERVICE_ROOT, protocolError, _errorHelp);
m_interfaceWeb->disconnect();

View File

@ -8,6 +8,10 @@
#include <zeus/debug.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::FutureBase);
zeus::FutureBase::FutureBase(const zeus::FutureBase& _base):
m_promise(_base.m_promise) {

View File

@ -7,6 +7,10 @@
#include <zeus/FutureGroup.hpp>
#include <zeus/debug.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::FutureGroup);
void zeus::FutureGroup::add(const zeus::FutureBase& _fut) {
m_listFuture.pushBack(_fut);
}

View File

@ -10,6 +10,8 @@
#include <enet/TcpClient.hpp>
#include <zeus/Client.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::Object);
zeus::Object::Object(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _objectId) :

View File

@ -6,6 +6,10 @@
#include <zeus/ObjectIntrospect.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::ObjectIntrospect);
zeus::ObjectIntrospect::ObjectIntrospect(zeus::ObjectRemote& _obj):
m_obj(_obj) {

View File

@ -7,7 +7,8 @@
#include <zeus/ObjectRemote.hpp>
#include <zeus/Client.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::ObjectRemoteBase);
zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const etk::String& _type):
zeus::WebObj(_iface, _localId, _localObjectId),

View File

@ -25,6 +25,7 @@ namespace zeus {
etk::String m_type; //!< name of the remote object
uint32_t m_remoteAddress; //!< remote adress of the object
bool m_isLinked; //!< link status of the object
ememory::SharedPtr<void> m_adressLocalObject; //!< Pointer on the local object if we are in the same process.
public:
/**
* @brief Contructor of the remote object

View File

@ -10,6 +10,9 @@
#include <zeus/debug.hpp>
#include <zeus/WebServer.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::Promise);
zeus::Promise::Promise(uint32_t _transactionId, uint32_t _source) {
m_sendTime = echrono::Steady::now();

View File

@ -7,6 +7,10 @@
#include <zeus/Proxy.hpp>
#include <zeus/debug.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::Proxy);
const zeus::Proxy& zeus::Proxy::operator= (const zeus::ObjectRemote& _obj) {
m_obj = _obj;
return *this;

View File

@ -6,7 +6,8 @@
#include <zeus/Raw.hpp>
#include "debug.hpp"
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::Raw);
zeus::Raw::Raw() :
m_size(0),

View File

@ -5,6 +5,10 @@
*/
#include <zeus/RemoteProcessCall.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::RemoteProcessCall);
zeus::RemoteProcessCall::RemoteProcessCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId) :
zeus::WebObj(_iface, _id, _objectId),
m_type("UNKNOW") {

View File

@ -7,6 +7,10 @@
#include <zeus/WebObj.hpp>
#include <zeus/debug.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::WebObj);
zeus::WebObj::WebObj(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId) :
m_interfaceWeb(_iface),
m_id(_id),

View File

@ -11,6 +11,10 @@
#include <zeus/message/Data.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::WebServer);
ememory::SharedPtr<zeus::message::Call> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
uint64_t _transactionId,
const uint32_t& _source,
@ -109,18 +113,19 @@ void zeus::WebServer::setInterfaceName(const etk::String& _name) {
}
void zeus::WebServer::addWebObj(ememory::SharedPtr<zeus::WebObj> _obj) {
//ethread::UniqueLock lock(m_mutex);
ethread::UniqueLock lock(m_listObjectMutex);
m_listObject.pushBack(_obj);
}
void zeus::WebServer::addWebObjRemote(ememory::SharedPtr<zeus::ObjectRemoteBase> _obj) {
//ethread::UniqueLock lock(m_mutex);
ethread::UniqueLock lock(m_listRemoteObjectMutex);
m_listRemoteObject.pushBack(_obj);
}
void zeus::WebServer::interfaceRemoved(etk::Vector<uint16_t> _list) {
ZEUS_WARNING("Remove interface : " << _list);
for (int32_t iii=0; iii < _list.size(); ++iii) {
ethread::UniqueLock lock(m_listRemoteObjectMutex);
// Call All remote Object object
for (auto it=m_listRemoteObject.begin();
it != m_listRemoteObject.end();
@ -139,6 +144,7 @@ void zeus::WebServer::interfaceRemoved(etk::Vector<uint16_t> _list) {
}
}
for (int32_t iii=0; iii < _list.size(); ++iii) {
ethread::UniqueLock lock(m_listObjectMutex);
// Call All remote Object object
for (auto it=m_listObject.begin();
it != m_listObject.end();
@ -283,7 +289,7 @@ int32_t zeus::WebServer::writeBinary(ememory::SharedPtr<zeus::Message> _obj) {
return -1;
}
bool zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols) {
etk::String zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols) {
ZEUS_INFO("Receive Header uri: " << _uri);
bool findProtocol = false;
for (auto &it : _protocols) {
@ -295,17 +301,35 @@ bool zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<et
}
if (findProtocol == false) {
ZEUS_ERROR("Disable connection request URI='" << _uri << "' with wrong protocol:" << _protocols);
return false;
return "CLOSE";
}
// TODO : Add better return on specific user ...
if (m_observerRequestUri != nullptr) {
return m_observerRequestUri(_uri);
etk::Map<etk::String,etk::String> options;
etk::String uri;
size_t pos = _uri.find('?');
if (pos == etk::String::npos) {
uri = _uri;
} else {
uri = _uri.extract(0, pos);
etk::String opt = _uri.extract(pos+1, _uri.size());
etk::Vector<etk::String> listValue = opt.split('&');
for (auto &it: listValue) {
pos = it.find('=');
if (pos == etk::String::npos) {
options.set(it, "");
} else {
options.set(it.extract(0,pos), it.extract(pos+1, it.size()));
}
}
}
return m_observerRequestUri(uri, options);
}
if (_uri == "/") {
return true;
return "OK";
}
ZEUS_ERROR("Disable connection all time the uri is not accepted by the server if the URI is not '/' URI='" << _uri << "'");
return false;
return "CLOSE";
}
void zeus::WebServer::onReceiveData(etk::Vector<uint8_t>& _frame, bool _isBinary) {
@ -414,42 +438,47 @@ void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
// Not find a pending call ==> execute it ...
if (future.isValid() == false) {
uint32_t dest = _buffer->getDestination();
// Call local object
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
if (it->getFullId() == dest) {
// send in an other async to syncronize the
m_processingPool.async(
[=](){
ememory::SharedPtr<zeus::WebObj> tmpObj = it;
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
tmpObj->receive(_buffer);
},
dest
);
return;
{
ethread::UniqueLock lock(m_listObjectMutex);
// Call local object
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
if (it->getFullId() == dest) {
// send in an other async to syncronize the
m_processingPool.async(
[=](){
ememory::SharedPtr<zeus::WebObj> tmpObj = it;
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
tmpObj->receive(_buffer);
},
dest
);
return;
}
}
}
//ethread::UniqueLock lock(m_mutex);
// call local map object on remote object
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
if (tmp == nullptr) {
continue;
}
if (tmp->getFullId() == dest) {
// send in an other async to syncronize the
m_processingPool.async(
[=](){
ememory::SharedPtr<zeus::WebObj> tmpObj = tmp;
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
tmpObj->receive(_buffer);
},
dest
);
return;
{
ethread::UniqueLock lock(m_listRemoteObjectMutex);
// call local map object on remote object
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
if (tmp == nullptr) {
continue;
}
if (tmp->getFullId() == dest) {
// send in an other async to syncronize the
m_processingPool.async(
[=](){
ememory::SharedPtr<zeus::WebObj> tmpObj = tmp;
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
tmpObj->receive(_buffer);
},
dest
);
return;
}
}
}
if (m_observerElement != nullptr) {
@ -496,24 +525,29 @@ void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
}
void zeus::WebServer::listObjects() {
//ethread::UniqueLock lock(m_mutex);
if ( m_listObject.size() == 0
&& m_listRemoteObject.size() == 0) {
return;
}
ZEUS_DEBUG("[" << m_interfaceId << "] Interface WebServer:");
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
{
ethread::UniqueLock lock(m_listObjectMutex);
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
it->display();
}
it->display();
}
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmpp = it.lock();
if (tmpp == nullptr) {
continue;
{
ethread::UniqueLock lock(m_listRemoteObjectMutex);
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmpp = it.lock();
if (tmpp == nullptr) {
continue;
}
tmpp->display();
}
tmpp->display();
}
}
@ -523,27 +557,37 @@ void zeus::WebServer::cleanDeadObject() {
&& m_listRemoteObject.size() == 0) {
return;
}
for (auto it=m_listObject.begin();
it!=m_listObject.end();
/* no auto increment*/) {
if (*it == nullptr) {
it = m_listObject.erase(it);
continue;
ZEUS_INFO("Clean DEAD object... total=" << m_listObject.size());
etk::Vector<ememory::SharedPtr<zeus::WebObj>> tmpToRemoveObjectInAsync;
{
ethread::UniqueLock lock(m_listObjectMutex);
for (auto it=m_listObject.begin();
it!=m_listObject.end();
/* no auto increment*/) {
if (*it == nullptr) {
it = m_listObject.erase(it);
continue;
}
if ((*it)->haveRemoteConnected() == false) {
tmpToRemoveObjectInAsync.pushBack(*it);
it = m_listObject.erase(it);
continue;
}
++it;
}
if ((*it)->haveRemoteConnected() == false) {
it = m_listObject.erase(it);
continue;
}
++it;
}
for (auto it=m_listRemoteObject.begin();
it!=m_listRemoteObject.end();
/* no auto increment*/) {
if (it->expired() == true) {
it = m_listRemoteObject.erase(it);
continue;
tmpToRemoveObjectInAsync.clear();
{
ethread::UniqueLock lock(m_listRemoteObjectMutex);
for (auto it=m_listRemoteObject.begin();
it!=m_listRemoteObject.end();
/* no auto increment*/) {
if (it->expired() == true) {
it = m_listRemoteObject.erase(it);
continue;
}
++it;
}
++it;
}
}
@ -553,22 +597,28 @@ bool zeus::WebServer::transferRemoteObjectOwnership(uint16_t _objectAddress, uin
&& m_listRemoteObject.size() == 0) {
return false;
}
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
if (it->getObjectId() == _objectAddress) {
return it->transferOwnership(_sourceAddress, _destinataireAddress);
{
ethread::UniqueLock lock(m_listObjectMutex);
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
if (it->getObjectId() == _objectAddress) {
return it->transferOwnership(_sourceAddress, _destinataireAddress);
}
}
}
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
if (tmp == nullptr) {
continue;
}
if (tmp->getObjectId() == _objectAddress) {
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
return false;
{
ethread::UniqueLock lock(m_listRemoteObjectMutex);
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
if (tmp == nullptr) {
continue;
}
if (tmp->getObjectId() == _objectAddress) {
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
return false;
}
}
}
return false;
@ -580,24 +630,30 @@ bool zeus::WebServer::removeObjectOwnership(uint16_t _objectAddress, uint32_t _s
&& m_listRemoteObject.size() == 0) {
return false;
}
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
//ZEUS_INFO("1 Remove ownership of " << it->getObjectId() << " == " << _objectAddress);
if (it->getObjectId() == _objectAddress) {
return it->removeOwnership(_sourceAddress);
{
ethread::UniqueLock lock(m_listObjectMutex);
for (auto &it : m_listObject) {
if (it == nullptr) {
continue;
}
ZEUS_INFO("1 Remove ownership of " << it->getObjectId() << " == " << _objectAddress);
if (it->getObjectId() == _objectAddress) {
return it->removeOwnership(_sourceAddress);
}
}
}
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
if (tmp == nullptr) {
continue;
}
//ZEUS_INFO("2 Remove ownership of " << tmp->getObjectId() << " == " << _objectAddress);
if (tmp->getObjectId() == _objectAddress) {
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
return false;
{
ethread::UniqueLock lock(m_listRemoteObjectMutex);
for (auto &it : m_listRemoteObject) {
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
if (tmp == nullptr) {
continue;
}
ZEUS_INFO("2 Remove ownership of " << tmp->getObjectId() << " == " << _objectAddress);
if (tmp->getObjectId() == _objectAddress) {
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
return false;
}
}
}
return false;
@ -618,6 +674,7 @@ void zeus::WebServer::threadAsyncCallback() {
if (m_threadAsyncList2.size() != 0) {
ethread::UniqueLock lock(m_threadAsyncMutex);
for (auto &it : m_threadAsyncList2) {
ZEUS_INFO("Add async");
m_threadAsyncList.pushBack(it);
}
m_threadAsyncList2.clear();
@ -632,6 +689,7 @@ void zeus::WebServer::threadAsyncCallback() {
bool ret = (*it)(this);
if (ret == true) {
// Remove it ...
ZEUS_INFO("Remove async");
it = m_threadAsyncList.erase(it);
} else {
++it;

View File

@ -115,6 +115,7 @@ namespace zeus {
private:
enet::WebSocket m_connection; //!< Zeus protocol is based on a webSocket to be compatible with Java-script
ethread::Pool m_processingPool; //!< Thread pool processing of the input data
// access only with the tcp thread only
etk::Vector<ememory::SharedPtr<zeus::Message>> m_listPartialMessage; //!< list of all message that data has not finished to arrive.
uint16_t m_localAddress; //!< Local client address.
uint16_t m_localIdObjectIncrement; //!< attribute an unique ID for an object.
@ -141,8 +142,18 @@ namespace zeus {
ethread::UniqueLock lock(m_mutex);
return m_localIdObjectIncrement++;
}
public:
/**
* @brief Get the address of the connection source IP:port or empty string
* @return string with the remote address name.
*/
const etk::String& getRemoteAddress() const {
return m_connection.getRemoteAddress();
}
private:
ethread::Mutex m_listObjectMutex; //!< m_listObject object protection
etk::Vector<ememory::SharedPtr<zeus::WebObj>> m_listObject; //!< List of all local object that is reference in the system.
ethread::Mutex m_listRemoteObjectMutex; //!< m_listObject object protection
etk::Vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> m_listRemoteObject; //!< List of all object that we have a reference in the local interface.
public:
/**
@ -165,6 +176,7 @@ namespace zeus {
void interfaceRemoved(etk::Vector<uint16_t> _list);
private:
uint32_t m_interfaceId; //!< local client interface ID
// TODO: add a lock here or an atomic get + increment
uint16_t m_transmissionId; //!< Unique Id of a transmission (it is != 0)
/**
* @brief Get a new transmission ID
@ -188,7 +200,15 @@ namespace zeus {
};
}
public:
using ObserverRequestUri = etk::Function<bool(const etk::String&)>; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not)
/**
* @brief Declare callback function for URI requesting
* @param[in] _uri URI connection (GET)
* @param[in] _protocols Protocol requested in the URI (ZEUS:1.0/ZEUS:0.8)
* @return "OK" Connection accepted ==> send header
* @return "CLOSE" Close the current connection: 404
* @return "REDIRECT:IP:port" Redirect at the specific IP and port
*/
using ObserverRequestUri = etk::Function<etk::String(const etk::String& _uri, const etk::Map<etk::String,etk::String>& _options)>; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not)
protected:
ObserverRequestUri m_observerRequestUri; //!< Observer on a requesting URI connection
public:
@ -198,9 +218,9 @@ namespace zeus {
* @param[in] _func Function to call.
*/
template<class CLASS_TYPE>
void connectUri(CLASS_TYPE* _class, bool (CLASS_TYPE::*_func)(const etk::String&)) {
m_observerRequestUri = [=](const etk::String& _value){
return (*_class.*_func)(_value);
void connectUri(CLASS_TYPE* _class, etk::String (CLASS_TYPE::*_func)(const etk::String& _uri, const etk::Map<etk::String,etk::String>& _options)) {
m_observerRequestUri = [=](const etk::String& _uri, const etk::Map<etk::String,etk::String>& _options){
return (*_class.*_func)(_uri, _options);
};
}
/**
@ -268,10 +288,11 @@ namespace zeus {
* @brief Called by the underprotocol for a new URI connection
* @param[in] _uri URI connection (GET)
* @param[in] _protocols Protocol requested in the URI (ZEUS:1.0/ZEUS:0.8)
* @return true the connection is accepted
* @return false the connection is rejected
* @return "OK" Connection accepted ==> send header
* @return "CLOSE" Close the current connection: 404
* @return "REDIRECT:IP:port" Redirect at the specific IP and port
*/
bool onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols);
etk::String onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols);
/**
* @brief The Zeus protocol is based on a webSocket, then the connection can send full fragment (it call newMessage when data is parsed
* @param[in] _frame A frame that has been just received

View File

@ -10,6 +10,9 @@
#include <etk/stdTools.hpp>
#include <zeus/message/Answer.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::Answer);
void zeus::message::Answer::generateDisplay(etk::Stream& _os) const {
zeus::Message::generateDisplay(_os);
if (getNumberParameter() != 0) {

View File

@ -10,6 +10,10 @@
#include <etk/stdTools.hpp>
#include <zeus/message/Call.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::Call);
void zeus::message::Call::generateDisplay(etk::Stream& _os) const {
zeus::Message::generateDisplay(_os);
_os << " '" + m_callName + "'";

View File

@ -10,6 +10,10 @@
#include <etk/stdTools.hpp>
#include <zeus/message/Data.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::Data);
void zeus::message::Data::generateDisplay(etk::Stream& _os) const {
zeus::Message::generateDisplay(_os);
_os << " paramId=" << etk::toString(m_parameterId);

View File

@ -10,6 +10,10 @@
#include <etk/stdTools.hpp>
#include <zeus/message/Event.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::Event);
void zeus::message::Event::generateDisplay(etk::Stream& _os) const {
zeus::Message::generateDisplay(_os);
if (getNumberParameter() != 0) {

View File

@ -17,6 +17,8 @@
#include <zeus/message/Event.hpp>
#include <zeus/WebServer.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::Message);
zeus::Message::Message(ememory::SharedPtr<zeus::WebServer> _iface):
m_iface(_iface) {

View File

@ -8,6 +8,8 @@
#include <zeus/debug.hpp>
#include <zeus/File.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::ParamType);
bool zeus::message::checkCompatibility(const ParamType& _type, const ParamType& _params) {
if (_params == _type) {

View File

@ -12,6 +12,9 @@
#include <zeus/message/Parameter.hpp>
#include <zeus/File.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::Parameter);
zeus::message::Parameter::Parameter(ememory::SharedPtr<zeus::WebServer> _iface):
Message(_iface) {

View File

@ -7,6 +7,10 @@
#include <etk/stdTools.hpp>
#include <zeus/message/type.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::message::type);
namespace etk {
template<> etk::String toString<enum zeus::message::type>(const enum zeus::message::type& _value) {
switch (_value) {

View File

@ -13,6 +13,10 @@
#include "debug.hpp"
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::FileImpl);
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal) {
return ememory::makeShared<zeus::FileImpl>(_fileNameReal);
}
@ -28,16 +32,17 @@ ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal, etk
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _fileNameShow, _mineType, _sha512);
}
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Vector<uint8_t> _fileNameReal, etk::String _virtualName, etk::String _mineType) {
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _virtualName, _mineType);
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Vector<uint8_t> _fileData, etk::String _virtualName, etk::String _mineType) {
return ememory::makeShared<zeus::FileImpl>(etk::move(_fileData), _virtualName, _mineType);
}
zeus::FileImpl::FileImpl(const etk::Vector<uint8_t>& _value, etk::String _virtualName, etk::String _mineType) :
zeus::FileImpl::FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName, etk::String _mineType) :
m_filename(_virtualName),
m_gettedData(0),
m_mineType(_mineType),
m_sha512("") {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
m_dataRaw = true;
m_data = _value;
m_size = m_data.size();
@ -47,6 +52,7 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _sha512) :
m_node(_fileNameReal),
m_gettedData(0),
m_sha512(_sha512) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
m_size = m_node.fileSize();
etk::String extention;
if ( _fileNameReal.rfind('.') != etk::String::npos
@ -69,6 +75,7 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, e
m_gettedData(0),
m_mineType(_mineType),
m_sha512(_sha512) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
m_size = m_node.fileSize();
if ( _sha512.size() > 0
&& _sha512.size() != 128) {
@ -78,6 +85,7 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, e
}
zeus::FileImpl::~FileImpl() {
ZEUS_ERROR(" <<<<<<<<<<<<<<============== DESTROY FILE");
if (m_node.fileIsOpen() == true) {
m_node.fileClose();
}

View File

@ -22,7 +22,7 @@ namespace zeus {
public:
FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512="");
FileImpl(etk::String _fileNameReal, etk::String _sha512="");
FileImpl(const etk::Vector<uint8_t>& _value, etk::String _virtualName, etk::String _mineType);
FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName, etk::String _mineType);
~FileImpl();
uint64_t getSize() override;
etk::String getName() override;

View File

@ -11,6 +11,10 @@
#include <etk/os/FSNode.hpp>
#include "debug.hpp"
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(zeus::MediaImpl);
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::String _fileNameReal) {
return ememory::makeShared<zeus::MediaImpl>(0, _fileNameReal);
}
@ -31,6 +35,7 @@ ejson::Object zeus::MediaImpl::getJson() {
zeus::MediaImpl::MediaImpl(const etk::String& _basePath, ejson::Object _property) :
m_basePath(_basePath) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE MEDIA");
m_id = _property["id"].toNumber().getU64();
ZEUS_INFO("get ID : " << m_id);
m_fileName = _property["file-name"].toString().get();
@ -53,6 +58,7 @@ zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const
m_id(_id),
m_basePath(_basePath),
m_fileName(_fileNameReal) {
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE MEDIA");
etk::String extention;
if ( m_fileName.rfind('.') != etk::String::npos
&& m_fileName.rfind('.') != 0) {
@ -66,6 +72,7 @@ zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const
}
zeus::MediaImpl::~MediaImpl() {
ZEUS_ERROR(" <<<<<<<<<<<<<<============== DESTROY MEDIA");
}