From b1b52cef1607aad6c8d1b0a7ec2b1a38388a8569 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 28 Aug 2017 00:06:18 +0200 Subject: [PATCH] [DEV] continue removing stl --- lutinMacro_zeus.py | 44 +- test/client/appl/main-test-client.cpp | 14 +- .../appl/main-service-test-service1.cpp | 14 +- .../cli-video/appl/main-tool-client-video.cpp | 228 +++++------ tools/cli/appl/main-tool-client.cpp | 214 +++++----- tools/gateway/appl/DirectInterface.cpp | 16 +- tools/gateway/appl/DirectInterface.hpp | 4 +- tools/gateway/appl/GateWay.cpp | 26 +- tools/gateway/appl/GateWay.hpp | 18 +- tools/gateway/appl/IOInterface.cpp | 36 +- tools/gateway/appl/IOInterface.hpp | 6 +- tools/gateway/appl/RouterInterface.cpp | 32 +- tools/gateway/appl/RouterInterface.hpp | 8 +- tools/gateway/appl/main-gateway.cpp | 58 +-- tools/launcher/appl/main-launcher.cpp | 30 +- tools/player-video/appl/ClientProperty.cpp | 18 +- tools/player-video/appl/ClientProperty.hpp | 16 +- tools/player-video/appl/Main.cpp | 4 +- tools/player-video/appl/MediaDecoder.cpp | 87 +++- tools/player-video/appl/MediaDecoder.hpp | 28 +- tools/player-video/appl/Windows.cpp | 24 +- tools/player-video/appl/Windows.hpp | 8 +- tools/player-video/appl/widget/Connection.cpp | 22 +- tools/player-video/appl/widget/Connection.hpp | 10 +- tools/player-video/appl/widget/ListViewer.cpp | 88 ++-- tools/player-video/appl/widget/ListViewer.hpp | 40 +- tools/player-video/appl/widget/Player.cpp | 76 ++-- tools/player-video/appl/widget/Player.hpp | 2 +- .../player-video/appl/widget/ProgressBar.cpp | 8 +- .../player-video/appl/widget/ProgressBar.hpp | 6 +- tools/player-video/appl/widget/UpBar.cpp | 26 +- tools/player-video/appl/widget/UpBar.hpp | 2 +- .../player-video/appl/widget/VideoPlayer.cpp | 7 +- .../player-video/appl/widget/VideoPlayer.hpp | 8 +- tools/player-video/appl/widget/VolumeBar.cpp | 6 +- tools/player-video/appl/widget/VolumeBar.hpp | 6 +- tools/player-video/lutin_zeus-player-video.py | 7 +- tools/router/appl/ClientInterface.cpp | 16 +- tools/router/appl/ClientInterface.hpp | 4 +- tools/router/appl/GateWayInterface.cpp | 22 +- tools/router/appl/GateWayInterface.hpp | 10 +- tools/router/appl/Router.cpp | 54 +-- tools/router/appl/Router.hpp | 14 +- tools/router/appl/main-router.cpp | 18 +- tools/server-remote/appl/ClientProperty.cpp | 18 +- tools/server-remote/appl/ClientProperty.hpp | 16 +- tools/server-remote/appl/Main.cpp | 2 +- tools/server-remote/appl/Windows.cpp | 14 +- tools/server-remote/appl/Windows.hpp | 4 +- .../server-remote/appl/widget/Connection.cpp | 22 +- .../server-remote/appl/widget/Connection.hpp | 10 +- .../server-remote/lutin_zeus-server-remote.py | 2 +- .../appl/main-service-picture.cpp | 88 ++-- tools/service-user/appl/main-service-user.cpp | 34 +- .../service-video/appl/main-service-video.cpp | 118 +++--- zeus/AbstractFunction.cpp | 34 +- zeus/AbstractFunction.hpp | 36 +- zeus/AbstractFunctionTypeClass.hpp | 40 +- zeus/AbstractFunctionTypeDirect.hpp | 20 +- zeus/Client.cpp | 43 +- zeus/Client.hpp | 30 +- zeus/Future.cpp | 76 ++-- zeus/Future.hpp | 10 +- zeus/FutureBase.cpp | 4 +- zeus/FutureBase.hpp | 4 +- zeus/FutureGroup.cpp | 2 +- zeus/FutureGroup.hpp | 4 +- zeus/Object.cpp | 2 +- zeus/Object.hpp | 18 +- zeus/ObjectIntrospect.cpp | 14 +- zeus/ObjectIntrospect.hpp | 14 +- zeus/ObjectRemote.cpp | 4 +- zeus/ObjectRemote.hpp | 10 +- zeus/Promise.cpp | 12 +- zeus/Promise.hpp | 4 +- zeus/Raw.hpp | 2 +- zeus/RemoteProcessCall.cpp | 52 +-- zeus/RemoteProcessCall.hpp | 54 +-- zeus/RemoteProperty.hpp | 4 +- zeus/RemoteSignal.hpp | 2 +- zeus/WebObj.cpp | 2 +- zeus/WebObj.hpp | 2 +- zeus/WebServer.cpp | 44 +- zeus/WebServer.hpp | 44 +- zeus/message/Answer.cpp | 8 +- zeus/message/Answer.hpp | 12 +- zeus/message/Call.cpp | 8 +- zeus/message/Call.hpp | 8 +- zeus/message/Data.cpp | 8 +- zeus/message/Data.hpp | 6 +- zeus/message/Event.cpp | 2 +- zeus/message/Event.hpp | 2 +- zeus/message/Message.cpp | 16 +- zeus/message/Message.hpp | 18 +- zeus/message/ParamType.cpp | 38 +- zeus/message/ParamType.hpp | 14 +- zeus/message/Parameter.cpp | 48 +-- zeus/message/Parameter.hpp | 4 +- zeus/message/Parameter_addParameter.cpp | 188 ++++----- zeus/message/Parameter_getParameter.cpp | 384 +++++++++--------- zeus/message/type.cpp | 6 +- zeus/message/type.hpp | 2 +- zeus/mineType.cpp | 6 +- zeus/mineType.hpp | 4 +- zeus/zeus-File.impl.cpp | 46 +-- zeus/zeus-File.impl.hpp | 16 +- zeus/zeus-Media.impl.cpp | 96 ++--- zeus/zeus-Media.impl.hpp | 36 +- zeus/zeus.cpp | 2 +- 109 files changed, 1683 insertions(+), 1595 deletions(-) diff --git a/lutinMacro_zeus.py b/lutinMacro_zeus.py index c690cc7..35f9790 100644 --- a/lutinMacro_zeus.py +++ b/lutinMacro_zeus.py @@ -7,7 +7,7 @@ import copy list_of_known_type = [ ["void", "void"], ["bool", "bool"], - ["string", "std::string"], + ["string", "etk::String"], ["int8", "int8_t"], ["int16", "int16_t"], ["int32", "int32_t"], @@ -18,25 +18,25 @@ list_of_known_type = [ ["uint64", "uint64_t"], ["float32", "float"], ["float64", "double"], - ["vector:bool", "std::vector"], - ["vector:string", "std::vector"], - ["vector:int8", "std::vector"], - ["vector:int16", "std::vector"], - ["vector:int32", "std::vector"], - ["vector:int64", "std::vector"], - ["vector:uint8", "std::vector"], - ["vector:uint16", "std::vector"], - ["vector:uint32", "std::vector"], - ["vector:uint64", "std::vector"], - ["vector:float32", "std::vector"], - ["vector:float64", "std::vector"], + ["vector:bool", "etk::Vector"], + ["vector:string", "etk::Vector"], + ["vector:int8", "etk::Vector"], + ["vector:int16", "etk::Vector"], + ["vector:int32", "etk::Vector"], + ["vector:int64", "etk::Vector"], + ["vector:uint8", "etk::Vector"], + ["vector:uint16", "etk::Vector"], + ["vector:uint32", "etk::Vector"], + ["vector:uint64", "etk::Vector"], + ["vector:float32", "etk::Vector"], + ["vector:float64", "etk::Vector"], ["duration", "echrono::Duration"], ["time", "echrono::Time"], ["file", "zeus::File"], ["stream", "zeus::Stream"], ["json", "ejson::Object"], ["raw", "zeus::Raw"], - ["ActionNotif", "zeus::ActionNotification"], + ["ActionNotif", "zeus::ActionNotification"], ] @@ -439,8 +439,8 @@ class ServiceDefinition: out += "#include \n" out += "#include \n" out += "#include \n" - out += "#include \n" - out += "#include \n" + out += "#include \n" + out += "#include \n" out += "#include \n" out += "#include \n" for elem in self.imports: @@ -540,7 +540,7 @@ class ServiceDefinition: out += " \n" out += " template<>\n" out += " void Parameter::addParameter>(uint16_t _paramId, const ememory::SharedPtr<" + self.prop["name_class"] + ">& _value) {\n" - out += " std::vector data;\n" + out += " etk::Vector data;\n" """ out += " addType(data, createType<" + class_name + ">());\n" """ @@ -562,7 +562,7 @@ class ServiceDefinition: out += " }\n" # return Object ID and interface adress out += " memcpy(&data[currentOffset], &fullId, 4);\n" - out += " m_parameter.push_back(std::make_pair(startOffset,data));\n" + out += " m_parameter.pushBack(etk::makePair(startOffset,data));\n" out += " }\n" out += " \n" out += " template<>\n" @@ -603,8 +603,8 @@ class ServiceDefinition: out += "#include \n" out += "#include \n" out += "#include <" + self.prop["file_name_class_header"] + ">\n" - out += "#include \n" - out += "#include \n" + out += "#include \n" + out += "#include \n" out += "\n" space = "" for elem in self.name[:-1]: @@ -713,8 +713,8 @@ class ServiceDefinition: out += "#include \n" out += "#include \n" out += "#include \n" - out += "#include \n" - out += "#include \n" + out += "#include \n" + out += "#include \n" out += "#include <" + self.prop["file_name_class_header"] + ">\n" for elem in self.imports: prop = zeus_object_to_dictionary(elem) diff --git a/test/client/appl/main-test-client.cpp b/test/client/appl/main-test-client.cpp index fbaf44c..1574846 100644 --- a/test/client/appl/main-test-client.cpp +++ b/test/client/appl/main-test-client.cpp @@ -26,15 +26,15 @@ int main(int _argc, const char *_argv[]) { elog::init(_argc, _argv); zeus::init(_argc, _argv); zeus::Client client1; - std::string fromUser = "test1"; - std::string toUser = "test1"; - std::string pass = "coucou"; + etk::String fromUser = "test1"; + etk::String toUser = "test1"; + etk::String pass = "coucou"; for (int32_t iii=0; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if (etk::start_with(data, "--ip=") == true) { - client1.propertyIp.set(std::string(&data[5])); + client1.propertyIp.set(etk::String(&data[5])); } else if (etk::start_with(data, "--port=") == true) { - client1.propertyPort.set(etk::string_to_uint16_t(std::string(&data[7]))); + client1.propertyPort.set(etk::string_to_uint16_t(etk::String(&data[7]))); } else if (etk::start_with(data, "--from=") == true) { fromUser = &data[7]; } else if (etk::start_with(data, "--to=") == true) { @@ -91,7 +91,7 @@ int main(int _argc, const char *_argv[]) { APPL_INFO(" -- Get service count"); APPL_INFO(" ----------------------------------"); zeus::Future retNbService = client1.getServiceCount(); - zeus::Future> retServiceList = client1.getServiceList(); + zeus::Future> retServiceList = client1.getServiceList(); retNbService.wait(); APPL_INFO("Nb services = " << retNbService.get()); retServiceList.wait(); diff --git a/test/service1/appl/main-service-test-service1.cpp b/test/service1/appl/main-service-test-service1.cpp index ab58201..81acdac 100644 --- a/test/service1/appl/main-service-test-service1.cpp +++ b/test/service1/appl/main-service-test-service1.cpp @@ -25,10 +25,10 @@ #include static std::mutex g_mutex; -static std::string g_basePath; -static std::string g_baseDBName = std::string(SERVICE_NAME) + "-database.json"; +static etk::String g_basePath; +static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; -static std::vector> m_listFile; +static etk::Vector> m_listFile; static uint64_t m_lastMaxId = 0; static bool g_needToStore = false; @@ -40,7 +40,7 @@ static uint64_t createUniqueID() { namespace appl { class TestService1 : public zeus::service::test::Service1 { private: - std::string m_userName; + etk::String m_userName; public: TestService1(uint16_t _clientId) { APPL_VERBOSE("New TestService1 ... for user: " << _clientId); @@ -53,14 +53,14 @@ namespace appl { return _value*2; } - std::vector getVU32(std::vector _value) override { + etk::Vector getVU32(etk::Vector _value) override { for (auto &it: _value) { it *= 2; } return _value; } - std::string getString(std::string _value) override { + etk::String getString(etk::String _value) override { return "get:'" + _value + "'"; } void getVoid() override { @@ -94,7 +94,7 @@ static void load_db() { g_needToStore = false; } -ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], std::string _basePath) { +ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) { g_basePath = _basePath; std::unique_lock lock(g_mutex); APPL_INFO("Load USER: " << g_basePath); diff --git a/tools/cli-video/appl/main-tool-client-video.cpp b/tools/cli-video/appl/main-tool-client-video.cpp index cd568af..409fbcf 100644 --- a/tools/cli-video/appl/main-tool-client-video.cpp +++ b/tools/cli-video/appl/main-tool-client-video.cpp @@ -23,11 +23,11 @@ #include #include -static std::string extractAndRemove(const std::string& _inputValue, const char _startMark, const char _stopMark, std::vector& _values) { +static etk::String extractAndRemove(const etk::String& _inputValue, const char _startMark, const char _stopMark, etk::Vector& _values) { _values.clear(); - std::string out; + etk::String out; bool inside=false; - std::string insideData; + etk::String insideData; for (auto &it : _inputValue) { if ( inside == false && it == _startMark) { @@ -35,7 +35,7 @@ static std::string extractAndRemove(const std::string& _inputValue, const char _ } else if ( inside == true && it == _stopMark) { inside = false; - _values.push_back(insideData); + _values.pushBack(insideData); insideData.clear(); } else if (inside == true) { insideData += it; @@ -45,20 +45,20 @@ static std::string extractAndRemove(const std::string& _inputValue, const char _ } return out; } -bool progressCall(const std::string& _value) { +bool progressCall(const etk::String& _value) { return false; } -void progressCallback(const std::string& _value) { +void progressCallback(const etk::String& _value) { APPL_PRINT("plop " << _value); } -bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map _basicKey = std::map()) { - std::string extention; - if ( _path.rfind('.') != std::string::npos +bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map _basicKey = etk::Map()) { + etk::String extention; + if ( _path.rfind('.') != etk::String::npos && _path.rfind('.') != 0) { - extention = etk::tolower(std::string(_path.begin()+_path.rfind('.')+1, _path.end())); + extention = etk::tolower(etk::String(_path.begin()+_path.rfind('.')+1, _path.end())); } - std::string fileName = etk::split(_path, '/').back(); + etk::String fileName = etk::split(_path, '/').back(); // internal extention ... if (extention == "sha512") { return true; @@ -88,7 +88,7 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< APPL_ERROR(" ==> can not asociate at a specific seri"); return false; } - std::string groupName = _basicKey["series-name"]; + etk::String groupName = _basicKey["series-name"]; if (_basicKey["saison"] != "") { groupName += ":" + _basicKey["saison"]; } @@ -97,11 +97,11 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< sending.waitFor(echrono::seconds(20000)); return true; } - std::string storedSha512; + etk::String storedSha512; if (etk::FSNodeExist(_path + ".sha512") == true) { uint64_t time_sha512 = etk::FSNodeGetTimeModified(_path + ".sha512"); uint64_t time_elem = etk::FSNodeGetTimeModified(_path); - std::string storedSha512_file = etk::FSNodeReadAllData(_path + ".sha512"); + etk::String storedSha512_file = etk::FSNodeReadAllData(_path + ".sha512"); if (time_elem > time_sha512) { // check the current sha512 storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path)); @@ -151,7 +151,7 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< // TODO: if the media have meta data ==> this mean that the media already added before ... APPL_INFO("Find fileName : '" << fileName << "'"); // Remove Date (XXXX) or other title - std::vector dates; + etk::Vector dates; fileName = extractAndRemove(fileName, '(', ')', dates); bool haveDate = false; bool haveTitle = false; @@ -176,7 +176,7 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< continue; } haveDate = true; - _basicKey.insert(std::pair("date", it)); + _basicKey.insert(etk::Pair("date", it)); } else { if (haveTitle == true) { APPL_INFO(" '" << fileName << "'"); @@ -185,39 +185,39 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< } haveTitle = true; // Other title - _basicKey.insert(std::pair("title2", it)); + _basicKey.insert(etk::Pair("title2", it)); } } // remove unneeded date if (haveDate == false) { - _basicKey.insert(std::pair("date", "")); + _basicKey.insert(etk::Pair("date", "")); } // remove unneeded title 2 if (haveTitle == false) { - _basicKey.insert(std::pair("title2", "")); + _basicKey.insert(etk::Pair("title2", "")); } // Remove the actors [XXX YYY][EEE TTT]... - std::vector acthors; + etk::Vector acthors; fileName = extractAndRemove(fileName, '[', ']', acthors); if (acthors.size() > 0) { APPL_INFO(" '" << fileName << "'"); - std::string actorList; + etk::String actorList; for (auto &itActor : acthors) { if (actorList != "") { actorList += ";"; } actorList += itActor; } - _basicKey.insert(std::pair("acthors", actorList)); + _basicKey.insert(etk::Pair("acthors", actorList)); } // remove extention - fileName = std::string(fileName.begin(), fileName.begin() + fileName.size() - (extention.size()+1)); + fileName = etk::String(fileName.begin(), fileName.begin() + fileName.size() - (extention.size()+1)); - std::vector listElementBase = etk::split(fileName, '-'); + etk::Vector listElementBase = etk::split(fileName, '-'); - std::vector listElement; - std::string tmpStartString; + etk::Vector listElement; + etk::String tmpStartString; for (size_t iii=0; iii("title", etk::to_string(listElement[0]))); + _basicKey.insert(etk::Pair("title", etk::toString(listElement[0]))); } else { /* for (auto &itt : listElement) { @@ -252,47 +252,47 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< // internal formalisme ... int32_t saison = -1; int32_t episode = -1; - std::string seriesName = listElement[0]; + etk::String seriesName = listElement[0]; - _basicKey.insert(std::pair("series-name", etk::to_string(seriesName))); - std::string fullEpisodeName = listElement[3]; + _basicKey.insert(etk::Pair("series-name", etk::toString(seriesName))); + etk::String fullEpisodeName = listElement[3]; for (int32_t yyy=4; yyy("title", etk::to_string(fullEpisodeName))); - if (std::string(&listElement[1][1]) == "XX") { + _basicKey.insert(etk::Pair("title", etk::toString(fullEpisodeName))); + if (etk::String(&listElement[1][1]) == "XX") { // saison unknow ... ==> nothing to do ... } else { saison = etk::string_to_int32_t(&listElement[1][1]); } - if (std::string(&listElement[2][1]) == "XX") { + if (etk::String(&listElement[2][1]) == "XX") { // episode unknow ... ==> nothing to do ... } else { episode = etk::string_to_int32_t(&listElement[2][1]); - _basicKey.insert(std::pair("episode", etk::to_string(episode))); + _basicKey.insert(etk::Pair("episode", etk::toString(episode))); } APPL_INFO("Find a internal mode series: :"); APPL_INFO(" origin : '" << fileName << "'"); - std::string saisonPrint = "XX"; - std::string episodePrint = "XX"; + etk::String saisonPrint = "XX"; + etk::String episodePrint = "XX"; if (saison < 0) { // nothing to do } else if(saison < 10) { - saisonPrint = "0" + etk::to_string(saison); - _basicKey.insert(std::pair("saison", etk::to_string(saison))); + saisonPrint = "0" + etk::toString(saison); + _basicKey.insert(etk::Pair("saison", etk::toString(saison))); } else { - saisonPrint = etk::to_string(saison); - _basicKey.insert(std::pair("saison", etk::to_string(saison))); + saisonPrint = etk::toString(saison); + _basicKey.insert(etk::Pair("saison", etk::toString(saison))); } if (episode < 0) { // nothing to do } else if(episode < 10) { - episodePrint = "0" + etk::to_string(episode); - _basicKey.insert(std::pair("episode", etk::to_string(episode))); + episodePrint = "0" + etk::toString(episode); + _basicKey.insert(etk::Pair("episode", etk::toString(episode))); } else { - episodePrint = etk::to_string(episode); - _basicKey.insert(std::pair("episode", etk::to_string(episode))); + episodePrint = etk::toString(episode); + _basicKey.insert(etk::Pair("episode", etk::toString(episode))); } APPL_PRINT(" ==> '" << seriesName << "-s" << saisonPrint << "-e" << episodePrint << "-" << fullEpisodeName << "'"); } @@ -309,107 +309,107 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< return true; } -void installVideoPath(zeus::service::ProxyVideo& _srv, std::string _path, std::map _basicKey = std::map()) { +void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map _basicKey = etk::Map()) { etk::FSNode node(_path); APPL_INFO("Parse : '" << _path << "'"); - std::vector listSubPath = node.folderGetSub(true, false, "*"); + etk::Vector listSubPath = node.folderGetSub(true, false, "*"); for (auto &itPath : listSubPath) { - std::map basicKeyTmp = _basicKey; + etk::Map basicKeyTmp = _basicKey; APPL_INFO("Add Sub path: '" << itPath << "'"); - std::string lastPathName = etk::split(itPath, '/').back(); + etk::String lastPathName = etk::split(itPath, '/').back(); if (basicKeyTmp.size() == 0) { APPL_INFO("find A '" << lastPathName << "' " << basicKeyTmp.size()); if (lastPathName == "film") { - basicKeyTmp.insert(std::pair("type", "film")); - basicKeyTmp.insert(std::pair("production-methode", "picture")); + basicKeyTmp.insert(etk::Pair("type", "film")); + basicKeyTmp.insert(etk::Pair("production-methode", "picture")); } else if (lastPathName == "film-annimation") { - basicKeyTmp.insert(std::pair("type", "film")); - basicKeyTmp.insert(std::pair("production-methode", "draw")); + basicKeyTmp.insert(etk::Pair("type", "film")); + basicKeyTmp.insert(etk::Pair("production-methode", "draw")); } else if (lastPathName == "film-short") { // short films - basicKeyTmp.insert(std::pair("type", "film")); - basicKeyTmp.insert(std::pair("production-methode", "short")); + basicKeyTmp.insert(etk::Pair("type", "film")); + basicKeyTmp.insert(etk::Pair("production-methode", "short")); } else if (lastPathName == "tv-show") { - basicKeyTmp.insert(std::pair("type", "tv-show")); - basicKeyTmp.insert(std::pair("production-methode", "picture")); + basicKeyTmp.insert(etk::Pair("type", "tv-show")); + basicKeyTmp.insert(etk::Pair("production-methode", "picture")); } else if (lastPathName == "tv-show-annimation") { - basicKeyTmp.insert(std::pair("type", "tv-show")); - basicKeyTmp.insert(std::pair("production-methode", "draw")); + basicKeyTmp.insert(etk::Pair("type", "tv-show")); + basicKeyTmp.insert(etk::Pair("production-methode", "draw")); } else if (lastPathName == "theater") { - basicKeyTmp.insert(std::pair("type", "theater")); + basicKeyTmp.insert(etk::Pair("type", "theater")); } else if (lastPathName == "one-man") { - basicKeyTmp.insert(std::pair("type", "one-man")); + basicKeyTmp.insert(etk::Pair("type", "one-man")); } } else { APPL_INFO("find B '" << lastPathName << "' " << basicKeyTmp.size()); if (lastPathName == "saison_01") { - basicKeyTmp.insert(std::pair("saison", "1")); + basicKeyTmp.insert(etk::Pair("saison", "1")); } else if (lastPathName == "saison_02") { - basicKeyTmp.insert(std::pair("saison", "2")); + basicKeyTmp.insert(etk::Pair("saison", "2")); } else if (lastPathName == "saison_03") { - basicKeyTmp.insert(std::pair("saison", "3")); + basicKeyTmp.insert(etk::Pair("saison", "3")); } else if (lastPathName == "saison_04") { - basicKeyTmp.insert(std::pair("saison", "4")); + basicKeyTmp.insert(etk::Pair("saison", "4")); } else if (lastPathName == "saison_05") { - basicKeyTmp.insert(std::pair("saison", "5")); + basicKeyTmp.insert(etk::Pair("saison", "5")); } else if (lastPathName == "saison_06") { - basicKeyTmp.insert(std::pair("saison", "6")); + basicKeyTmp.insert(etk::Pair("saison", "6")); } else if (lastPathName == "saison_07") { - basicKeyTmp.insert(std::pair("saison", "7")); + basicKeyTmp.insert(etk::Pair("saison", "7")); } else if (lastPathName == "saison_08") { - basicKeyTmp.insert(std::pair("saison", "8")); + basicKeyTmp.insert(etk::Pair("saison", "8")); } else if (lastPathName == "saison_09") { - basicKeyTmp.insert(std::pair("saison", "9")); + basicKeyTmp.insert(etk::Pair("saison", "9")); } else if (lastPathName == "saison_10") { - basicKeyTmp.insert(std::pair("saison", "10")); + basicKeyTmp.insert(etk::Pair("saison", "10")); } else if (lastPathName == "saison_11") { - basicKeyTmp.insert(std::pair("saison", "11")); + basicKeyTmp.insert(etk::Pair("saison", "11")); } else if (lastPathName == "saison_12") { - basicKeyTmp.insert(std::pair("saison", "12")); + basicKeyTmp.insert(etk::Pair("saison", "12")); } else if (lastPathName == "saison_13") { - basicKeyTmp.insert(std::pair("saison", "13")); + basicKeyTmp.insert(etk::Pair("saison", "13")); } else if (lastPathName == "saison_14") { - basicKeyTmp.insert(std::pair("saison", "14")); + basicKeyTmp.insert(etk::Pair("saison", "14")); } else if (lastPathName == "saison_15") { - basicKeyTmp.insert(std::pair("saison", "15")); + basicKeyTmp.insert(etk::Pair("saison", "15")); } else if (lastPathName == "saison_16") { - basicKeyTmp.insert(std::pair("saison", "16")); + basicKeyTmp.insert(etk::Pair("saison", "16")); } else if (lastPathName == "saison_17") { - basicKeyTmp.insert(std::pair("saison", "17")); + basicKeyTmp.insert(etk::Pair("saison", "17")); } else if (lastPathName == "saison_18") { - basicKeyTmp.insert(std::pair("saison", "18")); + basicKeyTmp.insert(etk::Pair("saison", "18")); } else if (lastPathName == "saison_19") { - basicKeyTmp.insert(std::pair("saison", "19")); + basicKeyTmp.insert(etk::Pair("saison", "19")); } else if (lastPathName == "saison_20") { - basicKeyTmp.insert(std::pair("saison", "20")); + basicKeyTmp.insert(etk::Pair("saison", "20")); } else if (lastPathName == "saison_21") { - basicKeyTmp.insert(std::pair("saison", "21")); + basicKeyTmp.insert(etk::Pair("saison", "21")); } else if (lastPathName == "saison_22") { - basicKeyTmp.insert(std::pair("saison", "22")); + basicKeyTmp.insert(etk::Pair("saison", "22")); } else if (lastPathName == "saison_23") { - basicKeyTmp.insert(std::pair("saison", "23")); + basicKeyTmp.insert(etk::Pair("saison", "23")); } else if (lastPathName == "saison_24") { - basicKeyTmp.insert(std::pair("saison", "24")); + basicKeyTmp.insert(etk::Pair("saison", "24")); } else if (lastPathName == "saison_25") { - basicKeyTmp.insert(std::pair("saison", "25")); + basicKeyTmp.insert(etk::Pair("saison", "25")); } else if (lastPathName == "saison_26") { - basicKeyTmp.insert(std::pair("saison", "26")); + basicKeyTmp.insert(etk::Pair("saison", "26")); } else if (lastPathName == "saison_27") { - basicKeyTmp.insert(std::pair("saison", "27")); + basicKeyTmp.insert(etk::Pair("saison", "27")); } else if (lastPathName == "saison_28") { - basicKeyTmp.insert(std::pair("saison", "28")); + basicKeyTmp.insert(etk::Pair("saison", "28")); } else if (lastPathName == "saison_29") { - basicKeyTmp.insert(std::pair("saison", "29")); + basicKeyTmp.insert(etk::Pair("saison", "29")); } else { - basicKeyTmp.insert(std::pair("series-name", lastPathName)); + basicKeyTmp.insert(etk::Pair("series-name", lastPathName)); } } installVideoPath(_srv, itPath, basicKeyTmp); } // Add files : - std::vector listSubFile = node.folderGetSub(false, true, "*"); + etk::Vector listSubFile = node.folderGetSub(false, true, "*"); for (auto &itFile : listSubFile) { - std::map basicKeyTmp = _basicKey; + etk::Map basicKeyTmp = _basicKey; pushVideoFile(_srv, itFile, _basicKey); } @@ -420,17 +420,17 @@ int main(int _argc, const char *_argv[]) { elog::init(_argc, _argv); zeus::init(_argc, _argv); zeus::Client client1; - std::string login = "test1"; - std::string address = ""; + etk::String login = "test1"; + etk::String address = ""; uint32_t port = 0; - std::string pass = "coucou"; - std::string requestAction = ""; - std::vector args; + etk::String pass = "coucou"; + etk::String requestAction = ""; + etk::Vector args; for (int32_t iii=1; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if (etk::start_with(data, "--login=") == true) { // separate loggin and IP adress ... - std::vector listElem = etk::split(&data[8], '~'); + etk::Vector listElem = etk::split(&data[8], '~'); if (listElem.size() == 0) { APPL_ERROR("Not enouth element in the login ... need use a XXX~SERVER.org:zzz"); return -1; @@ -439,7 +439,7 @@ int main(int _argc, const char *_argv[]) { if (listElem.size() == 1) { // connnect on local host ... nothing to do } else { - std::vector listElem2 = etk::split(listElem[1], ':'); + etk::Vector listElem2 = etk::split(listElem[1], ':'); if (listElem2.size() >= 1) { address = listElem2[0]; } @@ -467,7 +467,7 @@ int main(int _argc, const char *_argv[]) { if (requestAction == "") { requestAction = data; } else { - args.push_back(data); + args.pushBack(data); } } } @@ -490,7 +490,7 @@ int main(int _argc, const char *_argv[]) { client1.disconnect(); return -1; } - std::string serviceName = "video"; + etk::String serviceName = "video"; APPL_INFO(" ----------------------------------"); APPL_INFO(" -- connect service '" << serviceName << "'"); APPL_INFO(" ----------------------------------"); @@ -519,9 +519,9 @@ int main(int _argc, const char *_argv[]) { uint32_t count = remoteServiceVideo.count().wait().get(); APPL_DEBUG("have " << count << " medias"); for (uint32_t iii=0; iii " << tmpMax); - std::vector list = remoteServiceVideo.getIds(iii,tmpMax).wait().get(); + etk::Vector list = remoteServiceVideo.getIds(iii,tmpMax).wait().get(); zeus::FutureGroup groupWait; for (auto& it : list) { APPL_PRINT("remove ELEMENT : " << it); @@ -539,9 +539,9 @@ int main(int _argc, const char *_argv[]) { uint32_t count = remoteServiceVideo.count().wait().get(); APPL_DEBUG("have " << count << " medias"); for (uint32_t iii=0; iii " << tmpMax); - std::vector list = remoteServiceVideo.getIds(iii, tmpMax).wait().get(); + etk::Vector list = remoteServiceVideo.getIds(iii, tmpMax).wait().get(); for (auto& it : list) { // Get the media zeus::ProxyMedia media = remoteServiceVideo.get(it).waitFor(echrono::seconds(2000)).get(); @@ -549,11 +549,11 @@ int main(int _argc, const char *_argv[]) { APPL_ERROR("get media error"); return -1; } - std::string name = media.getMetadata("title").wait().get(); - std::string serie = media.getMetadata("series-name").wait().get(); - std::string episode = media.getMetadata("episode").wait().get(); - std::string saison = media.getMetadata("saison").wait().get(); - std::string outputDesc = ""; + etk::String name = media.getMetadata("title").wait().get(); + etk::String serie = media.getMetadata("series-name").wait().get(); + etk::String episode = media.getMetadata("episode").wait().get(); + etk::String saison = media.getMetadata("saison").wait().get(); + etk::String outputDesc = ""; if (serie != "") { outputDesc += serie + "-"; } diff --git a/tools/cli/appl/main-tool-client.cpp b/tools/cli/appl/main-tool-client.cpp index bb70160..4848c7e 100644 --- a/tools/cli/appl/main-tool-client.cpp +++ b/tools/cli/appl/main-tool-client.cpp @@ -22,11 +22,11 @@ #include #include -static std::string extractAndRemove(const std::string& _inputValue, const char _startMark, const char _stopMark, std::vector& _values) { +static etk::String extractAndRemove(const etk::String& _inputValue, const char _startMark, const char _stopMark, etk::Vector& _values) { _values.clear(); - std::string out; + etk::String out; bool inside=false; - std::string insideData; + etk::String insideData; for (auto &it : _inputValue) { if ( inside == false && it == _startMark) { @@ -34,7 +34,7 @@ static std::string extractAndRemove(const std::string& _inputValue, const char _ } else if ( inside == true && it == _stopMark) { inside = false; - _values.push_back(insideData); + _values.pushBack(insideData); insideData.clear(); } else if (inside == true) { insideData += it; @@ -44,19 +44,19 @@ static std::string extractAndRemove(const std::string& _inputValue, const char _ } return out; } -bool progressCall(const std::string& _value) { +bool progressCall(const etk::String& _value) { return false; } -void progressCallback(const std::string& _value) { +void progressCallback(const etk::String& _value) { APPL_PRINT("plop " << _value); } #if 0 -bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map _basicKey = std::map()) { - std::string extention; - if ( _path.rfind('.') != std::string::npos +bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map _basicKey = etk::Map()) { + etk::String extention; + if ( _path.rfind('.') != etk::String::npos && _path.rfind('.') != 0) { - extention = etk::tolower(std::string(_path.begin()+_path.rfind('.')+1, _path.end())); + extention = etk::tolower(etk::String(_path.begin()+_path.rfind('.')+1, _path.end())); } // internal extention .... if (extention == "sha512") { @@ -71,11 +71,11 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< APPL_ERROR("Sot send file : " << _path << " Not manage extention..."); return false; } - std::string storedSha512; + etk::String storedSha512; if (etk::FSNodeExist(_path + ".sha512") == true) { uint64_t time_sha512 = etk::FSNodeGetTimeModified(_path + ".sha512"); uint64_t time_elem = etk::FSNodeGetTimeModified(_path); - std::string storedSha512_file = etk::FSNodeReadAllData(_path + ".sha512"); + etk::String storedSha512_file = etk::FSNodeReadAllData(_path + ".sha512"); if (time_elem > time_sha512) { // check the current sha512 storedSha512 = algue::stringConvert(algue::sha512::encodeFromFile(_path)); @@ -125,10 +125,10 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< // TODO: if the media have meta data ==> this mean that the media already added before ... // Parse file name: - std::string fileName = etk::split(_path, '/').back(); + etk::String fileName = etk::split(_path, '/').back(); APPL_INFO("Find fileName : '" << fileName << "'"); // Remove Date (XXXX) or other title - std::vector dates; + etk::Vector dates; fileName = extractAndRemove(fileName, '(', ')', dates); bool haveDate = false; bool haveTitle = false; @@ -153,7 +153,7 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< continue; } haveDate = true; - _basicKey.insert(std::pair("date", it)); + _basicKey.insert(etk::Pair("date", it)); } else { if (haveTitle == true) { APPL_INFO(" '" << fileName << "'"); @@ -162,39 +162,39 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< } haveTitle = true; // Other title - _basicKey.insert(std::pair("title2", it)); + _basicKey.insert(etk::Pair("title2", it)); } } // remove unneeded date if (haveDate == false) { - _basicKey.insert(std::pair("date", "")); + _basicKey.insert(etk::Pair("date", "")); } // remove unneeded title 2 if (haveTitle == false) { - _basicKey.insert(std::pair("title2", "")); + _basicKey.insert(etk::Pair("title2", "")); } // Remove the actors [XXX YYY][EEE TTT]... - std::vector acthors; + etk::Vector acthors; fileName = extractAndRemove(fileName, '[', ']', acthors); if (acthors.size() > 0) { APPL_INFO(" '" << fileName << "'"); - std::string actorList; + etk::String actorList; for (auto &itActor : acthors) { if (actorList != "") { actorList += ";"; } actorList += itActor; } - _basicKey.insert(std::pair("acthors", actorList)); + _basicKey.insert(etk::Pair("acthors", actorList)); } // remove extention - fileName = std::string(fileName.begin(), fileName.begin() + fileName.size() - (extention.size()+1)); + fileName = etk::String(fileName.begin(), fileName.begin() + fileName.size() - (extention.size()+1)); - std::vector listElementBase = etk::split(fileName, '-'); + etk::Vector listElementBase = etk::split(fileName, '-'); - std::vector listElement; - std::string tmpStartString; + etk::Vector listElement; + etk::String tmpStartString; for (size_t iii=0; iii("title", etk::to_string(listElement[0]))); + _basicKey.insert(etk::Pair("title", etk::toString(listElement[0]))); } else { /* for (auto &itt : listElement) { @@ -229,47 +229,47 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< // internal formalisme ... int32_t saison = -1; int32_t episode = -1; - std::string seriesName = listElement[0]; + etk::String seriesName = listElement[0]; - _basicKey.insert(std::pair("series-name", etk::to_string(seriesName))); - std::string fullEpisodeName = listElement[3]; + _basicKey.insert(etk::Pair("series-name", etk::toString(seriesName))); + etk::String fullEpisodeName = listElement[3]; for (int32_t yyy=4; yyy("title", etk::to_string(fullEpisodeName))); - if (std::string(&listElement[1][1]) == "XX") { + _basicKey.insert(etk::Pair("title", etk::toString(fullEpisodeName))); + if (etk::String(&listElement[1][1]) == "XX") { // saison unknow ... ==> nothing to do ... } else { saison = etk::string_to_int32_t(&listElement[1][1]); } - if (std::string(&listElement[2][1]) == "XX") { + if (etk::String(&listElement[2][1]) == "XX") { // episode unknow ... ==> nothing to do ... } else { episode = etk::string_to_int32_t(&listElement[2][1]); - _basicKey.insert(std::pair("episode", etk::to_string(episode))); + _basicKey.insert(etk::Pair("episode", etk::toString(episode))); } APPL_INFO("Find a internal mode series: :"); APPL_INFO(" origin : '" << fileName << "'"); - std::string saisonPrint = "XX"; - std::string episodePrint = "XX"; + etk::String saisonPrint = "XX"; + etk::String episodePrint = "XX"; if (saison < 0) { // nothing to do } else if(saison < 10) { - saisonPrint = "0" + etk::to_string(saison); - _basicKey.insert(std::pair("saison", etk::to_string(saison))); + saisonPrint = "0" + etk::toString(saison); + _basicKey.insert(etk::Pair("saison", etk::toString(saison))); } else { - saisonPrint = etk::to_string(saison); - _basicKey.insert(std::pair("saison", etk::to_string(saison))); + saisonPrint = etk::toString(saison); + _basicKey.insert(etk::Pair("saison", etk::toString(saison))); } if (episode < 0) { // nothing to do } else if(episode < 10) { - episodePrint = "0" + etk::to_string(episode); - _basicKey.insert(std::pair("episode", etk::to_string(episode))); + episodePrint = "0" + etk::toString(episode); + _basicKey.insert(etk::Pair("episode", etk::toString(episode))); } else { - episodePrint = etk::to_string(episode); - _basicKey.insert(std::pair("episode", etk::to_string(episode))); + episodePrint = etk::toString(episode); + _basicKey.insert(etk::Pair("episode", etk::toString(episode))); } APPL_PRINT(" ==> '" << seriesName << "-s" << saisonPrint << "-e" << episodePrint << "-" << fullEpisodeName << "'"); } @@ -286,107 +286,107 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< return true; } -void installVideoPath(zeus::service::ProxyVideo& _srv, std::string _path, std::map _basicKey = std::map()) { +void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map _basicKey = etk::Map()) { etk::FSNode node(_path); APPL_INFO("Parse : '" << _path << "'"); - std::vector listSubPath = node.folderGetSub(true, false, "*"); + etk::Vector listSubPath = node.folderGetSub(true, false, "*"); for (auto &itPath : listSubPath) { - std::map basicKeyTmp = _basicKey; + etk::Map basicKeyTmp = _basicKey; APPL_INFO("Add Sub path: '" << itPath << "'"); - std::string lastPathName = etk::split(itPath, '/').back(); + etk::String lastPathName = etk::split(itPath, '/').back(); if (basicKeyTmp.size() == 0) { APPL_INFO("find A '" << lastPathName << "' " << basicKeyTmp.size()); if (lastPathName == "film") { - basicKeyTmp.insert(std::pair("type", "film")); - basicKeyTmp.insert(std::pair("production-methode", "picture")); + basicKeyTmp.insert(etk::Pair("type", "film")); + basicKeyTmp.insert(etk::Pair("production-methode", "picture")); } else if (lastPathName == "film-annimation") { - basicKeyTmp.insert(std::pair("type", "film")); - basicKeyTmp.insert(std::pair("production-methode", "draw")); + basicKeyTmp.insert(etk::Pair("type", "film")); + basicKeyTmp.insert(etk::Pair("production-methode", "draw")); } else if (lastPathName == "film-short") { // short films - basicKeyTmp.insert(std::pair("type", "film")); - basicKeyTmp.insert(std::pair("production-methode", "short")); + basicKeyTmp.insert(etk::Pair("type", "film")); + basicKeyTmp.insert(etk::Pair("production-methode", "short")); } else if (lastPathName == "tv-show") { - basicKeyTmp.insert(std::pair("type", "tv-show")); - basicKeyTmp.insert(std::pair("production-methode", "picture")); + basicKeyTmp.insert(etk::Pair("type", "tv-show")); + basicKeyTmp.insert(etk::Pair("production-methode", "picture")); } else if (lastPathName == "tv-show-annimation") { - basicKeyTmp.insert(std::pair("type", "tv-show")); - basicKeyTmp.insert(std::pair("production-methode", "draw")); + basicKeyTmp.insert(etk::Pair("type", "tv-show")); + basicKeyTmp.insert(etk::Pair("production-methode", "draw")); } else if (lastPathName == "theater") { - basicKeyTmp.insert(std::pair("type", "theater")); + basicKeyTmp.insert(etk::Pair("type", "theater")); } else if (lastPathName == "one-man") { - basicKeyTmp.insert(std::pair("type", "one-man")); + basicKeyTmp.insert(etk::Pair("type", "one-man")); } } else { APPL_INFO("find B '" << lastPathName << "' " << basicKeyTmp.size()); if (lastPathName == "saison_01") { - basicKeyTmp.insert(std::pair("saison", "1")); + basicKeyTmp.insert(etk::Pair("saison", "1")); } else if (lastPathName == "saison_02") { - basicKeyTmp.insert(std::pair("saison", "2")); + basicKeyTmp.insert(etk::Pair("saison", "2")); } else if (lastPathName == "saison_03") { - basicKeyTmp.insert(std::pair("saison", "3")); + basicKeyTmp.insert(etk::Pair("saison", "3")); } else if (lastPathName == "saison_04") { - basicKeyTmp.insert(std::pair("saison", "4")); + basicKeyTmp.insert(etk::Pair("saison", "4")); } else if (lastPathName == "saison_05") { - basicKeyTmp.insert(std::pair("saison", "5")); + basicKeyTmp.insert(etk::Pair("saison", "5")); } else if (lastPathName == "saison_06") { - basicKeyTmp.insert(std::pair("saison", "6")); + basicKeyTmp.insert(etk::Pair("saison", "6")); } else if (lastPathName == "saison_07") { - basicKeyTmp.insert(std::pair("saison", "7")); + basicKeyTmp.insert(etk::Pair("saison", "7")); } else if (lastPathName == "saison_08") { - basicKeyTmp.insert(std::pair("saison", "8")); + basicKeyTmp.insert(etk::Pair("saison", "8")); } else if (lastPathName == "saison_09") { - basicKeyTmp.insert(std::pair("saison", "9")); + basicKeyTmp.insert(etk::Pair("saison", "9")); } else if (lastPathName == "saison_10") { - basicKeyTmp.insert(std::pair("saison", "10")); + basicKeyTmp.insert(etk::Pair("saison", "10")); } else if (lastPathName == "saison_11") { - basicKeyTmp.insert(std::pair("saison", "11")); + basicKeyTmp.insert(etk::Pair("saison", "11")); } else if (lastPathName == "saison_12") { - basicKeyTmp.insert(std::pair("saison", "12")); + basicKeyTmp.insert(etk::Pair("saison", "12")); } else if (lastPathName == "saison_13") { - basicKeyTmp.insert(std::pair("saison", "13")); + basicKeyTmp.insert(etk::Pair("saison", "13")); } else if (lastPathName == "saison_14") { - basicKeyTmp.insert(std::pair("saison", "14")); + basicKeyTmp.insert(etk::Pair("saison", "14")); } else if (lastPathName == "saison_15") { - basicKeyTmp.insert(std::pair("saison", "15")); + basicKeyTmp.insert(etk::Pair("saison", "15")); } else if (lastPathName == "saison_16") { - basicKeyTmp.insert(std::pair("saison", "16")); + basicKeyTmp.insert(etk::Pair("saison", "16")); } else if (lastPathName == "saison_17") { - basicKeyTmp.insert(std::pair("saison", "17")); + basicKeyTmp.insert(etk::Pair("saison", "17")); } else if (lastPathName == "saison_18") { - basicKeyTmp.insert(std::pair("saison", "18")); + basicKeyTmp.insert(etk::Pair("saison", "18")); } else if (lastPathName == "saison_19") { - basicKeyTmp.insert(std::pair("saison", "19")); + basicKeyTmp.insert(etk::Pair("saison", "19")); } else if (lastPathName == "saison_20") { - basicKeyTmp.insert(std::pair("saison", "20")); + basicKeyTmp.insert(etk::Pair("saison", "20")); } else if (lastPathName == "saison_21") { - basicKeyTmp.insert(std::pair("saison", "21")); + basicKeyTmp.insert(etk::Pair("saison", "21")); } else if (lastPathName == "saison_22") { - basicKeyTmp.insert(std::pair("saison", "22")); + basicKeyTmp.insert(etk::Pair("saison", "22")); } else if (lastPathName == "saison_23") { - basicKeyTmp.insert(std::pair("saison", "23")); + basicKeyTmp.insert(etk::Pair("saison", "23")); } else if (lastPathName == "saison_24") { - basicKeyTmp.insert(std::pair("saison", "24")); + basicKeyTmp.insert(etk::Pair("saison", "24")); } else if (lastPathName == "saison_25") { - basicKeyTmp.insert(std::pair("saison", "25")); + basicKeyTmp.insert(etk::Pair("saison", "25")); } else if (lastPathName == "saison_26") { - basicKeyTmp.insert(std::pair("saison", "26")); + basicKeyTmp.insert(etk::Pair("saison", "26")); } else if (lastPathName == "saison_27") { - basicKeyTmp.insert(std::pair("saison", "27")); + basicKeyTmp.insert(etk::Pair("saison", "27")); } else if (lastPathName == "saison_28") { - basicKeyTmp.insert(std::pair("saison", "28")); + basicKeyTmp.insert(etk::Pair("saison", "28")); } else if (lastPathName == "saison_29") { - basicKeyTmp.insert(std::pair("saison", "29")); + basicKeyTmp.insert(etk::Pair("saison", "29")); } else { - basicKeyTmp.insert(std::pair("series-name", lastPathName)); + basicKeyTmp.insert(etk::Pair("series-name", lastPathName)); } } installVideoPath(_srv, itPath, basicKeyTmp); } // Add files : - std::vector listSubFile = node.folderGetSub(false, true, "*"); + etk::Vector listSubFile = node.folderGetSub(false, true, "*"); for (auto &itFile : listSubFile) { - std::map basicKeyTmp = _basicKey; + etk::Map basicKeyTmp = _basicKey; pushVideoFile(_srv, itFile, _basicKey); } @@ -398,17 +398,17 @@ int main(int _argc, const char *_argv[]) { elog::init(_argc, _argv); zeus::init(_argc, _argv); zeus::Client client1; - std::string login = "test1"; - std::string address = ""; + etk::String login = "test1"; + etk::String address = ""; uint32_t port = 0; - std::string pass = "coucou"; - std::string requestAction = ""; - std::vector args; + etk::String pass = "coucou"; + etk::String requestAction = ""; + etk::Vector args; for (int32_t iii=1; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if (etk::start_with(data, "--login=") == true) { // separate loggin and IP adress ... - std::vector listElem = etk::split(&data[8], '~'); + etk::Vector listElem = etk::split(&data[8], '~'); if (listElem.size() == 0) { APPL_ERROR("Not enouth element in the login ... need use a XXX~SERVER.org:zzz"); return -1; @@ -417,7 +417,7 @@ int main(int _argc, const char *_argv[]) { if (listElem.size() == 1) { // connnect on local host ... nothing to do } else { - std::vector listElem2 = etk::split(listElem[1], ':'); + etk::Vector listElem2 = etk::split(listElem[1], ':'); if (listElem2.size() >= 1) { address = listElem2[0]; } @@ -445,7 +445,7 @@ int main(int _argc, const char *_argv[]) { if (requestAction == "") { requestAction = data; } else { - args.push_back(data); + args.pushBack(data); } } } @@ -473,7 +473,7 @@ int main(int _argc, const char *_argv[]) { APPL_PRINT("== List: "); APPL_PRINT("============================================"); zeus::Future retNbService = client1.getServiceCount(); - zeus::Future> retServiceList = client1.getServiceList(); + zeus::Future> retServiceList = client1.getServiceList(); retNbService.wait(); APPL_INFO("Nb services = " << retNbService.get()); retServiceList.wait(); @@ -490,14 +490,14 @@ int main(int _argc, const char *_argv[]) { APPL_PRINT("============================================"); // Send a full path: if (args.size() == 0) { - zeus::Future> retServiceList = client1.getServiceList(); + zeus::Future> retServiceList = client1.getServiceList(); retServiceList.wait(); for (auto &it: retServiceList.get()) { zeus::Proxy proxy = client1.getService(it); if (proxy.exist() == false) { APPL_ERROR("[" << it << "] ==> can not connect ..." ); } else { - std::string desc = proxy.sys.getDescription().wait().get(); + etk::String desc = proxy.sys.getDescription().wait().get(); APPL_PRINT("[" << it << "] " << desc); } } @@ -506,7 +506,7 @@ int main(int _argc, const char *_argv[]) { APPL_ERROR("== action: '" << requestAction << "' can have 0 or 1 arguments"); APPL_PRINT("============================================"); } else { - zeus::Future> retServiceList = client1.getServiceList(); + zeus::Future> retServiceList = client1.getServiceList(); retServiceList.wait(); bool exist = false; for (auto &it: retServiceList.get()) { diff --git a/tools/gateway/appl/DirectInterface.cpp b/tools/gateway/appl/DirectInterface.cpp index 64ba35f..636d4b4 100644 --- a/tools/gateway/appl/DirectInterface.cpp +++ b/tools/gateway/appl/DirectInterface.cpp @@ -13,10 +13,10 @@ #include -static const std::string protocolError = "PROTOCOL-ERROR"; +static const etk::String protocolError = "PROTOCOL-ERROR"; appl::DirectInterface::DirectInterface(enet::Tcp _connection) : - m_interfaceWeb(std::move(_connection), true) { + m_interfaceWeb(etk::move(_connection), true) { m_uid = 0; m_state = appl::clientState::unconnect; APPL_INFO("-----------------------"); @@ -32,23 +32,23 @@ appl::DirectInterface::~DirectInterface() { APPL_INFO("--------------------------"); } /* -void appl::clientSpecificInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { +void appl::clientSpecificInterface::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) { m_interfaceWeb->answerError(_transactionId, m_routeurUID, ZEUS_ID_SERVICE_ROOT, protocolError, _errorHelp); m_interfaceWeb->sendCtrl(m_routeurUID, ZEUS_ID_SERVICE_ROOT, "DISCONNECT"); m_state = appl::clientState::disconnect; } */ -bool appl::DirectInterface::requestURI(const std::string& _uri) { +bool appl::DirectInterface::requestURI(const etk::String& _uri) { APPL_WARNING("request Direct connection: '" << _uri << "'"); - std::string tmpURI = _uri; + etk::String tmpURI = _uri; if (tmpURI.size() == 0) { APPL_ERROR("Empty URI ... not supported ..."); return false; } if (tmpURI[0] == '/') { - tmpURI = std::string(tmpURI.begin() + 1, tmpURI.end()); + tmpURI = etk::String(tmpURI.begin() + 1, tmpURI.end()); } - std::vector listValue = etk::split(tmpURI, '?'); + etk::Vector listValue = etk::split(tmpURI, '?'); if (listValue.size() == 0) { APPL_ERROR("can not parse URI ..."); return false; @@ -110,7 +110,7 @@ void appl::DirectInterface::receive(ememory::SharedPtr _value) { answerProtocolError(transactionId, "Can not get the Client ID..."); return; } - m_interfaceWeb.setInterfaceName("cli-" + etk::to_string(m_uid)); + m_interfaceWeb.setInterfaceName("cli-" + etk::toString(m_uid)); m_interfaceWeb.answerValue(transactionId, _value->getDestination(), _value->getSource(), m_uid); } else { appl::IOInterface::receive(_value); diff --git a/tools/gateway/appl/DirectInterface.hpp b/tools/gateway/appl/DirectInterface.hpp index 7fce97a..857abfe 100644 --- a/tools/gateway/appl/DirectInterface.hpp +++ b/tools/gateway/appl/DirectInterface.hpp @@ -20,8 +20,8 @@ namespace appl { bool start(appl::GateWay* _gateway); void receive(ememory::SharedPtr _data); void send(ememory::SharedPtr _data); - bool requestURI(const std::string& _uri); - //void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + bool requestURI(const etk::String& _uri); + //void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); zeus::WebServer* getInterface() { return &m_interfaceWeb; } diff --git a/tools/gateway/appl/GateWay.cpp b/tools/gateway/appl/GateWay.cpp index 6b509ed..b3ebdea 100644 --- a/tools/gateway/appl/GateWay.cpp +++ b/tools/gateway/appl/GateWay.cpp @@ -26,7 +26,7 @@ namespace appl { } virtual ~TcpServerInput() {} - void start(const std::string& _host, uint16_t _port) { + void start(const etk::String& _host, uint16_t _port) { m_interface.setHostNane(_host); m_interface.setPort(_port); m_interface.link(); @@ -54,14 +54,14 @@ namespace appl { // get datas: while (m_threadRunning == true) { // READ section data: - enet::Tcp data = std::move(m_interface.waitNext()); + enet::Tcp data = etk::move(m_interface.waitNext()); if (data.getConnectionStatus() != enet::Tcp::status::link) { APPL_CRITICAL("New TCP connection (DEAD ....) ==> gateway is dead ..."); // TODO: Check interaface: if (m_interface. std::this_thread::sleep_for(std::chrono::milliseconds(300)); } APPL_VERBOSE("New connection"); - m_gateway->newDirectInterface(std::move(data)); + m_gateway->newDirectInterface(etk::move(data)); } } }; @@ -69,9 +69,9 @@ namespace appl { void appl::GateWay::newDirectInterface(enet::Tcp _connection) { APPL_WARNING("New TCP connection (service)"); - ememory::SharedPtr tmp = ememory::makeShared(std::move(_connection)); + ememory::SharedPtr tmp = ememory::makeShared(etk::move(_connection)); tmp->start(this); - m_listTemporaryIO.push_back(tmp); + m_listTemporaryIO.pushBack(tmp); } appl::GateWay::GateWay() : @@ -92,7 +92,7 @@ appl::GateWay::~GateWay() { } void appl::GateWay::addIO(const ememory::SharedPtr& _io) { - m_listIO.push_back(_io); + m_listIO.pushBack(_io); // REMOVE of temporary element in the temporary list: auto it = m_listTemporaryIO.begin(); while (it != m_listTemporaryIO.end()) { @@ -137,7 +137,7 @@ void appl::GateWay::stop() { m_listIO.clear(); } -bool appl::GateWay::serviceExist(const std::string& _service) { +bool appl::GateWay::serviceExist(const etk::String& _service) { for (auto &it : m_listIO) { if (it == nullptr) { continue; @@ -154,7 +154,7 @@ bool appl::GateWay::serviceExist(const std::string& _service) { return false; } -uint16_t appl::GateWay::serviceClientIdGet(const std::string& _service) { +uint16_t appl::GateWay::serviceClientIdGet(const etk::String& _service) { for (auto &it : m_listIO) { if (it == nullptr) { continue; @@ -172,8 +172,8 @@ uint16_t appl::GateWay::serviceClientIdGet(const std::string& _service) { } -std::vector appl::GateWay::getAllServiceName() { - std::vector out; +etk::Vector appl::GateWay::getAllServiceName() { + etk::Vector out; // TODO : Change this it is old and deprecated ... for (auto &it : m_listIO) { if (it == nullptr) { @@ -183,7 +183,7 @@ std::vector appl::GateWay::getAllServiceName() { continue; } for (auto &srvIt : it->getServiceList()) { - out.push_back(srvIt); + out.pushBack(srvIt); } } return out; @@ -211,14 +211,14 @@ bool appl::GateWay::send(ememory::SharedPtr _data) { void appl::GateWay::cleanIO() { APPL_VERBOSE("Check if something need to be clean ..."); - std::vector tmpIDToRemove; + etk::Vector tmpIDToRemove; // Clean all IOs... { auto it = m_listIO.begin(); while (it != m_listIO.end()) { if (*it != nullptr) { if ((*it)->isConnected() == false) { - tmpIDToRemove.push_back((*it)->getId()); + tmpIDToRemove.pushBack((*it)->getId()); it = m_listIO.erase(it); continue; } diff --git a/tools/gateway/appl/GateWay.hpp b/tools/gateway/appl/GateWay.hpp index 2647ea9..ae4178f 100644 --- a/tools/gateway/appl/GateWay.hpp +++ b/tools/gateway/appl/GateWay.hpp @@ -18,17 +18,17 @@ namespace appl { ememory::SharedPtr m_routerClient; //!< Interface with the Gateway Front End ememory::SharedPtr m_interfaceNewService; public: - eproperty::Value propertyUserName; + eproperty::Value propertyUserName; eproperty::Value propertyRouterNo; - eproperty::Value propertyRouterIp; + eproperty::Value propertyRouterIp; eproperty::Value propertyRouterPort; eproperty::Value propertyServiceExtern; - eproperty::Value propertyServiceIp; + eproperty::Value propertyServiceIp; eproperty::Value propertyServicePort; eproperty::Value propertyServiceMax; public: - std::vector> m_listTemporaryIO; //!< List of all service availlable with their specific connection interface - std::vector> m_listIO; + etk::Vector> m_listTemporaryIO; //!< List of all service availlable with their specific connection interface + etk::Vector> m_listIO; void addIO(const ememory::SharedPtr& _io); void removeIO(const ememory::SharedPtr& _io); @@ -37,8 +37,8 @@ namespace appl { virtual ~GateWay(); void start(); void stop(); - //ememory::SharedPtr get(const std::string& _serviceName); - std::vector getAllServiceName(); + //ememory::SharedPtr get(const etk::String& _serviceName); + etk::Vector getAllServiceName(); bool send(ememory::SharedPtr _data); void newDirectInterface(enet::Tcp _connection); void cleanIO(); @@ -53,8 +53,8 @@ namespace appl { void onServiceConnect(const bool& _value); public: uint16_t getId(); - bool serviceExist(const std::string& _service); - uint16_t serviceClientIdGet(const std::string& _service); + bool serviceExist(const etk::String& _service); + uint16_t serviceClientIdGet(const etk::String& _service); // Check if it take a long time without activity to kill itself ... bool checkIsAlive(const echrono::Duration& _timeout); }; diff --git a/tools/gateway/appl/IOInterface.cpp b/tools/gateway/appl/IOInterface.cpp index dd3432d..03db96a 100644 --- a/tools/gateway/appl/IOInterface.cpp +++ b/tools/gateway/appl/IOInterface.cpp @@ -13,7 +13,7 @@ #include -static const std::string protocolError = "PROTOCOL-ERROR"; +static const etk::String protocolError = "PROTOCOL-ERROR"; appl::IOInterface::IOInterface() { m_uid = 0; @@ -30,7 +30,7 @@ appl::IOInterface::~IOInterface() { // TODO : ... m_gateway->removeIO(sharedFromThis()); } -void appl::IOInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { +void appl::IOInterface::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) { zeus::WebServer* iface = getInterface(); iface->answerError(_transactionId, 0, ZEUS_ID_SERVICE_ROOT, protocolError, _errorHelp); //m_interfaceRouterClient->sendCtrl(m_routeurUID, ZEUS_ID_SERVICE_ROOT, "DISCONNECT"); @@ -46,12 +46,12 @@ bool appl::IOInterface::start(appl::GateWay* _gateway, uint16_t _id) { } else { m_state = appl::clientState::connectDirect; } - //m_interfaceRouterClient->setInterfaceName("cli-" + etk::to_string(m_uid)); + //m_interfaceRouterClient->setInterfaceName("cli-" + etk::toString(m_uid)); APPL_WARNING("[" << m_uid << "] New IO interface"); return true; } -const std::vector& appl::IOInterface::getServiceList() { +const etk::Vector& appl::IOInterface::getServiceList() { return m_listService; } @@ -75,7 +75,7 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { return; } ememory::SharedPtr callObj = ememory::staticPointerCast(_value); - std::string callFunction = callObj->getCall(); + etk::String callFunction = callObj->getCall(); if (callFunction == "removeRouterClient") { // TODO : Broadcast that an IO is remoed ... m_state = appl::clientState::unconnect; @@ -122,8 +122,8 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { } #if 0 if (callFunction == "identify") { - std::string clientName = callObj->getParameter(0); - std::string clientTocken = callObj->getParameter(1); + etk::String clientName = callObj->getParameter(0); + etk::String clientTocken = callObj->getParameter(1); if (m_userService == nullptr) { answerProtocolError(transactionId, "gateWay internal error 3"); return; @@ -144,7 +144,7 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { m_clientName = clientName; } if (callFunction == "auth") { - std::string password = callObj->getParameter(0); + etk::String password = callObj->getParameter(0); zeus::Future fut = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "checkAuth", password); fut.wait(); // TODO: Set timeout ... if (fut.hasError() == true) { @@ -167,7 +167,7 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { // -------------------------------- // -- Get groups: // -------------------------------- - zeus::Future> futGroup = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "clientGroupsGet", m_clientName); + zeus::Future> futGroup = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "clientGroupsGet", m_clientName); futGroup.wait(); // TODO: Set timeout ... if (futGroup.hasError() == true) { APPL_ERROR("Get error from the service ..."); @@ -179,8 +179,8 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { // -------------------------------- // -- Get services: // -------------------------------- - std::vector currentServices = m_gatewayInterface->getAllServiceName(); - zeus::Future> futServices = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "filterClientServices", m_clientName, currentServices); + etk::Vector currentServices = m_gatewayInterface->getAllServiceName(); + zeus::Future> futServices = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "filterClientServices", m_clientName, currentServices); futServices.wait(); // TODO: Set timeout ... if (futServices.hasError() == true) { APPL_ERROR("Get error from the service ..."); @@ -190,8 +190,8 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { } m_clientServices = futServices.get(); APPL_WARNING("Connection of: '" << m_clientName << "' to '" << m_userConnectionName << "'"); - APPL_WARNING(" groups: " << etk::to_string(m_clientgroups)); - APPL_WARNING(" services: " << etk::to_string(m_clientServices)); + APPL_WARNING(" groups: " << etk::toString(m_clientgroups)); + APPL_WARNING(" services: " << etk::toString(m_clientServices)); #endif m_gateway->addIO(sharedFromThis()); @@ -202,7 +202,7 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { } if (callFunction == "link") { // TODO : Filter services access ... - std::string serviceName = callObj->getParameter(0); + etk::String serviceName = callObj->getParameter(0); if (m_gateway->serviceExist(serviceName) == false) { zeus::WebServer* iface = getInterface(); iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false); @@ -229,7 +229,7 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { { if (callFunction == "serviceAdd") { zeus::WebServer* iface = getInterface(); - std::string serviceName = callObj->getParameter(0); + etk::String serviceName = callObj->getParameter(0); if (serviceName == "") { iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false); return; @@ -240,13 +240,13 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { return; } ZEUS_INFO("Register new service '" << serviceName << "' in " << m_uid); - m_listService.push_back(serviceName); + m_listService.pushBack(serviceName); iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), true); return; } if (callFunction == "serviceRemove") { zeus::WebServer* iface = getInterface(); - std::string serviceName = callObj->getParameter(0); + etk::String serviceName = callObj->getParameter(0); if (serviceName == "") { iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false); } @@ -278,7 +278,7 @@ void appl::IOInterface::receive(ememory::SharedPtr _value) { } if (callFunction == "link") { // TODO : Filter services access ... - std::string serviceName = callObj->getParameter(0); + etk::String serviceName = callObj->getParameter(0); if (m_gateway->serviceExist(serviceName) == false) { zeus::WebServer* iface = getInterface(); iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false); diff --git a/tools/gateway/appl/IOInterface.hpp b/tools/gateway/appl/IOInterface.hpp index 0313460..d36c518 100644 --- a/tools/gateway/appl/IOInterface.hpp +++ b/tools/gateway/appl/IOInterface.hpp @@ -22,9 +22,9 @@ namespace appl { appl::GateWay* m_gateway; protected: uint16_t m_uid; //!< Client unique ID (for routing) - std::vector m_listService; + etk::Vector m_listService; public: - const std::vector& getServiceList(); + const etk::Vector& getServiceList(); public: enum clientState m_state; // state machine ... IOInterface(); @@ -41,7 +41,7 @@ namespace appl { uint16_t getId() const { return m_uid; } - void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); virtual zeus::WebServer* getInterface() = 0; virtual bool isConnected() { return false; }; }; diff --git a/tools/gateway/appl/RouterInterface.cpp b/tools/gateway/appl/RouterInterface.cpp index 487b0e7..3eaede9 100644 --- a/tools/gateway/appl/RouterInterface.cpp +++ b/tools/gateway/appl/RouterInterface.cpp @@ -13,7 +13,7 @@ #include -static const std::string protocolError = "PROTOCOL-ERROR"; +static const etk::String protocolError = "PROTOCOL-ERROR"; appl::clientSpecificInterface::clientSpecificInterface() { m_uid = 0; @@ -99,7 +99,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v return; } ememory::SharedPtr callObj = ememory::staticPointerCast(_value); - std::string callFunction = callObj->getCall(); + etk::String callFunction = callObj->getCall(); switch (m_state) { case appl::clientState::disconnect: case appl::clientState::unconnect: @@ -127,8 +127,8 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v return; } if (callFunction == "identify") { - std::string clientName = callObj->getParameter(0); - std::string clientTocken = callObj->getParameter(1); + etk::String clientName = callObj->getParameter(0); + etk::String clientTocken = callObj->getParameter(1); if (m_userService == nullptr) { answerProtocolError(transactionId, "gateWay internal error 3"); return; @@ -149,7 +149,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v m_clientName = clientName; } if (callFunction == "auth") { - std::string password = callObj->getParameter(0); + etk::String password = callObj->getParameter(0); zeus::Future fut = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "checkAuth", password); fut.wait(); // TODO: Set timeout ... if (fut.hasError() == true) { @@ -170,7 +170,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v // -------------------------------- // -- Get groups: // -------------------------------- - zeus::Future> futGroup = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "clientGroupsGet", m_clientName); + zeus::Future> futGroup = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "clientGroupsGet", m_clientName); futGroup.wait(); // TODO: Set timeout ... if (futGroup.hasError() == true) { APPL_ERROR("Get error from the service ..."); @@ -182,8 +182,8 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v // -------------------------------- // -- Get services: // -------------------------------- - std::vector currentServices = m_gatewayInterface->getAllServiceName(); - zeus::Future> futServices = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "filterClientServices", m_clientName, currentServices); + etk::Vector currentServices = m_gatewayInterface->getAllServiceName(); + zeus::Future> futServices = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "filterClientServices", m_clientName, currentServices); futServices.wait(); // TODO: Set timeout ... if (futServices.hasError() == true) { APPL_ERROR("Get error from the service ..."); @@ -193,8 +193,8 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v } m_clientServices = futServices.get(); APPL_WARNING("Connection of: '" << m_clientName << "' to '" << m_userConnectionName << "'"); - APPL_WARNING(" groups: " << etk::to_string(m_clientgroups)); - APPL_WARNING(" services: " << etk::to_string(m_clientServices)); + APPL_WARNING(" groups: " << etk::toString(m_clientgroups)); + APPL_WARNING(" services: " << etk::toString(m_clientServices)); m_interfaceWeb->answerValue(transactionId, _value->getClientId(), _value->getServiceId(), true); @@ -219,7 +219,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v } if (callFunction == "link") { // first param: - std::string serviceName = callObj->getParameter(0); + etk::String serviceName = callObj->getParameter(0); ZEUS_ERROR("Connect to service : " << serviceName << " " << m_uid); // Check if service already link: auto it = m_listConnectedService.begin(); @@ -249,7 +249,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v m_interfaceWeb->answerError(transactionId, _value->getClientId(), _value->getServiceId(), "ERROR-CREATE-SERVICE-INSTANCE"); return; } - m_listConnectedService.push_back(srv); + m_listConnectedService.pushBack(srv); ZEUS_ERROR(" ==> get ID : " << m_uid); m_interfaceWeb->answerValue(transactionId, _value->getClientId(), _value->getServiceId(), m_listConnectedService.size()); return; @@ -318,19 +318,19 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr _v #endif -appl::RouterInterface::RouterInterface(const std::string& _ip, uint16_t _port, std::string _userName, appl::GateWay* _gateway) : +appl::RouterInterface::RouterInterface(const etk::String& _ip, uint16_t _port, etk::String _userName, appl::GateWay* _gateway) : m_state(appl::clientState::unconnect), m_gateway(_gateway), m_interfaceWeb() { APPL_INFO("----------------------------------------"); APPL_INFO("-- NEW Connection to the ROUTER --"); APPL_INFO("----------------------------------------"); - enet::Tcp connection = std::move(enet::connectTcpClient(_ip, _port)); + enet::Tcp connection = etk::move(enet::connectTcpClient(_ip, _port)); if (connection.getConnectionStatus() != enet::Tcp::status::link) { APPL_ERROR("Can not connect the GateWay-front-end"); return; } - m_interfaceWeb.setInterface(std::move(connection), false, _userName); + m_interfaceWeb.setInterface(etk::move(connection), false, _userName); m_interfaceWeb.connect(this, &appl::RouterInterface::onClientData); m_interfaceWeb.connect(true); m_interfaceWeb.setInterfaceName("cli-GW-to-router"); @@ -381,7 +381,7 @@ void appl::RouterInterface::onClientData(ememory::SharedPtr _valu return; } } - m_listClients.push_back(ememory::makeShared()); + m_listClients.pushBack(ememory::makeShared()); size_t localId = m_listClients.size()-1; bool ret = m_listClients[localId]->start(m_gateway, &m_interfaceWeb, sourceId); if (ret == false) { diff --git a/tools/gateway/appl/RouterInterface.hpp b/tools/gateway/appl/RouterInterface.hpp index 4050515..4aa8e63 100644 --- a/tools/gateway/appl/RouterInterface.hpp +++ b/tools/gateway/appl/RouterInterface.hpp @@ -15,12 +15,12 @@ namespace appl { public: zeus::WebServer* m_interfaceWeb; public: - std::string m_clientName; + etk::String m_clientName; clientSpecificInterface(); ~clientSpecificInterface(); bool start(appl::GateWay* _gateway, zeus::WebServer* _interfaceWeb, uint16_t _id); void send(ememory::SharedPtr _data); - //void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + //void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); zeus::WebServer* getInterface(); bool isConnected(); }; @@ -28,12 +28,12 @@ namespace appl { class RouterInterface { private: enum clientState m_state; // state machine .. - std::vector> m_listClients; // TODO : Maybe remove this ... + etk::Vector> m_listClients; // TODO : Maybe remove this ... private: appl::GateWay* m_gateway; zeus::WebServer m_interfaceWeb; public: - RouterInterface(const std::string& _ip, uint16_t _port, std::string _userName, appl::GateWay* _gateway); + RouterInterface(const etk::String& _ip, uint16_t _port, etk::String _userName, appl::GateWay* _gateway); virtual ~RouterInterface(); void stop(); void onClientData(ememory::SharedPtr _value); diff --git a/tools/gateway/appl/main-gateway.cpp b/tools/gateway/appl/main-gateway.cpp index 67864c8..7676943 100644 --- a/tools/gateway/appl/main-gateway.cpp +++ b/tools/gateway/appl/main-gateway.cpp @@ -27,29 +27,29 @@ #include #include -typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], std::string _basePath); +typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::String _basePath); typedef bool (*SERVICE_IO_uninit_t)(); typedef void (*SERVICE_IO_peridic_call_t)(); typedef zeus::Object* (*SERVICE_IO_instanciate_t)(uint32_t, ememory::SharedPtr&, uint32_t); class PlugginAccess { private: - std::string m_name; - std::string m_fullName; + etk::String m_name; + etk::String m_fullName; void* m_handle; SERVICE_IO_init_t m_SERVICE_IO_init; SERVICE_IO_uninit_t m_SERVICE_IO_uninit; SERVICE_IO_peridic_call_t m_SERVICE_IO_peridic_call; SERVICE_IO_instanciate_t m_SERVICE_IO_instanciate; public: - PlugginAccess(const std::string& _name, const std::string& _fullName) : + PlugginAccess(const etk::String& _name, const etk::String& _fullName) : m_name(_name), m_fullName(_fullName), m_handle(nullptr), m_SERVICE_IO_init(nullptr), m_SERVICE_IO_uninit(nullptr), m_SERVICE_IO_instanciate(nullptr) { - std::string srv = etk::FSNodeGetApplicationPath() + "/../lib/lib" + m_fullName + "-impl.so"; + etk::String srv = etk::FSNodeGetApplicationPath() + "/../lib/lib" + m_fullName + "-impl.so"; APPL_PRINT("Try to open service with name: '" << m_name << "' at position: '" << srv << "' with full name=" << m_fullName); m_handle = dlopen(srv.c_str(), RTLD_LAZY); if (!m_handle) { @@ -85,7 +85,7 @@ class PlugginAccess { ~PlugginAccess() { } - bool init(int _argc, const char *_argv[], std::string _basePath) { + bool init(int _argc, const char *_argv[], etk::String _basePath) { if (m_SERVICE_IO_init == nullptr) { return false; } @@ -132,8 +132,8 @@ int main(int _argc, const char *_argv[]) { zeus::init(_argc, _argv); appl::GateWay basicGateway; #ifdef GATEWAY_ENABLE_LAUNCHER - std::string basePath; - std::vector services; + etk::String basePath; + etk::Vector services; zeus::Client m_client; // The default service port is 1985 m_client.propertyPort.set(1985); @@ -141,17 +141,17 @@ int main(int _argc, const char *_argv[]) { // default delay to disconnect is 30 seconds: uint32_t routerDisconnectionDelay = 30; for (int32_t iii=0; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if (etk::start_with(data, "--user=") == true) { - basicGateway.propertyUserName.set(std::string(&data[7])); + basicGateway.propertyUserName.set(etk::String(&data[7])); } else if (data == "--no-router") { basicGateway.propertyRouterNo.set(true); } else if (etk::start_with(data, "--router-ip=") == true) { - basicGateway.propertyRouterIp.set(std::string(&data[12])); + basicGateway.propertyRouterIp.set(etk::String(&data[12])); } else if (etk::start_with(data, "--router-port=") == true) { - basicGateway.propertyRouterPort.set(etk::string_to_uint16_t(std::string(&data[14]))); + basicGateway.propertyRouterPort.set(etk::string_to_uint16_t(etk::String(&data[14]))); } else if (etk::start_with(data, "--router-delay=") == true) { - int32_t value = etk::string_to_int32_t(std::string(&data[15])); + int32_t value = etk::string_to_int32_t(etk::String(&data[15])); if (value == -1) { routerDisconnectionDelay = 999999999; } else if (value == 0) { @@ -166,26 +166,26 @@ int main(int _argc, const char *_argv[]) { } basicGateway.propertyServiceExtern.set(value); } else if (etk::start_with(data, "--service-ip=") == true) { - basicGateway.propertyServiceIp.set(std::string(&data[13])); + basicGateway.propertyServiceIp.set(etk::String(&data[13])); #ifdef GATEWAY_ENABLE_LAUNCHER - m_client.propertyIp.set(std::string(&data[13])); + m_client.propertyIp.set(etk::String(&data[13])); #endif } else if (etk::start_with(data, "--service-port=") == true) { - basicGateway.propertyServicePort.set(etk::string_to_uint16_t(std::string(&data[15]))); + basicGateway.propertyServicePort.set(etk::string_to_uint16_t(etk::String(&data[15]))); #ifdef GATEWAY_ENABLE_LAUNCHER - m_client.propertyPort.set(etk::string_to_uint16_t(std::string(&data[15]))); + m_client.propertyPort.set(etk::string_to_uint16_t(etk::String(&data[15]))); #endif } else if (etk::start_with(data, "--service-max=") == true) { - basicGateway.propertyServiceMax.set(etk::string_to_uint16_t(std::string(&data[14]))); + basicGateway.propertyServiceMax.set(etk::string_to_uint16_t(etk::String(&data[14]))); #ifdef GATEWAY_ENABLE_LAUNCHER } else if (etk::start_with(data, "--base-path=") == true) { - basePath = std::string(&data[12]); + basePath = etk::String(&data[12]); if ( basePath.size() != 0 && basePath[basePath.size()-1] != '/') { basePath += '/'; } } else if (etk::start_with(data, "--srv=") == true) { - services.push_back(std::string(&data[6])); + services.pushBack(etk::String(&data[6])); #endif } else if ( data == "-h" || data == "--help") { @@ -209,26 +209,26 @@ int main(int _argc, const char *_argv[]) { } } #ifdef GATEWAY_ENABLE_LAUNCHER - std::vector> listAvaillableServices; + etk::Vector> listAvaillableServices; if (services.size() != 0) { // find all services: etk::FSNode dataPath(etk::FSNodeGetApplicationPath() + "/../share"); - std::vector listSubPath = dataPath.folderGetSub(true, false, ".*"); + etk::Vector listSubPath = dataPath.folderGetSub(true, false, ".*"); APPL_DEBUG(" Base data path: " << dataPath.getName()); APPL_DEBUG(" SubPath: " << listSubPath); for (auto &it: listSubPath) { if (etk::FSNodeExist(it + "/zeus/") == true) { etk::FSNode dataPath(it + "/zeus/"); - std::vector listServices = dataPath.folderGetSub(false, true, ".*\\.srv"); + etk::Vector listServices = dataPath.folderGetSub(false, true, ".*\\.srv"); for (auto &it2: listServices) { - std::string nameFileSrv = etk::FSNode(it2).getNameFile(); - std::vector spl = etk::split(std::string(nameFileSrv.begin(), nameFileSrv.end()-4), "-service-"); + etk::String nameFileSrv = etk::FSNode(it2).getNameFile(); + etk::Vector spl = etk::split(etk::String(nameFileSrv.begin(), nameFileSrv.end()-4), "-service-"); if (spl.size() != 2) { APPL_ERROR("reject service, wrong format ... '" << it2 << "' missing XXX-service-SERVICE-NAME.srv"); continue; } APPL_INFO("find service : " << it2); - listAvaillableServices.push_back(std::make_pair(spl[1], std::string(nameFileSrv.begin(), nameFileSrv.end()-4))); + listAvaillableServices.pushBack(etk::makePair(spl[1], etk::String(nameFileSrv.begin(), nameFileSrv.end()-4))); } } else { // not check the second path ==> no service availlable @@ -256,12 +256,12 @@ int main(int _argc, const char *_argv[]) { #ifdef GATEWAY_ENABLE_LAUNCHER } else { bool routerAlive = true; - std::vector> listElements; + etk::Vector> listElements; if ( services.size() == 1 && services[0] == "all") { for (auto &it: listAvaillableServices) { ememory::SharedPtr tmp = ememory::makeShared(it.first, it.second); - listElements.push_back(tmp); + listElements.pushBack(tmp); } } else { for (auto &it: services) { @@ -270,7 +270,7 @@ int main(int _argc, const char *_argv[]) { for (auto &it2: listAvaillableServices) { if (it2.first == it) { ememory::SharedPtr tmp = ememory::makeShared(it2.first, it2.second); - listElements.push_back(tmp); + listElements.pushBack(tmp); find = true; break; } diff --git a/tools/launcher/appl/main-launcher.cpp b/tools/launcher/appl/main-launcher.cpp index e418a2a..4281116 100644 --- a/tools/launcher/appl/main-launcher.cpp +++ b/tools/launcher/appl/main-launcher.cpp @@ -19,27 +19,27 @@ #include #include -typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], std::string _basePath); +typedef bool (*SERVICE_IO_init_t)(int _argc, const char *_argv[], etk::String _basePath); typedef bool (*SERVICE_IO_uninit_t)(); typedef void (*SERVICE_IO_peridic_call_t)(); typedef zeus::Object* (*SERVICE_IO_instanciate_t)(uint32_t, ememory::SharedPtr&, uint32_t); class PlugginAccess { private: - std::string m_name; + etk::String m_name; void* m_handle; SERVICE_IO_init_t m_SERVICE_IO_init; SERVICE_IO_uninit_t m_SERVICE_IO_uninit; SERVICE_IO_peridic_call_t m_SERVICE_IO_peridic_call; SERVICE_IO_instanciate_t m_SERVICE_IO_instanciate; public: - PlugginAccess(const std::string& _name) : + PlugginAccess(const etk::String& _name) : m_name(_name), m_handle(nullptr), m_SERVICE_IO_init(nullptr), m_SERVICE_IO_uninit(nullptr), m_SERVICE_IO_instanciate(nullptr) { - std::string srv = etk::FSNodeGetApplicationPath() + "/../lib/libzeus-service-" + m_name + "-impl.so"; + etk::String srv = etk::FSNodeGetApplicationPath() + "/../lib/libzeus-service-" + m_name + "-impl.so"; APPL_PRINT("Try to open service with name: '" << m_name << "' at position: '" << srv << "'"); m_handle = dlopen(srv.c_str(), RTLD_LAZY); if (!m_handle) { @@ -75,7 +75,7 @@ class PlugginAccess { ~PlugginAccess() { } - bool init(int _argc, const char *_argv[], std::string _basePath) { + bool init(int _argc, const char *_argv[], etk::String _basePath) { if (m_SERVICE_IO_init == nullptr) { return false; } @@ -119,24 +119,24 @@ class PlugginAccess { int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); zeus::init(_argc, _argv); - std::string ip; + etk::String ip; uint16_t port = 1985; - std::string basePath; - std::vector services; + etk::String basePath; + etk::Vector services; for (int32_t iii=0; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if (etk::start_with(data, "--ip=") == true) { - ip = std::string(&data[5]); + ip = etk::String(&data[5]); } else if (etk::start_with(data, "--port=") == true) { - port = etk::string_to_uint16_t(std::string(&data[7])); + port = etk::string_to_uint16_t(etk::String(&data[7])); } else if (etk::start_with(data, "--base-path=") == true) { - basePath = std::string(&data[12]); + basePath = etk::String(&data[12]); if ( basePath.size() != 0 && basePath[basePath.size()-1] != '/') { basePath += '/'; } } else if (etk::start_with(data, "--srv=") == true) { - services.push_back(std::string(&data[6])); + services.pushBack(etk::String(&data[6])); } else if ( data == "-h" || data == "--help") { APPL_PRINT(etk::getApplicationName() << " - help : "); @@ -149,11 +149,11 @@ int main(int _argc, const char *_argv[]) { } } zeus::Client m_client; - std::vector> listElements; + etk::Vector> listElements; for (auto &it: services) { ememory::SharedPtr tmp = ememory::makeShared(it); - listElements.push_back(tmp); + listElements.pushBack(tmp); } for (auto &it: listElements) { diff --git a/tools/player-video/appl/ClientProperty.cpp b/tools/player-video/appl/ClientProperty.cpp index 491c767..04e63cd 100644 --- a/tools/player-video/appl/ClientProperty.cpp +++ b/tools/player-video/appl/ClientProperty.cpp @@ -100,14 +100,14 @@ void appl::ClientProperty::connect() { APPL_INFO("Done"); } -void appl::ClientProperty::setLogin(std::string _login) { +void appl::ClientProperty::setLogin(etk::String _login) { m_fromUser = ""; m_toUser = ""; m_address = ""; m_port = 0; // separate loggin and IP adress ... - std::string login; - std::vector listElem = etk::split(_login, '~'); + etk::String login; + etk::Vector listElem = etk::split(_login, '~'); if (listElem.size() == 0) { APPL_ERROR("Not enouth element in the login ..."); return; @@ -117,7 +117,7 @@ void appl::ClientProperty::setLogin(std::string _login) { if (listElem.size() == 1) { // connnect on local host ... nothing to do } else { - std::vector listElem2 = etk::split(listElem[1], ':'); + etk::Vector listElem2 = etk::split(listElem[1], ':'); if (listElem2.size() >= 1) { m_address = listElem2[0]; } @@ -127,8 +127,8 @@ void appl::ClientProperty::setLogin(std::string _login) { } } -std::string appl::ClientProperty::getLogin() { - std::string out = m_fromUser; +etk::String appl::ClientProperty::getLogin() { + etk::String out = m_fromUser; bool hasTild = false; if (m_address != "") { if (hasTild == false) { @@ -143,16 +143,16 @@ std::string appl::ClientProperty::getLogin() { out += "~" ; hasTild = true; } - out += ":" + etk::to_string(m_port); + out += ":" + etk::toString(m_port); } return out; } -void appl::ClientProperty::setPassword(std::string _password) { +void appl::ClientProperty::setPassword(etk::String _password) { m_pass = _password; } -std::string appl::ClientProperty::getPassword() { +etk::String appl::ClientProperty::getPassword() { return m_pass; } diff --git a/tools/player-video/appl/ClientProperty.hpp b/tools/player-video/appl/ClientProperty.hpp index a1ec320..98fd600 100644 --- a/tools/player-video/appl/ClientProperty.hpp +++ b/tools/player-video/appl/ClientProperty.hpp @@ -19,10 +19,10 @@ namespace appl { class ClientProperty { protected: - std::string m_fromUser; - std::string m_toUser; - std::string m_pass; - std::string m_address; + etk::String m_fromUser; + etk::String m_toUser; + etk::String m_pass; + etk::String m_address; uint16_t m_port; zeus::Client m_connection; public: @@ -35,10 +35,10 @@ namespace appl { void disconnect(); ejson::Object toJson(); void fromJson(ejson::Object _obj); - void setLogin(std::string _login); - std::string getLogin(); - void setPassword(std::string _password); - std::string getPassword(); + void setLogin(etk::String _login); + etk::String getLogin(); + void setPassword(etk::String _password); + etk::String getPassword(); }; } diff --git a/tools/player-video/appl/Main.cpp b/tools/player-video/appl/Main.cpp index a616a92..e89bcbc 100644 --- a/tools/player-video/appl/Main.cpp +++ b/tools/player-video/appl/Main.cpp @@ -59,7 +59,7 @@ namespace appl { void localCreate(ewol::Context& _context) { // parse all the argument of the application for (int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { - std::string tmpppp = _context.getCmd().get(iii); + etk::String tmpppp = _context.getCmd().get(iii); if ( tmpppp == "-h" || tmpppp == "--help") { APPL_INFO(" -h/--help display this help" ); @@ -89,7 +89,7 @@ namespace appl { // configure the ewol context to use the new windows _context.setWindows(basicWindows); for (int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { - std::string tmpppp = _context.getCmd().get(iii); + etk::String tmpppp = _context.getCmd().get(iii); if (etk::start_with(tmpppp, "-") == true) { continue; } diff --git a/tools/player-video/appl/MediaDecoder.cpp b/tools/player-video/appl/MediaDecoder.cpp index 7fd1314..cf6f555 100644 --- a/tools/player-video/appl/MediaDecoder.cpp +++ b/tools/player-video/appl/MediaDecoder.cpp @@ -101,14 +101,20 @@ static void unPlanar(void* _bufferOut, const void* _bufferIn, int32_t _nbSample, } } + void appl::MessageElementVideo::setSize(const ivec2& _size) { if (m_imageRealSize != _size) { // Resize the buffer: m_imageRealSize = _size; - m_lineSize = m_imageRealSize.x() * 3; + //m_lineSize = m_imageRealSize.x() * 3; + m_lineSize = m_imageRealSize.x() * 4; } - if (m_image.getSize() != m_imageRealSize) { - m_image.resize(m_imageRealSize); + if (m_image.getType() != egami::colorType::RGBA8) { + m_image.configure(m_imageRealSize, egami::colorType::RGBA8); + } else { + if (m_image.getSize() != m_imageRealSize) { + m_image.resize(m_imageRealSize); + } } } void appl::MessageElementAudio::configure(audio::format _format, uint32_t _sampleRate, int32_t _nbChannel, int32_t _nbSample) { @@ -169,7 +175,62 @@ appl::MediaDecoder::MediaDecoder() : appl::MediaDecoder::~MediaDecoder() { uninit(); } +/* +etk::color yuvToRGBA(uint32_t +unsigned char* rgb_image = new unsigned char[width * height * 3]; //width and height of the image to be converted + +int y; +int cr; +int cb; + +double r; +double g; +double b; + +for (int i = 0, j = 0; i < width * height * 3; i+=6 j+=4) { + //first pixel + y = yuyv_image[j]; + cb = yuyv_image[j+1]; + cr = yuyv_image[j+3]; + + r = y + (1.4065 * (cr - 128)); + g = y - (0.3455 * (cb - 128)) - (0.7169 * (cr - 128)); + b = y + (1.7790 * (cb - 128)); + + //This prevents colour distortions in your rgb image + if (r < 0) r = 0; + else if (r > 255) r = 255; + if (g < 0) g = 0; + else if (g > 255) g = 255; + if (b < 0) b = 0; + else if (b > 255) b = 255; + + rgb_image[i] = (unsigned char)r; + rgb_image[i+1] = (unsigned char)g; + rgb_image[i+2] = (unsigned char)b; + + //second pixel + y = yuyv_image[j+2]; + cb = yuyv_image[j+1]; + cr = yuyv_image[j+3]; + + r = y + (1.4065 * (cr - 128)); + g = y - (0.3455 * (cb - 128)) - (0.7169 * (cr - 128)); + b = y + (1.7790 * (cb - 128)); + + if (r < 0) r = 0; + else if (r > 255) r = 255; + if (g < 0) g = 0; + else if (g > 255) g = 255; + if (b < 0) b = 0; + else if (b > 255) b = 255; + + rgb_image[i+3] = (unsigned char)r; + rgb_image[i+4] = (unsigned char)g; + rgb_image[i+5] = (unsigned char)b; +} +*/ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) { int ret = 0; int decoded = m_packet.size; @@ -215,13 +276,23 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) { //m_videoPool[slotId].setSize(ivec2(m_frame->width, m_frame->height)); m_videoPool[slotId].setSize(m_size); uint8_t* dataPointer = (uint8_t*)(m_videoPool[slotId].m_image.getTextureDataPointer()); - // Convert Image in RGB: + // Convert/rescale Image in RGB: sws_scale(m_convertContext, (const uint8_t **)(m_frame->data), m_frame->linesize, 0, m_frame->height, &dataPointer, &m_videoPool[slotId].m_lineSize); + // change RGB in RGBA: + for (int32_t yyy=m_frame->height-1; yyy>=0; --yyy) { + uint8_t* startLine = dataPointer + yyy*m_videoPool[slotId].m_lineSize; + for (int32_t xxx=m_frame->width-1; xxx>=0; --xxx) { + startLine[xxx*4+3] = 0xFF; + startLine[xxx*4+2] = startLine[xxx*3+2]; + startLine[xxx*4+1] = startLine[xxx*3+1]; + startLine[xxx*4+0] = startLine[xxx*3+0]; + } + } m_videoPool[slotId].m_id = m_videoFrameCount; m_videoPool[slotId].m_time = m_currentVideoTime; m_videoPool[slotId].m_duration = echrono::Duration(0, 1000000000.0/float(getFps(m_videoDecoderContext))); @@ -529,7 +600,7 @@ bool appl::StreamBuffering::addDataCallback(const zeus::Raw& _data, int64_t _pos } if (find == false) { APPL_ERROR("insert new element in the list of values"); - m_bufferFillSection.insert(it, std::pair(_positionRequest, _positionRequest + _data.size())); + m_bufferFillSection.insert(it, etk::Pair(_positionRequest, _positionRequest + _data.size())); } } checkIfWeNeedMoreDataFromNetwork(); @@ -705,9 +776,11 @@ void appl::MediaDecoder::init() { m_videoDecoderContext = m_videoStream->codec; // allocate image where the decoded image will be put m_size.setValue(m_videoDecoderContext->width, m_videoDecoderContext->height); - if (m_size.x() > 512) { + #if 1 + while (m_size.x() > 512) { m_size /= 2; } + #endif m_pixelFormat = m_videoDecoderContext->pix_fmt; m_videoPool.resize(1); @@ -716,6 +789,8 @@ void appl::MediaDecoder::init() { m_convertContext = sws_getContext(m_videoDecoderContext->width, m_videoDecoderContext->height, m_pixelFormat, m_size.x(), m_size.y(), AV_PIX_FMT_RGB24, 0, 0, 0, 0); + // AV_PIX_FMT_RGB24 + // AV_PIX_FMT_BGRA } // Open Audio Decoder: if (open_codec_context(&m_audioStream_idx, m_formatContext, AVMEDIA_TYPE_AUDIO) >= 0) { diff --git a/tools/player-video/appl/MediaDecoder.hpp b/tools/player-video/appl/MediaDecoder.hpp index 3a07663..c9e126e 100644 --- a/tools/player-video/appl/MediaDecoder.hpp +++ b/tools/player-video/appl/MediaDecoder.hpp @@ -51,10 +51,10 @@ namespace appl { }; class MessageElementAudio : public appl::MessageElement { public: - std::vector m_buffer; //!< raw audio data + etk::Vector m_buffer; //!< raw audio data audio::format m_format; //!< Audio format buffer uint32_t m_sampleRate; //!< sample rate of the buffer - std::vector m_map; //!< Channel map of the buffer + etk::Vector m_map; //!< Channel map of the buffer void configure(audio::format _format, uint32_t _sampleRate, int32_t _nbChannel, int32_t _nbSample); }; class StreamBuffering : public ememory::EnableSharedFromThis { @@ -64,9 +64,9 @@ namespace appl { ememory::SharedPtr m_property; //!< Remote interface that must get data uint32_t m_mediaId; //!< remote media ID that need to get data zeus::ProxyFile m_fileHandle; //!< Reference on the remote file - std::vector m_buffer; //!< preallocated with all needed data + etk::Vector m_buffer; //!< preallocated with all needed data int32_t m_bufferReadPosition; //!< Current position that is read - std::vector> m_bufferFillSection; //!< List of position that contain data + etk::Vector> m_bufferFillSection; //!< List of position that contain data bool m_callInProgress; bool m_stopRequested; public: @@ -76,7 +76,7 @@ namespace appl { std::unique_lock lock(m_mutex); return m_buffer.size(); } - std::vector> getDownloadPart() { + etk::Vector> getDownloadPart() { std::unique_lock lock(m_mutex); return m_bufferFillSection; } @@ -98,9 +98,9 @@ namespace appl { return m_duration; } public: - std::vector m_audioPool; + etk::Vector m_audioPool; echrono::Duration m_currentAudioTime; - std::vector m_videoPool; + etk::Vector m_videoPool; echrono::Duration m_currentVideoTime; bool m_updateVideoTimeStampAfterSeek; bool getSeekDone() { @@ -125,7 +125,7 @@ namespace appl { enum AVPixelFormat m_pixelFormat; AVStream *m_videoStream; AVStream *m_audioStream; - std::string m_sourceFilename; + etk::String m_sourceFilename; int32_t m_videoStream_idx; int32_t m_audioStream_idx; @@ -154,14 +154,14 @@ namespace appl { bool m_audioPresent; audio::format m_audioFormat; //!< Audio format buffer uint32_t m_audioSampleRate; //!< sample rate of the buffer - std::vector m_audioMap; //!< Channel map of the buffer + etk::Vector m_audioMap; //!< Channel map of the buffer bool haveAudio() { return m_audioPresent; } uint32_t audioGetSampleRate() { return m_audioSampleRate; } - std::vector audioGetChannelMap() { + etk::Vector audioGetChannelMap() { return m_audioMap; } audio::format audioGetFormat() { @@ -185,17 +185,17 @@ namespace appl { // @brief INTERNAL seek callback int64_t seekFunc(int64_t _offset, int _whence); - std::vector> getDownloadPart() { - std::vector> out; + etk::Vector> getDownloadPart() { + etk::Vector> out; if (m_remote == nullptr) { return out; } - std::vector> vals = m_remote->getDownloadPart(); + etk::Vector> vals = m_remote->getDownloadPart(); echrono::Duration totalTime = getDuration(); float size = totalTime.toSeconds()/float(m_remote->getSize()); //APPL_ERROR(" duration in sec : " << totalTime << " => " << totalTime.toSeconds()); for (auto &it : vals) { - out.push_back(std::pair(float(it.first)*size, float(it.second)*size)); + out.pushBack(etk::Pair(float(it.first)*size, float(it.second)*size)); } return out; } diff --git a/tools/player-video/appl/Windows.cpp b/tools/player-video/appl/Windows.cpp index b233200..13e0ccd 100644 --- a/tools/player-video/appl/Windows.cpp +++ b/tools/player-video/appl/Windows.cpp @@ -29,7 +29,7 @@ #include -static std::string g_baseDBName = "USERDATA:config.json"; +static etk::String g_baseDBName = "USERDATA:config.json"; void appl::Windows::store_db() { APPL_DEBUG("Store database [START]"); @@ -65,7 +65,7 @@ appl::Windows::Windows(): m_id(0), m_fullScreen(false) { addObjectType("appl::Windows"); - propertyTitle.setDirectCheck(std::string("sample ") + PROJECT_NAME); + propertyTitle.setDirectCheck(etk::String("sample ") + PROJECT_NAME); } void appl::Windows::init() { @@ -120,12 +120,12 @@ void appl::Windows::init() { } -void appl::Windows::onCallbackShortCut(const std::string& _value) { +void appl::Windows::onCallbackShortCut(const etk::String& _value) { APPL_WARNING("Event from ShortCut : " << _value); onCallbackMenuEvent(_value); } -void appl::Windows::onCallbackMenuEvent(const std::string& _value) { +void appl::Windows::onCallbackMenuEvent(const etk::String& _value) { APPL_WARNING("Event from Menu : " << _value); if (m_player != nullptr) { m_player->stop(); @@ -242,9 +242,9 @@ void appl::Windows::onCallbackPrevious() { tmpDisp->setFile(m_list[m_id]); tmpDisp->play(); echrono::Duration time = tmpDisp->getDuration(); - APPL_DEBUG("duration = " << time << " " << etk::to_string(time.toSeconds())); + APPL_DEBUG("duration = " << time << " " << etk::toString(time.toSeconds())); propertySetOnWidgetNamed("progress-bar", "value", "0"); - propertySetOnWidgetNamed("progress-bar", "max", etk::to_string(time.toSeconds())); + propertySetOnWidgetNamed("progress-bar", "max", etk::toString(time.toSeconds())); } } @@ -268,26 +268,26 @@ void appl::Windows::onCallbackNext() { tmpDisp->setFile(m_list[m_id]); tmpDisp->play(); echrono::Duration time = tmpDisp->getDuration(); - APPL_DEBUG("duration = " << time << " " << etk::to_string(time.toSeconds())); + APPL_DEBUG("duration = " << time << " " << etk::toString(time.toSeconds())); propertySetOnWidgetNamed("progress-bar", "value", "0"); - propertySetOnWidgetNamed("progress-bar", "max", etk::to_string(time.toSeconds())); + propertySetOnWidgetNamed("progress-bar", "max", etk::toString(time.toSeconds())); } } -void appl::Windows::addFile(const std::string& _file) { +void appl::Windows::addFile(const etk::String& _file) { APPL_DEBUG("Add file : " << _file); - m_list.push_back(_file); + m_list.pushBack(_file); if (m_list.size() == 1) { m_id = 0; ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); if (tmpDisp != nullptr) { tmpDisp->setFile(m_list[m_id]); echrono::Duration time = tmpDisp->getDuration(); - APPL_DEBUG("duration = " << time << " " << etk::to_string(time.toSeconds())); + APPL_DEBUG("duration = " << time << " " << etk::toString(time.toSeconds())); propertySetOnWidgetNamed("progress-bar", "value", "0"); - propertySetOnWidgetNamed("progress-bar", "max", etk::to_string(time.toSeconds())); + propertySetOnWidgetNamed("progress-bar", "max", etk::toString(time.toSeconds())); } } } diff --git a/tools/player-video/appl/Windows.hpp b/tools/player-video/appl/Windows.hpp index 746f3dd..b48e591 100644 --- a/tools/player-video/appl/Windows.hpp +++ b/tools/player-video/appl/Windows.hpp @@ -23,7 +23,7 @@ namespace appl { ememory::SharedPtr m_clientProp; appl::widget::ListViewerShared m_listViewer; appl::widget::PlayerShared m_player; - std::vector m_list; + etk::Vector m_list; int32_t m_id; public: DECLARE_FACTORY(Windows); @@ -32,7 +32,7 @@ namespace appl { void onCallbackPrevious(); void onCallbackPlay(const bool& _isPressed); void onCallbackNext(); - void addFile(const std::string& _file); + void addFile(const etk::String& _file); void onCallbackSeekRequest(const float& _value); @@ -40,8 +40,8 @@ namespace appl { void onCallbackConnectionError(const ememory::SharedPtr& _prop); void onCallbackConnectionCancel(); - void onCallbackShortCut(const std::string& _value); - void onCallbackMenuEvent(const std::string& _value); + void onCallbackShortCut(const etk::String& _value); + void onCallbackMenuEvent(const etk::String& _value); protected: void load_db(); void store_db(); diff --git a/tools/player-video/appl/widget/Connection.cpp b/tools/player-video/appl/widget/Connection.cpp index 41ffc2c..903cfcd 100644 --- a/tools/player-video/appl/widget/Connection.cpp +++ b/tools/player-video/appl/widget/Connection.cpp @@ -16,8 +16,8 @@ #include #include #include -//#include -#include +//#include +#include #include #include @@ -33,10 +33,10 @@ appl::widget::Connection::Connection() : void appl::widget::Connection::init() { ewol::widget::Composer::init(); loadFromFile("DATA:gui-connection.xml", getId()); - subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue); - subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue); - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate); - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]cancel-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonCancel); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]cancel-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonCancel); setProperty(nullptr); propertyCanFocus.set(true); } @@ -54,24 +54,24 @@ void appl::widget::Connection::setProperty(ememory::SharedPtrgetLogin(); m_password = m_baseProperty->getPassword(); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-login", "value", m_login); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-password", "value", m_password); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]connect-login", "value", m_login); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]connect-password", "value", m_password); } void appl::widget::Connection::onGetFocus() { // transfert focus on a specific widget... - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-login", "focus", "true"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]connect-login", "focus", "true"); } appl::widget::Connection::~Connection() { } -void appl::widget::Connection::onCallbackEntryLoginChangeValue(const std::string& _value) { +void appl::widget::Connection::onCallbackEntryLoginChangeValue(const etk::String& _value) { m_login = _value; } -void appl::widget::Connection::onCallbackEntryPasswordChangeValue(const std::string& _value) { +void appl::widget::Connection::onCallbackEntryPasswordChangeValue(const etk::String& _value) { m_password = _value; } diff --git a/tools/player-video/appl/widget/Connection.hpp b/tools/player-video/appl/widget/Connection.hpp index 3955487..a42fc3e 100644 --- a/tools/player-video/appl/widget/Connection.hpp +++ b/tools/player-video/appl/widget/Connection.hpp @@ -65,8 +65,8 @@ namespace appl { esignal::Signal> signalConnectionError; //!< Error on connection protected: ememory::SharedPtr m_baseProperty; - std::string m_login; - std::string m_password; + etk::String m_login; + etk::String m_password; Connection(); void init() override; public: @@ -74,7 +74,7 @@ namespace appl { virtual ~Connection(); void setProperty(ememory::SharedPtr _baseProperty=nullptr); private: - std::string getCompleateFileName(); + etk::String getCompleateFileName(); void updateCurrentFolder(); public: void onGetFocus() override; @@ -82,8 +82,8 @@ namespace appl { // callback functions: void onCallbackButtonValidate(); void onCallbackButtonCancel(); - void onCallbackEntryLoginChangeValue(const std::string& _value); - void onCallbackEntryPasswordChangeValue(const std::string& _value); + void onCallbackEntryLoginChangeValue(const etk::String& _value); + void onCallbackEntryPasswordChangeValue(const etk::String& _value); }; }; }; diff --git a/tools/player-video/appl/widget/ListViewer.cpp b/tools/player-video/appl/widget/ListViewer.cpp index d4aba99..011376c 100644 --- a/tools/player-video/appl/widget/ListViewer.cpp +++ b/tools/player-video/appl/widget/ListViewer.cpp @@ -45,7 +45,7 @@ appl::widget::ListViewer::~ListViewer() { } -void appl::widget::ListViewer::searchElements(std::string _filter) { +void appl::widget::ListViewer::searchElements(etk::String _filter) { if (_filter == "group") { searchElementsInternal("*", "type"); } else if (_filter == "film") { @@ -80,7 +80,7 @@ void appl::ElementProperty::loadData() { auto tmpProperty = sharedFromThis(); // Get the media zeus::Future futMedia = m_remoteServiceVideo.get(m_id); - futMedia.andElse([=](const std::string& _error, const std::string& _help) mutable { + futMedia.andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get media error: " << tmpProperty->m_id); { std::unique_lock lock(tmpProperty->m_mutex); @@ -103,7 +103,7 @@ void appl::ElementProperty::loadData() { return true; } _media.getMetadata("title") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -113,7 +113,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get title: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -130,7 +130,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMetadata("series-name") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -140,7 +140,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get serie: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -157,7 +157,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMetadata("saison") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -167,7 +167,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get saison: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -184,7 +184,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMetadata("episode") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -194,7 +194,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get episode: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -211,7 +211,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMetadata("description") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO("Get remot error : " << _error << " " << _help); { std::unique_lock lock(tmpProperty->m_mutex); @@ -222,7 +222,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get description: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -239,7 +239,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMetadata("production-methode") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -249,7 +249,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get production-methode: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -266,7 +266,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMetadata("type") - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -276,7 +276,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get type: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -293,7 +293,7 @@ void appl::ElementProperty::loadData() { return true; }); _media.getMineType() - .andElse([=](const std::string& _error, const std::string& _help) mutable { + .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; @@ -303,7 +303,7 @@ void appl::ElementProperty::loadData() { } return true; }) - .andThen([=](std::string _value) mutable { + .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get mine-type: " << _value); { std::unique_lock lock(tmpProperty->m_mutex); @@ -330,18 +330,18 @@ void appl::ElementProperty::loadData() { return true; }); auto futMediaCover = m_remoteServiceVideo.getCover(m_id, 128); - futMediaCover.andElse([=](const std::string& _error, const std::string& _help) mutable { + futMediaCover.andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover error: " << tmpProperty->m_id << ": " << _help); // TODO : Remove this ... std::this_thread::sleep_for(std::chrono::milliseconds(400)); - std::string serie; + etk::String serie; { std::unique_lock lock(tmpProperty->m_mutex); serie = tmpProperty->m_serie; } if (serie != "") { auto futMediaGroupCover = m_remoteServiceVideo.getGroupCover(serie, 128); - futMediaGroupCover.andElse([=](const std::string& _error, const std::string& _help) mutable { + futMediaGroupCover.andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group error: " << serie << ": " << _help); { m_widget->markToRedraw(); @@ -356,9 +356,9 @@ void appl::ElementProperty::loadData() { futMediaGroupCover.andThen([=](zeus::ProxyFile _media) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie); auto mineTypeFut = _media.getMineType(); - std::vector bufferData = zeus::storeInMemory(_media); + etk::Vector bufferData = zeus::storeInMemory(_media); APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie << " store in memory " << bufferData.size()); - std::string mineType = mineTypeFut.wait().get(); + etk::String mineType = mineTypeFut.wait().get(); APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie << " mineType '" << mineType << "'"); { std::unique_lock lock(tmpProperty->m_mutex); @@ -389,9 +389,9 @@ void appl::ElementProperty::loadData() { futMediaCover.andThen([=](zeus::ProxyFile _media) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id); auto mineTypeFut = _media.getMineType(); - std::vector bufferData = zeus::storeInMemory(_media); + etk::Vector bufferData = zeus::storeInMemory(_media); APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id << " store in memory " << bufferData.size()); - std::string mineType = mineTypeFut.wait().get(); + etk::String mineType = mineTypeFut.wait().get(); APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id << " mineType '" << mineType << "'"); { std::unique_lock lock(tmpProperty->m_mutex); @@ -427,7 +427,7 @@ void appl::ElementPropertyGroup::loadData() { auto tmpProperty = sharedFromThis(); // Get the media auto futMedia = m_remoteServiceVideo.getGroupCover(m_title, 128); - futMedia.andElse([=](const std::string& _error, const std::string& _help) mutable { + futMedia.andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover error on group: " << tmpProperty->m_title << ": " << _help); { std::unique_lock lock(tmpProperty->m_mutex); @@ -439,9 +439,9 @@ void appl::ElementPropertyGroup::loadData() { futMedia.andThen([=](zeus::ProxyFile _media) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title); auto mineTypeFut = _media.getMineType(); - std::vector bufferData = zeus::storeInMemory(_media); + etk::Vector bufferData = zeus::storeInMemory(_media); APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " store in memory " << bufferData.size()); - std::string mineType = mineTypeFut.wait().get(); + etk::String mineType = mineTypeFut.wait().get(); APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " mineType '" << mineType << "'"); { std::unique_lock lock(tmpProperty->m_mutex); @@ -466,11 +466,11 @@ void appl::widget::ListViewer::backHistory() { return; } auto value = m_history.back(); - m_history.pop_back(); + m_history.popBack(); searchElementsInternal(value.first, value.second, false); } -void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter, const std::string& _group, bool _storeHistory) { +void appl::widget::ListViewer::searchElementsInternal(const etk::String& _filter, const etk::String& _group, bool _storeHistory) { m_listElement.clear(); m_listElementGroup.clear(); m_listDisplay.clear(); @@ -481,7 +481,7 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter } if ( m_currentFilter != "" && _storeHistory == true) { - m_history.push_back(std::make_pair(m_currentFilter, m_currentGroup)); + m_history.pushBack(etk::makePair(m_currentFilter, m_currentGroup)); } m_currentFilter = _filter; m_currentGroup = _group; @@ -505,12 +505,12 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter return; } if (m_currentGroup != "") { - zeus::Future> listElem = remoteServiceVideo.getMetadataValuesWhere(m_currentGroup, m_currentFilter).wait(); + zeus::Future> listElem = remoteServiceVideo.getMetadataValuesWhere(m_currentGroup, m_currentFilter).wait(); if (listElem.hasError() == true) { APPL_ERROR(" ==> Can not get elements from video service returnValues = listElem.get(); + etk::Vector returnValues = listElem.get(); APPL_INFO("Get some Values: " << returnValues << ""); if (returnValues.size() == 1) { // TODO: if we have a single element and this is requested as a group ==> just jump in it @@ -530,15 +530,15 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter elem->m_title = it; } //elem->m_thumb = remoteServiceVideo.mediaThumbGet(it, 128).wait().get(); - m_listElementGroup.push_back(elem); + m_listElementGroup.pushBack(elem); } } else { - zeus::Future> listElem = remoteServiceVideo.getSQL(m_currentFilter).wait(); + zeus::Future> listElem = remoteServiceVideo.getSQL(m_currentFilter).wait(); if (listElem.hasError() == true) { APPL_ERROR(" ==> Can not get element from video service returnValues = listElem.get(); + etk::Vector returnValues = listElem.get(); APPL_INFO("Get some Values: " << returnValues << ""); for (auto &it : returnValues) { auto elem = ememory::makeShared(remoteServiceVideo, ememory::staticPointerCast(sharedFromThis())); @@ -548,7 +548,7 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter } elem->m_id = it; // ==> loading is done when display is requested ... - m_listElement.push_back(elem); + m_listElement.pushBack(elem); } } APPL_INFO("Request All is done"); @@ -571,7 +571,7 @@ void appl::widget::ListViewer::onRegenerateDisplay() { if (needRedraw() == false) { return; } - std::u32string errorString = U"No element Availlable"; + etk::UString errorString = U"No element Availlable"; m_text.clear(); // to know the size of one line : @@ -643,7 +643,7 @@ void appl::widget::ListViewer::onRegenerateDisplay() { m_listDisplay.clear(); for (size_t iii=0; iii(); - m_listDisplay.push_back(elem); + m_listDisplay.pushBack(elem); } } int32_t offset = m_originScrooled.y() / realPixelSize.y(); @@ -716,7 +716,7 @@ void appl::widget::ListViewer::onRegenerateDisplay() { startPos -= vec2(0, elementSize.y()); } m_maxSize.setX(m_size.x()); - m_maxSize.setY(float(std::max(m_listElement.size(),m_listElementGroup.size()))*elementSize.y()); + m_maxSize.setY(float(etk::max(m_listElement.size(),m_listElementGroup.size()))*elementSize.y()); // call the herited class... ewol::widget::WidgetScrolled::onRegenerateDisplay(); } @@ -770,10 +770,10 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { //APPL_VERBOSE("[" << getId() << "] {" << errorString << "} display at pos : " << tmpTextOrigin); m_text.setTextAlignement(originText.x(), originText.x()+_size.x()-_size.y(), ewol::compositing::alignDisable); // TODO: m_text.setClipping(originText, vec2(originText.x()+_size.x()-_size.y(), _size.y())); - std::string textToDisplay; + etk::String textToDisplay; if (m_property != nullptr) { if (m_property->LoadDataEnded() == false) { - textToDisplay += "
Loading in progress ... " + etk::to_string(m_property->m_nbElementLoaded) + "/8"; + textToDisplay += "
Loading in progress ... " + etk::toString(m_property->m_nbElementLoaded) + "/8"; } else { std::unique_lock lock(m_property->m_mutex); //m_text.setClipping(drawClippingPos, drawClippingSize); @@ -896,7 +896,7 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { if (prop == nullptr) { return true; } - std::string fullTitle; + etk::String fullTitle; if (prop->m_serie != "") { fullTitle += prop->m_serie + "-"; } @@ -915,7 +915,7 @@ bool appl::widget::ListViewer::onEventInput(const ewol::event::Input& _event) { if (prop == nullptr) { return true; } - std::string newGroup = ""; + etk::String newGroup = ""; if (m_currentGroup == "type") { if (prop->m_filter == "film") { newGroup = "production-methode"; diff --git a/tools/player-video/appl/widget/ListViewer.hpp b/tools/player-video/appl/widget/ListViewer.hpp index 684314b..51b6d8f 100644 --- a/tools/player-video/appl/widget/ListViewer.hpp +++ b/tools/player-video/appl/widget/ListViewer.hpp @@ -46,14 +46,14 @@ namespace appl { egami::Image m_thumb; //!< simple image describing the element bool m_thumbPresent; //!< if true, the Image is loaded - std::string m_title; //!< Title of the Element - std::string m_description; //!< Description of the element - std::string m_serie; //!< Name of the serie or empty - std::string m_episode; //!< Id of the Episode or empty - std::string m_saison; //!< id of the saison or empty - std::string m_mineType; //!< mine type: video/audio/image/... - std::string m_type; //!< type of the element - std::string m_productMethode; //!< Methode of production + etk::String m_title; //!< Title of the Element + etk::String m_description; //!< Description of the element + etk::String m_serie; //!< Name of the serie or empty + etk::String m_episode; //!< Id of the Episode or empty + etk::String m_saison; //!< id of the saison or empty + etk::String m_mineType; //!< mine type: video/audio/image/... + etk::String m_type; //!< type of the element + etk::String m_productMethode; //!< Methode of production // TODO: float m_globalNote; //!< note over [0,0..1,0] // TODO: int32_t m_countPersonalView; //!< number of view this media // TODO: int64_t m_globalPersonalView; //!< number of time this media has been viewed @@ -79,8 +79,8 @@ namespace appl { public: std::mutex m_mutex; uint64_t m_id; //!< Remote Id of the Media - std::string m_title; //!< Title of the Group - std::string m_filter; //!< element to add in the filter + etk::String m_title; //!< Title of the Group + etk::String m_filter; //!< element to add in the filter egami::Image m_thumb; //!< simple image describing the element bool m_thumbPresent; //!< if true, the Image is loaded void loadData(); @@ -113,14 +113,14 @@ namespace appl { class ElementCache { private: - std::string m_name; + etk::String m_name; ememory::SharedPtr m_resource; echrono::Steady m_lastRequestTime; }; class CacheImageManager { private: - std::vector m_imageCoverGroupCache; //!< All image cash of the group cover + etk::Vector m_imageCoverGroupCache; //!< All image cash of the group cover }; @@ -137,11 +137,11 @@ namespace appl { protected: ememory::SharedPtr m_clientProp; //!< Generic entrypoint on the Client protected: - std::vector> m_listElement; //!< list of all element getted in the remote access - std::vector> m_listElementGroup; //!< list of all element getted in the remote access - std::string m_currentFilter; - std::string m_currentGroup; - std::vector> m_listDisplay; //!< list of element in the current local display + etk::Vector> m_listElement; //!< list of all element getted in the remote access + etk::Vector> m_listElementGroup; //!< list of all element getted in the remote access + etk::String m_currentFilter; + etk::String m_currentGroup; + etk::Vector> m_listDisplay; //!< list of element in the current local display uint64_t m_currentPayed; protected: //! @brief constructor @@ -158,11 +158,11 @@ namespace appl { void setClientProperty(ememory::SharedPtr _prop) { m_clientProp = _prop; } - void searchElements(std::string _filter=""); - void searchElementsInternal(const std::string& _filter, const std::string& _group="", bool _storeHistory=true); + void searchElements(etk::String _filter=""); + void searchElementsInternal(const etk::String& _filter, const etk::String& _group="", bool _storeHistory=true); bool onEventInput(const ewol::event::Input& _event) override; protected: - std::vector> m_history; + etk::Vector> m_history; public: void backHistory(); public: diff --git a/tools/player-video/appl/widget/Player.cpp b/tools/player-video/appl/widget/Player.cpp index 1d25dbc..91df12d 100644 --- a/tools/player-video/appl/widget/Player.cpp +++ b/tools/player-video/appl/widget/Player.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -37,22 +37,22 @@ void appl::widget::Player::init() { if (*propertySubFile == "") { propertySubFile.set("DATA:gui-player.xml"); } - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-previous", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonPrevious); - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-play", signalValue, sharedFromThis(), &appl::widget::Player::onCallbackButtonPlay); - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-next", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonNext); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]appl-player-bt-previous", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonPrevious); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]appl-player-bt-play", signalValue, sharedFromThis(), &appl::widget::Player::onCallbackButtonPlay); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]appl-player-bt-next", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonNext); - subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalOther, sharedFromThis(), &appl::widget::Player::onCallbackOther); - subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalPosition, sharedFromThis(), &appl::widget::Player::onCallbackPosition); - subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalDuration, sharedFromThis(), &appl::widget::Player::onCallbackDuration); - subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFinish, sharedFromThis(), &appl::widget::Player::onCallbackFinished); + subBind(appl::widget::VideoDisplay, "[" + etk::toString(getId()) + "]appl-player-display", signalOther, sharedFromThis(), &appl::widget::Player::onCallbackOther); + subBind(appl::widget::VideoDisplay, "[" + etk::toString(getId()) + "]appl-player-display", signalPosition, sharedFromThis(), &appl::widget::Player::onCallbackPosition); + subBind(appl::widget::VideoDisplay, "[" + etk::toString(getId()) + "]appl-player-display", signalDuration, sharedFromThis(), &appl::widget::Player::onCallbackDuration); + subBind(appl::widget::VideoDisplay, "[" + etk::toString(getId()) + "]appl-player-display", signalFinish, sharedFromThis(), &appl::widget::Player::onCallbackFinished); - subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFps, sharedFromThis(), &appl::widget::Player::onCallbackFPS); - subBind(appl::widget::ProgressBar, "[" + etk::to_string(getId()) + "]appl-player-progress-bar", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackSeekRequest); - subBind(appl::widget::UpBar, "[" + etk::to_string(getId()) + "]appl-player-volume", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackVolumeRequest); - subBind(appl::widget::UpBar, "[" + etk::to_string(getId()) + "]appl-player-light", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackLightRequest); + subBind(appl::widget::VideoDisplay, "[" + etk::toString(getId()) + "]appl-player-display", signalFps, sharedFromThis(), &appl::widget::Player::onCallbackFPS); + subBind(appl::widget::ProgressBar, "[" + etk::toString(getId()) + "]appl-player-progress-bar", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackSeekRequest); + subBind(appl::widget::UpBar, "[" + etk::toString(getId()) + "]appl-player-volume", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackVolumeRequest); + subBind(appl::widget::UpBar, "[" + etk::toString(getId()) + "]appl-player-light", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackLightRequest); - m_display = ememory::dynamicPointerCast(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display")); - m_progress = ememory::dynamicPointerCast(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar")); + m_display = ememory::dynamicPointerCast(getSubObjectNamed("[" + etk::toString(getId()) + "]appl-player-display")); + m_progress = ememory::dynamicPointerCast(getSubObjectNamed("[" + etk::toString(getId()) + "]appl-player-progress-bar")); propertyCanFocus.set(true); markToRedraw(); } @@ -60,7 +60,7 @@ void appl::widget::Player::init() { void appl::widget::Player::onGetFocus() { // transfert focus on a specific widget... - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "focus", "true"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-bt-play", "focus", "true"); } appl::widget::Player::~Player() { @@ -72,54 +72,54 @@ void appl::widget::Player::playStream(ememory::SharedPtr _ return; } // stop previous (if needed) - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-bt-play", "value", "false"); m_display->stop(); // Set new file: m_display->setZeusMedia(_property, _mediaId); m_display->play(); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "true"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-bt-play", "value", "true"); } -static std::string timeToStaticString(const echrono::Duration& _time) { +static etk::String timeToStaticString(const echrono::Duration& _time) { float sec = _time.toSeconds(); int32_t millisecond = int32_t(sec*1000.0f)%999; int32_t seconds = int32_t(sec)%60; int32_t minutes = int32_t(sec/60)%60; int32_t hours = sec/3600; - std::string out; + etk::String out; if (hours!=0) { - out += etk::to_string(hours) + ":"; + out += etk::toString(hours) + ":"; } if (minutes<10) { - out += " " + etk::to_string(minutes) + "'"; + out += " " + etk::toString(minutes) + "'"; } else { - out += etk::to_string(minutes) + "'"; + out += etk::toString(minutes) + "'"; } if (seconds<10) { - out += " " + etk::to_string(seconds) + "\""; + out += " " + etk::toString(seconds) + "\""; } else { - out += etk::to_string(seconds) + "\""; + out += etk::toString(seconds) + "\""; } if (millisecond<10) { - out += " 00" + etk::to_string(millisecond); + out += " 00" + etk::toString(millisecond); } else if (millisecond<100) { - out += " 0" + etk::to_string(millisecond); + out += " 0" + etk::toString(millisecond); } else { - out += etk::to_string(millisecond); + out += etk::toString(millisecond); } return out; } void appl::widget::Player::onCallbackFinished() { if (m_progress != nullptr) { - std::vector> tmp; + etk::Vector> tmp; m_progress->setRangeAvaillable(tmp); m_progress->propertyValue.set(0); m_progress->propertyMaximum.set(0); } - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-time", "value", "--:--"); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-duration", "value", "--:--"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-time", "value", "--:--"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-duration", "value", "--:--"); signalFinished.emit(); } @@ -130,17 +130,17 @@ void appl::widget::Player::onCallbackDuration(const echrono::Duration& _time) { m_progress->propertyValue.set(0); m_progress->propertyMaximum.set(_time.toSeconds()); } - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-duration", "value", "" + timeToStaticString(_time) + ""); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-duration", "value", "" + timeToStaticString(_time) + ""); } void appl::widget::Player::onCallbackPosition(const echrono::Duration& _time) { //APPL_ERROR("time = " << _time); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-time", "value", "" + timeToStaticString(_time) + ""); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-time", "value", "" + timeToStaticString(_time) + ""); if (m_progress != nullptr) { m_progress->propertyValue.set(_time.toSeconds()); } if (m_display != nullptr) { - std::vector> tmp = m_display->getDownloadPart(); + etk::Vector> tmp = m_display->getDownloadPart(); if (m_progress != nullptr) { m_progress->setRangeAvaillable(tmp); } @@ -175,19 +175,19 @@ void appl::widget::Player::onCallbackLightRequest(const float& _value) { } -void appl::widget::Player::onCallbackOther(const std::string& _plop) { +void appl::widget::Player::onCallbackOther(const etk::String& _plop) { APPL_DEBUG("FPS = " << _plop); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-fps", "value", "FPS=" + _plop + ""); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-fps", "value", "FPS=" + _plop + ""); } void appl::widget::Player::onCallbackFPS(const int32_t& _fps) { APPL_DEBUG("FPS = " << _fps); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-fps", "value", "FPS=" + etk::to_string(_fps) + ""); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-fps", "value", "FPS=" + etk::toString(_fps) + ""); } void appl::widget::Player::stop() { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-bt-play", "value", "false"); if (m_display == nullptr) { return; } @@ -195,7 +195,7 @@ void appl::widget::Player::stop() { } void appl::widget::Player::suspend() { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-bt-play", "value", "false"); if (m_display == nullptr) { return; } diff --git a/tools/player-video/appl/widget/Player.hpp b/tools/player-video/appl/widget/Player.hpp index 4b851ab..84ba950 100644 --- a/tools/player-video/appl/widget/Player.hpp +++ b/tools/player-video/appl/widget/Player.hpp @@ -52,7 +52,7 @@ namespace appl { void onCallbackVolumeRequest(const float& _value); void onCallbackLightRequest(const float& _value); void onCallbackFPS(const int32_t& _fps); - void onCallbackOther(const std::string& _plop); + void onCallbackOther(const etk::String& _plop); void onCallbackFinished(); }; }; diff --git a/tools/player-video/appl/widget/ProgressBar.cpp b/tools/player-video/appl/widget/ProgressBar.cpp index 75465cc..af10162 100644 --- a/tools/player-video/appl/widget/ProgressBar.cpp +++ b/tools/player-video/appl/widget/ProgressBar.cpp @@ -40,8 +40,8 @@ appl::widget::ProgressBar::~ProgressBar() { void appl::widget::ProgressBar::calculateMinMaxSize() { vec2 minTmp = propertyMinSize->getPixel(); - m_minSize.setValue(std::max(minTmp.x(), 40.0f), - std::max(minTmp.y(), dotRadius*2.0f) ); + m_minSize.setValue(etk::max(minTmp.x(), 40.0f), + etk::max(minTmp.y(), dotRadius*2.0f) ); markToRedraw(); } @@ -65,7 +65,7 @@ void appl::widget::ProgressBar::onRegenerateDisplay() { for (auto &it: m_listAvaillable) { //APPL_INFO("plop " << it.first << " " << it.second); m_draw.setPos(vec3(dotRadius+(it.first/propertyMaximum)*(m_size.x()-2*dotRadius), m_size.y()*0.1, 0)); - m_draw.rectangleWidth(vec3(std::min((m_size.x()-2*dotRadius), (it.second/propertyMaximum)*(m_size.x()-2*dotRadius)), m_size.y()*0.8, 0) ); + m_draw.rectangleWidth(vec3(etk::min((m_size.x()-2*dotRadius), (it.second/propertyMaximum)*(m_size.x()-2*dotRadius)), m_size.y()*0.8, 0) ); } m_draw.setColor(m_textColorDone); @@ -105,7 +105,7 @@ bool appl::widget::ProgressBar::onEventInput(const ewol::event::Input& _event) { } void appl::widget::ProgressBar::updateValue(float _newValue) { - _newValue = std::max(std::min(_newValue, *propertyMaximum), 0.0f); + _newValue = etk::max(etk::min(_newValue, *propertyMaximum), 0.0f); propertyValue.setDirect(_newValue); markToRedraw(); } diff --git a/tools/player-video/appl/widget/ProgressBar.hpp b/tools/player-video/appl/widget/ProgressBar.hpp index 137dce3..1fec87a 100644 --- a/tools/player-video/appl/widget/ProgressBar.hpp +++ b/tools/player-video/appl/widget/ProgressBar.hpp @@ -24,7 +24,7 @@ namespace appl { public: // signals esignal::Signal signalChange; public: - //eproperty::Value propertyShape; //!< name of the shape used + //eproperty::Value propertyShape; //!< name of the shape used eproperty::Value propertyValue; //!< current value of the ProgressBar eproperty::Value propertyMaximum; //!< maximum value of the ProgressBar protected: @@ -50,9 +50,9 @@ namespace appl { void onRegenerateDisplay() override; bool onEventInput(const ewol::event::Input& _event) override; private: - std::vector> m_listAvaillable; + etk::Vector> m_listAvaillable; public: - void setRangeAvaillable(std::vector>& _values) { + void setRangeAvaillable(etk::Vector>& _values) { m_listAvaillable = _values; } protected: diff --git a/tools/player-video/appl/widget/UpBar.cpp b/tools/player-video/appl/widget/UpBar.cpp index e21cc35..d676f4b 100644 --- a/tools/player-video/appl/widget/UpBar.cpp +++ b/tools/player-video/appl/widget/UpBar.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include @@ -50,11 +50,11 @@ void appl::widget::UpBar::init() { } } if (*propertyType == "volume") { - subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackVolumeRequest); + subBind(appl::widget::VolumeBar, "[" + etk::toString(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackVolumeRequest); } else { - subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackLightRequest); + subBind(appl::widget::VolumeBar, "[" + etk::toString(getId()) + "]appl-upbar-range", signalChange, sharedFromThis(), &appl::widget::UpBar::onCallbackLightRequest); } - subBind(appl::widget::VolumeBar, "[" + etk::to_string(getId()) + "]appl-upbar-range", signalHide, sharedFromThis(), &appl::widget::UpBar::onCallbackHide); + subBind(appl::widget::VolumeBar, "[" + etk::toString(getId()) + "]appl-upbar-range", signalHide, sharedFromThis(), &appl::widget::UpBar::onCallbackHide); markToRedraw(); } @@ -67,8 +67,8 @@ void appl::widget::UpBar::onCallbackVolumeRequest(const float& _value) { APPL_DEBUG("volume change value=" << _value << " dB"); APPL_DEBUG("==========================================================================="); signalChange.emit(_value); - std::string display = etk::to_string(int32_t(_value)) + "." + etk::to_string(std::abs(int32_t(_value*10.0f)-int32_t(_value)*10)); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "value", display + " dB"); + etk::String display = etk::toString(int32_t(_value)) + "." + etk::toString(std::abs(int32_t(_value*10.0f)-int32_t(_value)*10)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-label", "value", display + " dB"); } void appl::widget::UpBar::onCallbackLightRequest(const float& _value) { @@ -76,17 +76,17 @@ void appl::widget::UpBar::onCallbackLightRequest(const float& _value) { APPL_DEBUG("Light change value=" << _value << " %"); APPL_DEBUG("==========================================================================="); signalChange.emit(float(int32_t(_value))*0.01f); - std::string display = etk::to_string(int32_t(_value)); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "value", display + " %"); + etk::String display = etk::toString(int32_t(_value)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-label", "value", display + " %"); } void appl::widget::UpBar::onCallbackHide(const float& _value) { if (_value == 0.0f) { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "hide", etk::to_string(true)); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-image", "hide", etk::to_string(true)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-label", "hide", etk::toString(true)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-image", "hide", etk::toString(true)); } else { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-label", "hide", etk::to_string(false)); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-image", "hide", etk::to_string(false)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-label", "hide", etk::toString(false)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-image", "hide", etk::toString(false)); } } @@ -96,7 +96,7 @@ void appl::widget::UpBar::onChangePropertyType() { } void appl::widget::UpBar::onChangePropertyValue() { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-upbar-range", "value", etk::to_string(*propertyValue)); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-upbar-range", "value", etk::toString(*propertyValue)); if (*propertyType == "volume") { onCallbackVolumeRequest(*propertyValue); } else { diff --git a/tools/player-video/appl/widget/UpBar.hpp b/tools/player-video/appl/widget/UpBar.hpp index 8962d67..05176d7 100644 --- a/tools/player-video/appl/widget/UpBar.hpp +++ b/tools/player-video/appl/widget/UpBar.hpp @@ -20,7 +20,7 @@ namespace appl { using UpBarWeak = ememory::WeakPtr; class UpBar : public ewol::widget::Composer { public: // properties - eproperty::Value propertyType; //!< Type of the bar + eproperty::Value propertyType; //!< Type of the bar eproperty::Value propertyValue; //!< value of the bar ... public: // signals esignal::Signal signalChange; //!< Value of the bar diff --git a/tools/player-video/appl/widget/VideoPlayer.cpp b/tools/player-video/appl/widget/VideoPlayer.cpp index 88eec00..9f8da1d 100644 --- a/tools/player-video/appl/widget/VideoPlayer.cpp +++ b/tools/player-video/appl/widget/VideoPlayer.cpp @@ -54,6 +54,9 @@ void appl::widget::VideoDisplay::init() { } // All time need to configure in RGB, By default it is in RGBA ... m_resource[iii]->get().configure(ivec2(128,128), egami::colorType::RGB8); + // Configure to use the minimum of CPU + m_resource[iii]->setRepeat(false); + m_resource[iii]->setFilterMode(ewol::resource::TextureFilter::nearest); } } // Create the River manager for tha application or part of the application. @@ -77,7 +80,7 @@ void appl::widget::VideoDisplay::loadProgram() { m_GLtexID = m_GLprogram->getUniform("EW_texID"); } } -void appl::widget::VideoDisplay::setFile(const std::string& _filename) { +void appl::widget::VideoDisplay::setFile(const etk::String& _filename) { /* // Stop playing in all case... stop(); @@ -380,7 +383,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) if (m_LastResetCounter > echrono::seconds(1)) { m_LastResetCounter.reset(); signalFps.emit(m_nbFramePushed); - signalOther.emit(std::to_string(m_nbFramePushed) + " " + etk::to_string(m_resource[m_useElement]->get().getSize()) + " " + etk::to_string(m_resource[m_useElement]->get().getGPUSize()) ); + signalOther.emit(etk::toString(m_nbFramePushed) + " " + etk::toString(m_resource[m_useElement]->get().getSize()) + " " + etk::toString(m_resource[m_useElement]->get().getGPUSize()) ); m_nbFramePushed = 0; } if ( getSomething == false diff --git a/tools/player-video/appl/widget/VideoPlayer.hpp b/tools/player-video/appl/widget/VideoPlayer.hpp index 8a47d7b..3b4089d 100644 --- a/tools/player-video/appl/widget/VideoPlayer.hpp +++ b/tools/player-video/appl/widget/VideoPlayer.hpp @@ -25,7 +25,7 @@ namespace appl { namespace widget { class VideoDisplay : public ewol::Widget { public: - esignal::Signal signalOther; + esignal::Signal signalOther; esignal::Signal signalFps; esignal::Signal signalPosition; //!< signal the current duration of the video duration esignal::Signal signalDuration; //!< signal the current duration of the video duration @@ -69,7 +69,7 @@ namespace appl { void onDraw() override; void onRegenerateDisplay() override; public: - void setFile(const std::string& _fileName); + void setFile(const etk::String& _fileName); void setZeusMedia(ememory::SharedPtr _property, uint32_t _mediaId); protected: bool m_isPalying; @@ -94,9 +94,9 @@ namespace appl { return echrono::Duration(0); } void seek(const echrono::Duration& _time); - std::vector> getDownloadPart() { + etk::Vector> getDownloadPart() { if (m_decoder == nullptr) { - return std::vector>(); + return etk::Vector>(); } return m_decoder->getDownloadPart(); } diff --git a/tools/player-video/appl/widget/VolumeBar.cpp b/tools/player-video/appl/widget/VolumeBar.cpp index 5791358..868f85d 100644 --- a/tools/player-video/appl/widget/VolumeBar.cpp +++ b/tools/player-video/appl/widget/VolumeBar.cpp @@ -67,8 +67,8 @@ appl::widget::VolumeBar::~VolumeBar() { void appl::widget::VolumeBar::calculateMinMaxSize() { vec2 minTmp = propertyMinSize->getPixel(); - m_minSize.setValue(std::max(minTmp.x(), 40.0f), - std::max(minTmp.y(), std::max(minTmp.x(), 40.0f)) ); + m_minSize.setValue(etk::max(minTmp.x(), 40.0f), + etk::max(minTmp.y(), etk::max(minTmp.x(), 40.0f)) ); markToRedraw(); } @@ -159,7 +159,7 @@ bool appl::widget::VolumeBar::onEventInput(const ewol::event::Input& _event) { } void appl::widget::VolumeBar::updateValue(float _newValue) { - _newValue = std::max(std::min(_newValue, *propertyMaximum), *propertyMinimum); + _newValue = etk::max(etk::min(_newValue, *propertyMaximum), *propertyMinimum); propertyValue.setDirect(_newValue); markToRedraw(); } diff --git a/tools/player-video/appl/widget/VolumeBar.hpp b/tools/player-video/appl/widget/VolumeBar.hpp index 69e2ed3..1220ab7 100644 --- a/tools/player-video/appl/widget/VolumeBar.hpp +++ b/tools/player-video/appl/widget/VolumeBar.hpp @@ -27,7 +27,7 @@ namespace appl { esignal::Signal signalChange; esignal::Signal signalHide; //!< Hide value [0..1] ==> 0 is hidden public: - //eproperty::Value propertyShape; //!< name of the shape used + //eproperty::Value propertyShape; //!< name of the shape used eproperty::Value propertyValue; //!< current value of the VolumeBar eproperty::Value propertyStep; //!< Up and down step value eproperty::Value propertyMinimum; //!< minimum value of the VolumeBar @@ -65,9 +65,9 @@ namespace appl { void onRegenerateDisplay() override; bool onEventInput(const ewol::event::Input& _event) override; private: - std::vector> m_listAvaillable; + etk::Vector> m_listAvaillable; public: - void setRangeAvaillable(std::vector>& _values) { + void setRangeAvaillable(etk::Vector>& _values) { m_listAvaillable = _values; } protected: diff --git a/tools/player-video/lutin_zeus-player-video.py b/tools/player-video/lutin_zeus-player-video.py index 8d47385..6d9841c 100644 --- a/tools/player-video/lutin_zeus-player-video.py +++ b/tools/player-video/lutin_zeus-player-video.py @@ -52,11 +52,16 @@ def configure(target, my_module): ]) my_module.add_flag('c++', [ "-DPROJECT_NAME=\"\\\""+ my_module.get_name()+"\\\"\"", - "-DAPPL_VERSION=\"\\\"" + tools.version_to_string(my_module.get_version()) + "\\\"\"", + "-DAPPL_VERSION=\"\\\"" + tools.version_toString(my_module.get_version()) + "\\\"\"", "-Wno-deprecated-declarations" ]) my_module.copy_path('data/*') my_module.add_path(".") + if "MacOs" in target.get_type(): + pass#my_module.set_pkg("ICON", "data/icon.icns") + else: + my_module.set_pkg("ICON", "data/icon.png") + my_module.add_pkg("RIGHT", "SET_ORIENTATION") my_module.add_pkg("RIGHT", "VIBRATE") diff --git a/tools/router/appl/ClientInterface.cpp b/tools/router/appl/ClientInterface.cpp index 3aa2352..4d9b159 100644 --- a/tools/router/appl/ClientInterface.cpp +++ b/tools/router/appl/ClientInterface.cpp @@ -13,11 +13,11 @@ #include -static const std::string protocolError = "PROTOCOL-ERROR"; +static const etk::String protocolError = "PROTOCOL-ERROR"; appl::ClientInterface::ClientInterface(enet::Tcp _connection, appl::Router* _routerInterface) : m_routerInterface(_routerInterface), - m_interfaceClient(std::move(_connection), true), + m_interfaceClient(etk::move(_connection), true), m_uid(0) { APPL_INFO("----------------"); APPL_INFO("-- NEW Client --"); @@ -32,19 +32,19 @@ appl::ClientInterface::~ClientInterface() { APPL_INFO("-------------------"); } -bool appl::ClientInterface::requestURI(const std::string& _uri) { +bool appl::ClientInterface::requestURI(const etk::String& _uri) { APPL_WARNING("request connect on CLIENT: '" << _uri << "'"); if(m_routerInterface == nullptr) { APPL_ERROR("Can not access to the main GateWay interface (nullptr)"); return false; } - std::string tmpURI = _uri; + etk::String tmpURI = _uri; if (tmpURI.size() == 0) { APPL_ERROR("Empty URI ... not supported ..."); return false; } if (tmpURI[0] == '/') { - tmpURI = std::string(tmpURI.begin() + 1, tmpURI.end()); + tmpURI = etk::String(tmpURI.begin() + 1, tmpURI.end()); } // TODO : Remove subParameters xxx?YYY m_userGateWay = m_routerInterface->get(tmpURI); @@ -87,7 +87,7 @@ bool appl::ClientInterface::isAlive() { return ret; } -void appl::ClientInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { +void appl::ClientInterface::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) { m_interfaceClient.answerError(_transactionId, 0, 0, protocolError, _errorHelp); m_interfaceClient.disconnect(true); } @@ -106,7 +106,7 @@ void appl::ClientInterface::onClientData(ememory::SharedPtr _valu } // check correct SourceID if (_value->getSourceId() != m_uid) { - answerProtocolError(transactionId, "message with the wrong source ID : " + etk::to_string(_value->getSourceId()) + " != " + etk::to_string(m_uid)); + answerProtocolError(transactionId, "message with the wrong source ID : " + etk::toString(_value->getSourceId()) + " != " + etk::toString(m_uid)); return; } // Check gateway corectly connected @@ -133,7 +133,7 @@ void appl::ClientInterface::onClientData(ememory::SharedPtr _valu answerProtocolError(transactionId, "Can not get the Client ID..."); return; } - m_interfaceClient.setInterfaceName("cli-" + etk::to_string(m_uid)); + m_interfaceClient.setInterfaceName("cli-" + etk::toString(m_uid)); m_interfaceClient.answerValue(transactionId, _value->getDestination(), _value->getSource(), m_uid); } else { // send data to the gateway diff --git a/tools/router/appl/ClientInterface.hpp b/tools/router/appl/ClientInterface.hpp index 69ffb51..5e42581 100644 --- a/tools/router/appl/ClientInterface.hpp +++ b/tools/router/appl/ClientInterface.hpp @@ -17,7 +17,7 @@ namespace appl { private: appl::Router* m_routerInterface; zeus::WebServer m_interfaceClient; - bool requestURI(const std::string& _uri); + bool requestURI(const etk::String& _uri); public: ememory::SharedPtr m_userGateWay; uint16_t m_uid; //!< gateway unique ID ==> to have an internal routage ... @@ -36,7 +36,7 @@ namespace appl { } bool isAlive(); - void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); }; diff --git a/tools/router/appl/GateWayInterface.cpp b/tools/router/appl/GateWayInterface.cpp index 80ae9a6..9d4b3fe 100644 --- a/tools/router/appl/GateWayInterface.cpp +++ b/tools/router/appl/GateWayInterface.cpp @@ -10,13 +10,13 @@ #include // todo : cHANGE THIS ... -static const std::string protocolError = "PROTOCOL-ERROR"; +static const etk::String protocolError = "PROTOCOL-ERROR"; appl::GateWayInterface::GateWayInterface(enet::Tcp _connection, appl::Router* _routerInterface) : m_routerInterface(_routerInterface), - m_interfaceClient(std::move(_connection), true), + m_interfaceClient(etk::move(_connection), true), m_lastSourceID(0x8000) { ZEUS_INFO("-----------------"); ZEUS_INFO("-- NEW GateWay --"); @@ -35,19 +35,19 @@ bool appl::GateWayInterface::isAlive() { return m_interfaceClient.isActive(); } -bool appl::GateWayInterface::requestURI(const std::string& _uri) { +bool appl::GateWayInterface::requestURI(const etk::String& _uri) { ZEUS_INFO("request connect on User - GateWay: '" << _uri << "'"); if(m_routerInterface == nullptr) { ZEUS_ERROR("Can not access to the main GateWay interface (nullptr)"); return false; } - std::string tmpURI = _uri; + etk::String tmpURI = _uri; if (tmpURI.size() == 0) { ZEUS_ERROR("Empty URI ... not supported ..."); return false; } if (tmpURI[0] == '/') { - tmpURI = std::string(tmpURI.begin() + 1, tmpURI.end()); + tmpURI = etk::String(tmpURI.begin() + 1, tmpURI.end()); } // TODO : Remove subParameters xxx?YYY // check if the USER is already connected: @@ -78,7 +78,7 @@ void appl::GateWayInterface::send(ememory::SharedPtr _data) { } uint16_t appl::GateWayInterface::addClient(ememory::SharedPtr _value) { - m_clientConnected.push_back(_value); + m_clientConnected.pushBack(_value); return m_lastSourceID++; } @@ -106,14 +106,14 @@ void appl::GateWayInterface::onServiceData(ememory::SharedPtr _va uint32_t transactionId = _value->getTransactionId(); if (_value->getType() == zeus::message::type::call) { ememory::SharedPtr callObj = ememory::staticPointerCast(_value); - std::string callFunction = callObj->getCall(); + etk::String callFunction = callObj->getCall(); if (callFunction == "connect-service") { if (m_name != "") { - ZEUS_WARNING("Service interface ==> try change the servie name after init: '" << callObj->getParameter(0)); + ZEUS_WARNING("Service interface ==> try change the servie name after init: '" << callObj->getParameter(0)); m_interfaceClient.answerValue(transactionId, _value->getDestination(), _value->getSource(), false); return; } - m_name = callObj->getParameter(0); + m_name = callObj->getParameter(0); m_interfaceClient.setInterfaceName("srv-" + m_name); m_interfaceClient.answerValue(transactionId, _value->getDestination(), _value->getSource(), true); return; @@ -129,11 +129,11 @@ void appl::GateWayInterface::onServiceData(ememory::SharedPtr _va return; } } - m_interfaceClient.answerError(_value->getTransactionId(), _value->getDestination(), _value->getSource(), "UNKNOW-DESTINATION", "the Id=" + etk::to_string(destinationId) + " is unknow"); + m_interfaceClient.answerError(_value->getTransactionId(), _value->getDestination(), _value->getSource(), "UNKNOW-DESTINATION", "the Id=" + etk::toString(destinationId) + " is unknow"); } -void appl::GateWayInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { +void appl::GateWayInterface::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) { m_interfaceClient.answerError(_transactionId, 0, 0, protocolError, _errorHelp); m_interfaceClient.disconnect(true); } diff --git a/tools/router/appl/GateWayInterface.hpp b/tools/router/appl/GateWayInterface.hpp index baae5ca..fd66876 100644 --- a/tools/router/appl/GateWayInterface.hpp +++ b/tools/router/appl/GateWayInterface.hpp @@ -16,9 +16,9 @@ namespace appl { appl::Router* m_routerInterface; zeus::WebServer m_interfaceClient; uint16_t m_lastSourceID; //!< The source dynbamic generated ID is manage in 2 part the value <= 0x7FFF is used by the gateway and the value >= 0x8000 is manage by the router - std::vector> m_clientConnected; - std::string m_name; - bool requestURI(const std::string& _uri); + etk::Vector> m_clientConnected; + etk::String m_name; + bool requestURI(const etk::String& _uri); public: GateWayInterface(enet::Tcp _connection, appl::Router* _routerInterface); virtual ~GateWayInterface(); @@ -30,12 +30,12 @@ namespace appl { uint16_t addClient(ememory::SharedPtr _value); void rmClient(ememory::SharedPtr _value); void send(ememory::SharedPtr _data); - const std::string& getName() { + const etk::String& getName() { return m_name; } bool isAlive(); protected: - void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); }; } diff --git a/tools/router/appl/Router.cpp b/tools/router/appl/Router.cpp index 6332361..6a6b788 100644 --- a/tools/router/appl/Router.cpp +++ b/tools/router/appl/Router.cpp @@ -9,16 +9,16 @@ #include #include -static std::string g_pathDBName = "USERDATA:router-database.json"; +static etk::String g_pathDBName = "USERDATA:router-database.json"; class UserAvaillable { public: - std::string m_name; - std::string m_basePath; + etk::String m_name; + etk::String m_basePath; bool m_accessMediaCenter; FILE* m_subProcess; }; -std::vector g_listUserAvaillable; +etk::Vector g_listUserAvaillable; bool g_needToStore = false; static void store_db() { @@ -56,7 +56,7 @@ static void load_db() { userProperty.m_basePath = userElement["path"].toString().get(); userProperty.m_accessMediaCenter = userElement["access-media-center"].toBoolean().get(); APPL_INFO("find USER: '" << userProperty.m_name << "'"); - g_listUserAvaillable.push_back(userProperty); + g_listUserAvaillable.pushBack(userProperty); } g_needToStore = false; } @@ -79,7 +79,7 @@ namespace appl { } virtual ~TcpServerInput() {} - void start(const std::string& _host, uint16_t _port) { + void start(const etk::String& _host, uint16_t _port) { m_interface.setHostNane(_host); m_interface.setPort(_port); m_interface.link(); @@ -106,12 +106,12 @@ namespace appl { // get datas: while (m_threadRunning == true) { // READ section data: - enet::Tcp data = std::move(m_interface.waitNext()); + enet::Tcp data = etk::move(m_interface.waitNext()); ZEUS_VERBOSE("New connection"); if (m_service == true) { - m_router->newClientGateWay(std::move(data)); + m_router->newClientGateWay(etk::move(data)); } else { - m_router->newClient(std::move(data)); + m_router->newClient(etk::move(data)); } } } @@ -120,16 +120,16 @@ namespace appl { void appl::Router::newClientGateWay(enet::Tcp _connection) { ZEUS_WARNING("New TCP connection (service)"); - ememory::SharedPtr tmp = ememory::makeShared(std::move(_connection), this); + ememory::SharedPtr tmp = ememory::makeShared(etk::move(_connection), this); tmp->start(); - m_GateWayList.push_back(tmp); + m_GateWayList.pushBack(tmp); } void appl::Router::newClient(enet::Tcp _connection) { ZEUS_WARNING("New TCP connection (client)"); - ememory::SharedPtr tmp = ememory::makeShared(std::move(_connection), this); + ememory::SharedPtr tmp = ememory::makeShared(etk::move(_connection), this); tmp->start(); - m_clientList.push_back(tmp); + m_clientList.pushBack(tmp); } appl::Router::Router() : @@ -161,7 +161,7 @@ void appl::Router::stop() { } -bool appl::Router::userIsConnected(const std::string& _userName) { +bool appl::Router::userIsConnected(const etk::String& _userName) { for (auto &it : m_GateWayList) { if (it == nullptr) { continue; @@ -180,7 +180,7 @@ bool appl::Router::userIsConnected(const std::string& _userName) { #include -ememory::SharedPtr appl::Router::get(const std::string& _userName) { +ememory::SharedPtr appl::Router::get(const etk::String& _userName) { // TODO : Start USer only when needed, not get it all time started... for (auto &it : m_GateWayList) { if (it == nullptr) { @@ -196,7 +196,7 @@ ememory::SharedPtr appl::Router::get(const std::string& if (it.m_name == _userName) { #if 0 // start interface: - std::string cmd = "~/dev/perso/out/Linux_x86_64/debug/staging/clang/zeus-package-base/zeus-package-base.app/bin/zeus-gateway"; + etk::String cmd = "~/dev/perso/out/Linux_x86_64/debug/staging/clang/zeus-package-base/zeus-package-base.app/bin/zeus-gateway"; cmd += " --user=" + it.m_name + " "; cmd += " --srv=user"; cmd += " --srv=picture"; @@ -220,10 +220,10 @@ ememory::SharedPtr appl::Router::get(const std::string& } else { // We're in the child here. APPL_ERROR("Child Execution ..."); - std::string binary = etk::FSNodeGetApplicationPath() + "/zeus-gateway"; - std::string userConf = "--user=" + it.m_name; - std::string basePath = "--base-path=" + it.m_basePath; - std::string logFile; + etk::String binary = etk::FSNodeGetApplicationPath() + "/zeus-gateway"; + etk::String userConf = "--user=" + it.m_name; + etk::String basePath = "--base-path=" + it.m_basePath; + etk::String logFile; if (*propertyStdOut == false) { logFile = it.m_basePath + "/log/gateway.log"; if ( logFile.size() != 0 @@ -231,12 +231,12 @@ ememory::SharedPtr appl::Router::get(const std::string& logFile = etk::FSNodeGetHomePath() + &logFile[1]; } logFile = "--elog-file=" + logFile; - //std::string logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log"; - //std::string logFile = " "; + //etk::String logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log"; + //etk::String logFile = " "; APPL_INFO("New Child log in = " << logFile); } - std::string delay = "--router-delay=" + etk::to_string(*propertyDelayToStop); - //std::string delay = "--router-delay=-1"; + etk::String delay = "--router-delay=" + etk::toString(*propertyDelayToStop); + //etk::String delay = "--router-delay=-1"; APPL_INFO("execute: " << binary << " " << userConf << " --srv=all " << delay << " " << basePath << " " << logFile); int ret = execlp( binary.c_str(), binary.c_str(), // must repeate the binary name to have the name as first argument ... @@ -273,14 +273,14 @@ ememory::SharedPtr appl::Router::get(const std::string& } -std::vector appl::Router::getAllUserName() { - std::vector out; +etk::Vector appl::Router::getAllUserName() { + etk::Vector out; /* for (auto &it : m_GateWayList) { if (it == nullptr) { continue; } - out.push_back(it->getName()); + out.pushBack(it->getName()); } */ return out; diff --git a/tools/router/appl/Router.hpp b/tools/router/appl/Router.hpp index abb0f46..e0e147c 100644 --- a/tools/router/appl/Router.hpp +++ b/tools/router/appl/Router.hpp @@ -15,17 +15,17 @@ namespace appl { private: uint64_t m_clientUID; private: - std::vector> m_GateWayList; //!< List of all service availlable with their specific connection interface - std::vector> m_clientList; //!< List of all Client interface with their own connection + etk::Vector> m_GateWayList; //!< List of all service availlable with their specific connection interface + etk::Vector> m_clientList; //!< List of all Client interface with their own connection ememory::SharedPtr m_interfaceClientServer; ememory::SharedPtr m_interfaceGateWayServer; ejson::Document m_listUser; public: eproperty::Value propertyStdOut; //!< not set the log in the stdout or in the local file - eproperty::Value propertyClientIp; + eproperty::Value propertyClientIp; eproperty::Value propertyClientPort; eproperty::Value propertyClientMax; - eproperty::Value propertyGateWayIp; + eproperty::Value propertyGateWayIp; eproperty::Value propertyGateWayPort; eproperty::Value propertyGateWayMax; eproperty::Value propertyDelayToStop; @@ -35,10 +35,10 @@ namespace appl { void start(); void stop(); // Get a specific user gateway: - ememory::SharedPtr get(const std::string& _userName); - bool userIsConnected(const std::string& _userName); + ememory::SharedPtr get(const etk::String& _userName); + bool userIsConnected(const etk::String& _userName); - std::vector getAllUserName(); + etk::Vector getAllUserName(); void newClientGateWay(enet::Tcp _connection); void newClient(enet::Tcp _connection); void cleanIO(); diff --git a/tools/router/appl/main-router.cpp b/tools/router/appl/main-router.cpp index 43e2436..554d980 100644 --- a/tools/router/appl/main-router.cpp +++ b/tools/router/appl/main-router.cpp @@ -16,28 +16,28 @@ int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); zeus::init(_argc, _argv); - //std::string OUT2 = algue::stringConvert(algue::sha512::encode("jkhlkjhlkjhlkjhlkjhlkjhlkjhiugouuyrtfkvjhbnj,owixhuvkfn r;,dcxwjo ppxicodsn,kwp listElem = etk::split(_login, '~'); + etk::String login; + etk::Vector listElem = etk::split(_login, '~'); if (listElem.size() == 0) { APPL_ERROR("Not enouth element in the login ..."); return; @@ -109,7 +109,7 @@ void appl::ClientProperty::setLogin(std::string _login) { if (listElem.size() == 1) { // connnect on local host ... nothing to do } else { - std::vector listElem2 = etk::split(listElem[1], ':'); + etk::Vector listElem2 = etk::split(listElem[1], ':'); if (listElem2.size() >= 1) { address = listElem2[0]; } @@ -119,8 +119,8 @@ void appl::ClientProperty::setLogin(std::string _login) { } } -std::string appl::ClientProperty::getLogin() { - std::string out = fromUser; +etk::String appl::ClientProperty::getLogin() { + etk::String out = fromUser; bool hasTild = false; if (address != "") { if (hasTild == false) { @@ -135,16 +135,16 @@ std::string appl::ClientProperty::getLogin() { out += "~" ; hasTild = true; } - out += ":" + etk::to_string(port); + out += ":" + etk::toString(port); } return out; } -void appl::ClientProperty::setPassword(std::string _password) { +void appl::ClientProperty::setPassword(etk::String _password) { pass = _password; } -std::string appl::ClientProperty::getPassword() { +etk::String appl::ClientProperty::getPassword() { return pass; } diff --git a/tools/server-remote/appl/ClientProperty.hpp b/tools/server-remote/appl/ClientProperty.hpp index 56757f5..ebe0720 100644 --- a/tools/server-remote/appl/ClientProperty.hpp +++ b/tools/server-remote/appl/ClientProperty.hpp @@ -12,10 +12,10 @@ namespace appl { class ClientProperty { public: - std::string fromUser; - std::string toUser; - std::string pass; - std::string address; + etk::String fromUser; + etk::String toUser; + etk::String pass; + etk::String address; uint16_t port; zeus::Client connection; ClientProperty(); @@ -23,10 +23,10 @@ namespace appl { void disconnect(); ejson::Object toJson(); void fromJson(ejson::Object _obj); - void setLogin(std::string _login); - std::string getLogin(); - void setPassword(std::string _password); - std::string getPassword(); + void setLogin(etk::String _login); + etk::String getLogin(); + void setPassword(etk::String _password); + etk::String getPassword(); }; } diff --git a/tools/server-remote/appl/Main.cpp b/tools/server-remote/appl/Main.cpp index 52ef39e..51b180f 100644 --- a/tools/server-remote/appl/Main.cpp +++ b/tools/server-remote/appl/Main.cpp @@ -27,7 +27,7 @@ namespace appl { void localCreate(ewol::Context& _context) { // parse all the argument of the application for (int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { - std::string tmpppp = _context.getCmd().get(iii); + etk::String tmpppp = _context.getCmd().get(iii); if ( tmpppp == "-h" || tmpppp == "--help") { APPL_INFO(" -h/--help display this help" ); diff --git a/tools/server-remote/appl/Windows.cpp b/tools/server-remote/appl/Windows.cpp index 1632f56..1ebc684 100644 --- a/tools/server-remote/appl/Windows.cpp +++ b/tools/server-remote/appl/Windows.cpp @@ -28,7 +28,7 @@ #include -static std::string g_baseDBName = "USERDATA:config.json"; +static etk::String g_baseDBName = "USERDATA:config.json"; void appl::Windows::store_db() { APPL_DEBUG("Store database [START]"); @@ -98,12 +98,12 @@ void appl::Windows::init() { } -void appl::Windows::onCallbackShortCut(const std::string& _value) { +void appl::Windows::onCallbackShortCut(const etk::String& _value) { APPL_WARNING("Event from ShortCut : " << _value); onCallbackMenuEvent(_value); } -void appl::Windows::onCallbackMenuEvent(const std::string& _value) { +void appl::Windows::onCallbackMenuEvent(const etk::String& _value) { APPL_WARNING("Event from Menu : " << _value); if (_value == "menu:connect") { appl::widget::ConnectionShared tmpWidget = appl::widget::Connection::create(); @@ -167,8 +167,8 @@ void appl::Windows::onCallbackReboot() { } zeus::Future listElem = remoteService.reboot().wait(); if (listElem.hasError() == true) { - popUpWidgetPush(ewol::widget::StdPopUp::create("title", std::string("Error occured"), - "comment", std::string("Reboot can not be done"))); + popUpWidgetPush(ewol::widget::StdPopUp::create("title", etk::String("Error occured"), + "comment", etk::String("Reboot can not be done"))); } } @@ -197,8 +197,8 @@ void appl::Windows::onCallbackShutdown() { } zeus::Future listElem = remoteService.shutdown().wait(); if (listElem.hasError() == true) { - popUpWidgetPush(ewol::widget::StdPopUp::create("title", std::string("Error occured"), - "comment", std::string("Reboot can not be done"))); + popUpWidgetPush(ewol::widget::StdPopUp::create("title", etk::String("Error occured"), + "comment", etk::String("Reboot can not be done"))); } } diff --git a/tools/server-remote/appl/Windows.hpp b/tools/server-remote/appl/Windows.hpp index 4f05706..f4e76c6 100644 --- a/tools/server-remote/appl/Windows.hpp +++ b/tools/server-remote/appl/Windows.hpp @@ -28,8 +28,8 @@ namespace appl { void onCallbackConnectionValidate(const ememory::SharedPtr& _prop); void onCallbackConnectionCancel(); - void onCallbackShortCut(const std::string& _value); - void onCallbackMenuEvent(const std::string& _value); + void onCallbackShortCut(const etk::String& _value); + void onCallbackMenuEvent(const etk::String& _value); }; } diff --git a/tools/server-remote/appl/widget/Connection.cpp b/tools/server-remote/appl/widget/Connection.cpp index d6f2150..79cf85c 100644 --- a/tools/server-remote/appl/widget/Connection.cpp +++ b/tools/server-remote/appl/widget/Connection.cpp @@ -16,8 +16,8 @@ #include #include #include -//#include -#include +//#include +#include #include #include @@ -33,10 +33,10 @@ appl::widget::Connection::Connection() : void appl::widget::Connection::init() { ewol::widget::Composer::init(); loadFromFile("DATA:gui-connection.xml", getId()); - subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue); - subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue); - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate); - subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]cancel-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonCancel); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-login", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryLoginChangeValue); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]connect-password", signalModify, sharedFromThis(), &appl::widget::Connection::onCallbackEntryPasswordChangeValue); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]connect-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonValidate); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]cancel-bt", signalPressed, sharedFromThis(), &appl::widget::Connection::onCallbackButtonCancel); setProperty(nullptr); propertyCanFocus.set(true); } @@ -54,24 +54,24 @@ void appl::widget::Connection::setProperty(ememory::SharedPtrgetLogin(); m_password = m_baseProperty->getPassword(); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-login", "value", m_login); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-password", "value", m_password); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]connect-login", "value", m_login); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]connect-password", "value", m_password); } void appl::widget::Connection::onGetFocus() { // transfert focus on a specific widget... - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]connect-login", "focus", "true"); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]connect-login", "focus", "true"); } appl::widget::Connection::~Connection() { } -void appl::widget::Connection::onCallbackEntryLoginChangeValue(const std::string& _value) { +void appl::widget::Connection::onCallbackEntryLoginChangeValue(const etk::String& _value) { m_login = _value; } -void appl::widget::Connection::onCallbackEntryPasswordChangeValue(const std::string& _value) { +void appl::widget::Connection::onCallbackEntryPasswordChangeValue(const etk::String& _value) { m_password = _value; } diff --git a/tools/server-remote/appl/widget/Connection.hpp b/tools/server-remote/appl/widget/Connection.hpp index 7458237..408fa9e 100644 --- a/tools/server-remote/appl/widget/Connection.hpp +++ b/tools/server-remote/appl/widget/Connection.hpp @@ -64,8 +64,8 @@ namespace appl { esignal::Signal> signalValidate; //!< select file(s) protected: ememory::SharedPtr m_baseProperty; - std::string m_login; - std::string m_password; + etk::String m_login; + etk::String m_password; Connection(); void init() override; public: @@ -73,7 +73,7 @@ namespace appl { virtual ~Connection(); void setProperty(ememory::SharedPtr _baseProperty=nullptr); private: - std::string getCompleateFileName(); + etk::String getCompleateFileName(); void updateCurrentFolder(); public: void onGetFocus() override; @@ -81,8 +81,8 @@ namespace appl { // callback functions: void onCallbackButtonValidate(); void onCallbackButtonCancel(); - void onCallbackEntryLoginChangeValue(const std::string& _value); - void onCallbackEntryPasswordChangeValue(const std::string& _value); + void onCallbackEntryLoginChangeValue(const etk::String& _value); + void onCallbackEntryPasswordChangeValue(const etk::String& _value); }; }; }; diff --git a/tools/server-remote/lutin_zeus-server-remote.py b/tools/server-remote/lutin_zeus-server-remote.py index 0e19a0e..9531813 100644 --- a/tools/server-remote/lutin_zeus-server-remote.py +++ b/tools/server-remote/lutin_zeus-server-remote.py @@ -42,7 +42,7 @@ def configure(target, my_module): ]) my_module.add_flag('c++', [ "-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"", - "-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\"", + "-DAPPL_VERSION=\"\\\"" + tools.version_toString(get_version()) + "\\\"\"", ]) my_module.copy_path('data/*') my_module.add_path(".") diff --git a/tools/service-picture/appl/main-service-picture.cpp b/tools/service-picture/appl/main-service-picture.cpp index e257478..ba97c4a 100644 --- a/tools/service-picture/appl/main-service-picture.cpp +++ b/tools/service-picture/appl/main-service-picture.cpp @@ -25,28 +25,28 @@ #include static std::mutex g_mutex; -static std::string g_basePath; -static std::string g_baseDBName = std::string(SERVICE_NAME) + "-database.json"; +static etk::String g_basePath; +static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; class FileProperty { public: uint64_t m_id; //!< use local reference ID to have faster access on the file ... - std::string m_fileName; // Sha 512 - std::string m_name; - std::string m_mineType; + etk::String m_fileName; // Sha 512 + etk::String m_name; + etk::String m_mineType; echrono::Time m_creationData; - std::map m_metadata; + etk::Map m_metadata; }; -static std::vector m_listFile; +static etk::Vector m_listFile; class Album { public: uint32_t m_id; //!< use local reference ID to have faster access on the file ... uint32_t m_parentId; //!< parent Album ID - std::string m_name; //!< name of the Album - std::string m_description; //!< description of the album - std::vector m_listMedia; //!< List of media in this album + etk::String m_name; //!< name of the Album + etk::String m_description; //!< description of the album + etk::Vector m_listMedia; //!< List of media in this album }; -static std::vector m_listAlbum; +static etk::Vector m_listAlbum; static uint64_t m_lastMaxId = 0; static bool g_needToStore = false; @@ -61,10 +61,10 @@ namespace appl { private: //ememory::SharedPtr& m_client; zeus::ProxyClientProperty m_client; - std::string m_userName; + etk::String m_userName; public: /* - PictureService(ememory::SharedPtr& _client, const std::string& _userName) : + PictureService(ememory::SharedPtr& _client, const etk::String& _userName) : m_client(_client), m_userName(_userName) { APPL_WARNING("New PictureService ... for user: "); @@ -83,12 +83,12 @@ namespace appl { return m_listFile.size(); } - std::vector mediaIdGetRange(uint32_t _start, uint32_t _stop) override { + etk::Vector mediaIdGetRange(uint32_t _start, uint32_t _stop) override { std::unique_lock lock(g_mutex); // TODO : Check right ... - std::vector out; + etk::Vector out; for (size_t iii=_start; iii proper files ... @@ -145,7 +145,7 @@ namespace appl { property.m_name = futName.get(); property.m_mineType = futType.get(); property.m_creationData = echrono::Time::now(); - m_listFile.push_back(property); + m_listFile.pushBack(property); g_needToStore = true; APPL_DEBUG(" filename : " << sha512String); return id; @@ -189,20 +189,20 @@ namespace appl { } } - std::vector mediaMetadataGetKeys(uint32_t _mediaId) override { - std::vector out; + etk::Vector mediaMetadataGetKeys(uint32_t _mediaId) override { + etk::Vector out; for (auto &it : m_listFile) { if (it.m_id == _mediaId) { for (auto &itM : it.m_metadata) { - out.push_back(itM.first); + out.pushBack(itM.first); } return out; } } throw std::invalid_argument("Wrong Album ID ..."); } - std::string mediaMetadataGetKey(uint32_t _mediaId, std::string _key) override { - std::vector out; + etk::String mediaMetadataGetKey(uint32_t _mediaId, etk::String _key) override { + etk::Vector out; for (auto &it : m_listFile) { if (it.m_id == _mediaId) { auto itM = it.m_metadata.find(_key); @@ -214,21 +214,21 @@ namespace appl { } throw std::invalid_argument("Wrong Album ID ..."); } - void mediaMetadataSetKey(uint32_t _mediaId, std::string _key, std::string _value) override { + void mediaMetadataSetKey(uint32_t _mediaId, etk::String _key, etk::String _value) override { for (auto &it : m_listFile) { if (it.m_id == _mediaId) { auto itM = it.m_metadata.find(_key); if (itM != it.m_metadata.end()) { itM->second = _value; } else { - it.m_metadata.insert(std::make_pair(_key, _value)); + it.m_metadata.insert(etk::makePair(_key, _value)); } return; } } throw std::invalid_argument("Wrong Album ID ..."); } - uint32_t albumCreate(std::string _albumName) override { + uint32_t albumCreate(etk::String _albumName) override { std::unique_lock lock(g_mutex); // TODO : Check right ... for (auto &it : m_listAlbum) { @@ -239,7 +239,7 @@ namespace appl { Album album; album.m_id = createUniqueID(); album.m_name = _albumName; - m_listAlbum.push_back(album); + m_listAlbum.pushBack(album); return album.m_id; } @@ -258,15 +258,15 @@ namespace appl { } throw std::invalid_argument("Wrong Album ID ..."); } - std::vector albumGetList() override { + etk::Vector albumGetList() override { std::unique_lock lock(g_mutex); - std::vector out; + etk::Vector out; for (auto &it : m_listAlbum) { - out.push_back(it.m_id); + out.pushBack(it.m_id); } return out; } - std::string albumNameGet(uint32_t _albumId) override { + etk::String albumNameGet(uint32_t _albumId) override { std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { @@ -276,7 +276,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); return ""; } - void albumNameSet(uint32_t _albumId, std::string _albumName) override { + void albumNameSet(uint32_t _albumId, etk::String _albumName) override { std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { @@ -286,7 +286,7 @@ namespace appl { } throw std::invalid_argument("Wrong Album ID ..."); } - std::string albumDescriptionGet(uint32_t _albumId) override { + etk::String albumDescriptionGet(uint32_t _albumId) override { std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { @@ -296,7 +296,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); return ""; } - void albumDescriptionSet(uint32_t _albumId, std::string _desc) override { + void albumDescriptionSet(uint32_t _albumId, etk::String _desc) override { std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { @@ -316,7 +316,7 @@ namespace appl { return; } } - it.m_listMedia.push_back(_mediaId); + it.m_listMedia.pushBack(_mediaId); return; } } @@ -351,16 +351,16 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); return 0; } - std::vector albumMediaIdGet(uint32_t _albumId, uint32_t _start, uint32_t _stop) override { + etk::Vector albumMediaIdGet(uint32_t _albumId, uint32_t _start, uint32_t _stop) override { std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { - std::vector out; + etk::Vector out; for (size_t iii=_start; iii lock(g_mutex); APPL_WARNING("Load USER: " << g_basePath); diff --git a/tools/service-user/appl/main-service-user.cpp b/tools/service-user/appl/main-service-user.cpp index 2b65479..92da11e 100644 --- a/tools/service-user/appl/main-service-user.cpp +++ b/tools/service-user/appl/main-service-user.cpp @@ -19,18 +19,18 @@ #include static std::mutex g_mutex; -static std::string g_basePath; -static std::string g_baseDBName = std::string(SERVICE_NAME) + "-database.json"; +static etk::String g_basePath; +static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; static ejson::Document g_database; namespace appl { class SystemService : public zeus::service::User { private: zeus::ProxyClientProperty m_client; - std::string m_userName; + etk::String m_userName; public: /* - SystemService(ememory::SharedPtr _client, const std::string& _userName) : + SystemService(ememory::SharedPtr _client, const etk::String& _userName) : m_client(_client), m_userName(_userName) { APPL_WARNING("New SystemService ... for user: "); @@ -43,9 +43,9 @@ namespace appl { APPL_WARNING("Delete service-user interface."); } public: - std::vector clientGroupsGet(std::string _clientName) { + etk::Vector clientGroupsGet(etk::String _clientName) { APPL_WARNING("call clientGroupsGet : " << _clientName); - std::vector out; + etk::Vector out; /* if (m_client == nullptr) { return out; @@ -55,7 +55,7 @@ namespace appl { /* if (m_client.getName().get() != "") { std::unique_lock lock(g_mutex); - std::vector out; + etk::Vector out; ejson::Object clients = g_database["client"].toObject(); if (clients.exist() == false) { // Section never created @@ -67,22 +67,22 @@ namespace appl { return out; } if (client["tocken"].toString().get() != "") { - out.push_back("connected"); + out.pushBack("connected"); } // TODO: check banishing ... ejson::Array groups = client["group"].toArray(); for (auto it : groups) { - out.push_back(it.toString().get()); + out.pushBack(it.toString().get()); } } */ // TODO: Check default visibility ... (if user want to have default visibility at Noone ==> then public must be removed... if (true) { - out.push_back("public"); + out.pushBack("public"); } return out; } - bool checkTocken(std::string _clientName, std::string _tocken) { + bool checkTocken(etk::String _clientName, etk::String _tocken) { std::unique_lock lock(g_mutex); APPL_INFO("Check TOCKEN for : '" << _clientName << "' tocken='" << _clientName << "'"); ejson::Object clients = g_database["client"].toObject(); @@ -99,7 +99,7 @@ namespace appl { } // TODO: check banishing ... // TODO: Do it better ... - std::string registerTocken = client["tocken"].toString().get(); + etk::String registerTocken = client["tocken"].toString().get(); if (registerTocken == _tocken) { APPL_INFO(" ==> return true"); return true; @@ -107,10 +107,10 @@ namespace appl { APPL_INFO(" ==> return false"); return false; } - bool checkAuth(std::string _password) { + bool checkAuth(etk::String _password) { std::unique_lock lock(g_mutex); APPL_INFO("Check AUTH for : '" << _password << "'"); - std::string pass = g_database["password"].toString().get(); + etk::String pass = g_database["password"].toString().get(); if (pass == "") { // pb password return false; @@ -120,7 +120,7 @@ namespace appl { } return false; } - std::vector filterClientServices(std::string _clientName, std::vector _currentList) { + etk::Vector filterClientServices(etk::String _clientName, etk::Vector _currentList) { std::unique_lock lock(g_mutex); APPL_INFO("Filter services : '" << _clientName << "' " << _currentList); // When connected to our session ==> we have no control access ... @@ -128,14 +128,14 @@ namespace appl { APPL_INFO(" return all"); return _currentList; } - std::vector out; + etk::Vector out; APPL_TODO("Filter service list ==> not implemented..."); return out; } }; } -ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], std::string _basePath) { +ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) { g_basePath = _basePath; std::unique_lock lock(g_mutex); APPL_WARNING("Load USER: " << g_basePath); diff --git a/tools/service-video/appl/main-service-video.cpp b/tools/service-video/appl/main-service-video.cpp index 0623b4a..692c818 100644 --- a/tools/service-video/appl/main-service-video.cpp +++ b/tools/service-video/appl/main-service-video.cpp @@ -26,12 +26,12 @@ #include static std::mutex g_mutex; -static std::string g_basePath; -static std::string g_basePathCover; -static std::string g_basePathCoverGroup; -static std::string g_baseDBName = std::string(SERVICE_NAME) + "-database.json"; +static etk::String g_basePath; +static etk::String g_basePathCover; +static etk::String g_basePathCoverGroup; +static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; -static std::vector> m_listFile; +static etk::Vector> m_listFile; static uint64_t m_lastMaxId = 0; static uint64_t m_lastMaxImportId = 0; @@ -47,8 +47,8 @@ static uint64_t createUniqueImportID() { return m_lastMaxImportId; } -static std::string removeSpaceOutQuote(const std::string& _in) { - std::string out; +static etk::String removeSpaceOutQuote(const etk::String& _in) { + etk::String out; bool insideQuote = false; for (auto &it : _in) { if (it == '\'') { @@ -68,10 +68,10 @@ static std::string removeSpaceOutQuote(const std::string& _in) { return out; } -static std::vector splitAction(const std::string& _in) { - std::vector out; +static etk::Vector splitAction(const etk::String& _in) { + etk::Vector out; bool insideQuote = false; - std::string value; + etk::String value; for (auto &it : _in) { if (it == '\'') { if (insideQuote == false) { @@ -80,7 +80,7 @@ static std::vector splitAction(const std::string& _in) { insideQuote = false; } if (value != "") { - out.push_back(value); + out.pushBack(value); value.clear(); } } else { @@ -88,20 +88,20 @@ static std::vector splitAction(const std::string& _in) { } } if (value != "") { - out.push_back(value); + out.pushBack(value); } return out; } -static void metadataChange(zeus::MediaImpl* _element, const std::string& _key) { +static void metadataChange(zeus::MediaImpl* _element, const etk::String& _key) { g_needToStore = true; // meta_data have chage ==> we need to upfdate the path of the file where the data is stored ... if (_element == nullptr) { return; } _element->forceUpdateDecoratedName(); - std::string current = _element->getFileName(); - std::string next = _element->getDecoratedName() + "_" + _element->getSha512(); + etk::String current = _element->getFileName(); + etk::String next = _element->getDecoratedName() + "_" + _element->getSha512(); if (next == current) { return; } @@ -113,10 +113,10 @@ namespace appl { private: //ememory::SharedPtr& m_client; zeus::ProxyClientProperty m_client; - std::string m_userName; + etk::String m_userName; public: /* - VideoService(ememory::SharedPtr& _client, const std::string& _userName) : + VideoService(ememory::SharedPtr& _client, const etk::String& _userName) : m_client(_client), m_userName(_userName) { APPL_WARNING("New VideoService ... for user: "); @@ -135,19 +135,19 @@ namespace appl { return m_listFile.size(); } - std::vector getIds(uint32_t _start, uint32_t _stop) override { + etk::Vector getIds(uint32_t _start, uint32_t _stop) override { std::unique_lock lock(g_mutex); // TODO : Check right ... - std::vector out; + etk::Vector out; for (size_t iii=_start; iiigetUniqueId()); + out.pushBack(m_listFile[iii]->getUniqueId()); } return out; } - uint32_t getId(std::string _sha512) override { + uint32_t getId(etk::String _sha512) override { std::unique_lock lock(g_mutex); // TODO : Check right ... uint32_t out; @@ -178,10 +178,10 @@ namespace appl { throw std::invalid_argument("Wrong file ID ..."); // } - uint32_t add(zeus::ActionNotification& _notifs, zeus::ProxyFile _dataFile) override { - //_action.setProgress("{\"pourcent\":" + etk::to_string(23.54) + ", \"comment\":\"Start loading file\""); - //_action.setProgress("{\"pourcent\":" + etk::to_string(23.54) + ", \"comment\":\"transfering file\"");; - //_action.setProgress("{\"pourcent\":" + etk::to_string(23.54) + ", \"comment\":\"synchronize meta-data\""); + uint32_t add(zeus::ActionNotification& _notifs, zeus::ProxyFile _dataFile) override { + //_action.setProgress("{\"pourcent\":" + etk::toString(23.54) + ", \"comment\":\"Start loading file\""); + //_action.setProgress("{\"pourcent\":" + etk::toString(23.54) + ", \"comment\":\"transfering file\"");; + //_action.setProgress("{\"pourcent\":" + etk::toString(23.54) + ", \"comment\":\"synchronize meta-data\""); uint64_t id = 0; uint64_t importId = 0; { @@ -195,7 +195,7 @@ namespace appl { auto futName = _dataFile.getName(); // wait the sha1 to check his existance: futRemoteSha512.wait(); - std::string sha512StringRemote = futRemoteSha512.get(); + etk::String sha512StringRemote = futRemoteSha512.get(); { std::unique_lock lock(g_mutex); for (auto &it : m_listFile) { @@ -210,8 +210,8 @@ namespace appl { } } } - std::string tmpFileName = g_basePath + "tmpImport_" + etk::to_string(importId); - std::string sha512String = zeus::storeInFile(_dataFile, tmpFileName); + etk::String tmpFileName = g_basePath + "tmpImport_" + etk::toString(importId); + etk::String sha512String = zeus::storeInFile(_dataFile, tmpFileName); futType.wait(); futName.wait(); // move the file at the good position: @@ -227,7 +227,7 @@ namespace appl { property->setMetadata("sha512", sha512String); property->setMetadata("mime-type", futType.get()); property->setCallbackMetadataChange(&metadataChange); - m_listFile.push_back(property); + m_listFile.pushBack(property); g_needToStore = true; } else { std::unique_lock lock(g_mutex); @@ -235,7 +235,7 @@ namespace appl { ememory::SharedPtr property = ememory::makeShared(id, sha512String, g_basePath); property->setMetadata("sha512", sha512String); property->setCallbackMetadataChange(&metadataChange); - m_listFile.push_back(property); + m_listFile.pushBack(property); g_needToStore = true; } APPL_DEBUG(" filename : " << sha512String); @@ -273,14 +273,14 @@ namespace appl { } } - std::vector> interpreteSQLRequest(const std::string& _sqlLikeRequest) { - std::vector> out; + etk::Vector> interpreteSQLRequest(const etk::String& _sqlLikeRequest) { + etk::Vector> out; if (_sqlLikeRequest != "*") { - std::vector listAnd = etk::split(_sqlLikeRequest, "AND"); + etk::Vector listAnd = etk::split(_sqlLikeRequest, "AND"); APPL_INFO("Find list AND : "); for (auto &it : listAnd) { it = removeSpaceOutQuote(it); - std::vector elements = splitAction(it); + etk::Vector elements = splitAction(it); if (elements.size() != 3) { APPL_ERROR("element : '" + it + "' have wrong spliting " << elements); throw std::invalid_argument("element : \"" + it + "\" have wrong spliting"); @@ -294,14 +294,14 @@ namespace appl { throw std::invalid_argument("action invalid : '" + elements[1] + "' only availlable : [==,!=,<=,>=,<,>]"); } APPL_INFO(" - '" << elements[0] << "' action='" << elements[1] << "' with='" << elements[2] << "'"); - out.push_back(elements); + out.pushBack(elements); } } return out; } - bool isValid(const std::vector>& _listElement, - const std::map& _metadata) { + bool isValid(const etk::Vector>& _listElement, + const etk::Map& _metadata) { for (auto &itCheck : _listElement) { // find matadataValue: auto itM = _metadata.find(itCheck[0]); @@ -338,8 +338,8 @@ namespace appl { return true; } - std::string mapToString(const std::map& _metadata) { - std::string out = "{"; + etk::String mapToString(const etk::Map& _metadata) { + etk::String out = "{"; for (auto &it : _metadata) { out += it.first + ":" + it.second + ","; } @@ -347,13 +347,13 @@ namespace appl { return out; } - std::vector getSQL(std::string _sqlLikeRequest) override { - std::vector out; + etk::Vector getSQL(etk::String _sqlLikeRequest) override { + etk::Vector out; if (_sqlLikeRequest == "") { throw std::invalid_argument("empty request"); } APPL_DEBUG("check : " << _sqlLikeRequest); - std::vector> listAndParsed = interpreteSQLRequest(_sqlLikeRequest); + etk::Vector> listAndParsed = interpreteSQLRequest(_sqlLikeRequest); std::unique_lock lock(g_mutex); for (auto &it : m_listFile) { if (it == nullptr) { @@ -363,18 +363,18 @@ namespace appl { bool isCorrectElement = isValid(listAndParsed, it->getMetadataDirect()); if (isCorrectElement == true) { APPL_DEBUG(" select"); - out.push_back(it->getUniqueId()); + out.pushBack(it->getUniqueId()); } } return out; } - std::vector getMetadataValuesWhere(std::string _keyName, std::string _sqlLikeRequest) override { - std::vector out; + etk::Vector getMetadataValuesWhere(etk::String _keyName, etk::String _sqlLikeRequest) override { + etk::Vector out; if (_sqlLikeRequest == "") { throw std::invalid_argument("empty request"); } - std::vector> listAndParsed = interpreteSQLRequest(_sqlLikeRequest); + etk::Vector> listAndParsed = interpreteSQLRequest(_sqlLikeRequest); std::unique_lock lock(g_mutex); for (auto &it : m_listFile) { if (it == nullptr) { @@ -388,7 +388,7 @@ namespace appl { if (it2 == it->getMetadataDirect().end()) { continue; } - std::string value = it2->second; + etk::String value = it2->second; isCorrectElement = false; for (auto &it2: out) { if (it2 == value) { @@ -397,13 +397,13 @@ namespace appl { } } if (isCorrectElement == false) { - out.push_back(value); + out.pushBack(value); } } return out; } - ememory::SharedPtr internalGetCover(const std::string& _baseName, const std::string& _mediaString, uint32_t _maxSize) { + ememory::SharedPtr internalGetCover(const etk::String& _baseName, const etk::String& _mediaString, uint32_t _maxSize) { if (etk::FSNodeExist(_baseName + _mediaString + ".jpg") == true) { return zeus::File::create(_baseName + _mediaString + ".jpg"); } @@ -413,15 +413,15 @@ namespace appl { throw std::runtime_error("No cover availlable"); } - void internalSetCover(const std::string& _baseName, zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, std::string _mediaString) { + void internalSetCover(const etk::String& _baseName, zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, etk::String _mediaString) { uint64_t importId = 0; { std::unique_lock lock(g_mutex); importId = createUniqueImportID(); } auto futType = _cover.getMineType(); - std::string tmpFileName = g_basePath + "tmpImport_" + etk::to_string(importId); - std::string sha512String = zeus::storeInFile(_cover, tmpFileName); + etk::String tmpFileName = g_basePath + "tmpImport_" + etk::toString(importId); + etk::String sha512String = zeus::storeInFile(_cover, tmpFileName); futType.wait(); if (etk::FSNodeGetSize(tmpFileName) == 0) { APPL_ERROR("try to store an empty file"); @@ -447,18 +447,18 @@ namespace appl { } ememory::SharedPtr getCover(uint32_t _mediaId, uint32_t _maxSize) override { - return internalGetCover(g_basePathCover, etk::to_string(_mediaId), _maxSize); + return internalGetCover(g_basePathCover, etk::toString(_mediaId), _maxSize); } - void setCover(zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, uint32_t _mediaId) override { - return internalSetCover(g_basePathCover, _notifs, _cover, etk::to_string(_mediaId)); + void setCover(zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, uint32_t _mediaId) override { + return internalSetCover(g_basePathCover, _notifs, _cover, etk::toString(_mediaId)); } - ememory::SharedPtr getGroupCover(std::string _groupName, uint32_t _maxSize) override { + ememory::SharedPtr getGroupCover(etk::String _groupName, uint32_t _maxSize) override { return internalGetCover(g_basePathCoverGroup, _groupName, _maxSize); } - void setGroupCover(zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, std::string _groupName) override { + void setGroupCover(zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, etk::String _groupName) override { return internalSetCover(g_basePathCoverGroup, _notifs, _cover, _groupName); } @@ -500,13 +500,13 @@ static void load_db() { APPL_ERROR("Can not access on the file : ... No name "); } else { property->setCallbackMetadataChange(&metadataChange); - m_listFile.push_back(property); + m_listFile.pushBack(property); } } g_needToStore = false; } -ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], std::string _basePath) { +ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) { g_basePath = _basePath; g_basePathCover = _basePath + "/AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover/"; g_basePathCoverGroup = _basePath + "/AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover_group/"; diff --git a/zeus/AbstractFunction.cpp b/zeus/AbstractFunction.cpp index c1b6b65..f80143c 100644 --- a/zeus/AbstractFunction.cpp +++ b/zeus/AbstractFunction.cpp @@ -35,9 +35,9 @@ bool zeus::checkOrderFunctionParameter() { return value; } -const std::string zeus::g_threadKeyTransactionId("zeus-transaction-id"); -const std::string zeus::g_threadKeyTransactionSource("zeus-transaction-source"); -const std::string zeus::g_threadKeyTransactionDestination("zeus-transaction-destination"); +const etk::String zeus::g_threadKeyTransactionId("zeus-transaction-id"); +const etk::String zeus::g_threadKeyTransactionSource("zeus-transaction-source"); +const etk::String zeus::g_threadKeyTransactionDestination("zeus-transaction-destination"); enum zeus::AbstractFunction::type zeus::AbstractFunction::getType() const { @@ -48,36 +48,36 @@ void zeus::AbstractFunction::setType(enum zeus::AbstractFunction::type _type) { m_type = _type; } -const std::string& zeus::AbstractFunction::getName() const { +const etk::String& zeus::AbstractFunction::getName() const { return m_name; } -const std::string& zeus::AbstractFunction::getDescription() const { +const etk::String& zeus::AbstractFunction::getDescription() const { return m_description; } -void zeus::AbstractFunction::setDescription(const std::string& _desc) { +void zeus::AbstractFunction::setDescription(const etk::String& _desc) { m_description = _desc; } -void zeus::AbstractFunction::setParam(int32_t _idParam, const std::string& _name, const std::string& _desc) { +void zeus::AbstractFunction::setParam(int32_t _idParam, const etk::String& _name, const etk::String& _desc) { ZEUS_TODO("not implemented set param ... '" << _name << "'"); } -void zeus::AbstractFunction::addParam(const std::string& _name, const std::string& _desc) { - m_paramsDescription.push_back(std::make_pair(_name, _desc)); +void zeus::AbstractFunction::addParam(const etk::String& _name, const etk::String& _desc) { + m_paramsDescription.pushBack(etk::makePair(_name, _desc)); } -void zeus::AbstractFunction::setReturn(const std::string& _desc) { +void zeus::AbstractFunction::setReturn(const etk::String& _desc) { m_returnDescription = _desc; } -std::string zeus::AbstractFunction::getPrototype() const { - std::string out = getPrototypeReturn(); +etk::String zeus::AbstractFunction::getPrototype() const { + etk::String out = getPrototypeReturn(); out += " "; out += m_name; out += "("; - std::vector tmp = getPrototypeParam(); + etk::Vector tmp = getPrototypeParam(); for (size_t iii=0; iii tmp = getPrototypeParam(); + etk::Vector tmp = getPrototypeParam(); for (size_t iii=0; iii> m_paramsDescription; //!< List of the parameter descriptions. + etk::Vector> m_paramsDescription; //!< List of the parameter descriptions. public: /** * @brief Set the parameter name and description @@ -89,42 +89,42 @@ namespace zeus { * @param[in] _name Name of the parameter * @param[in] _desc Description of the parameter */ - void setParam(int32_t _idParam, const std::string& _name, const std::string& _desc); + void setParam(int32_t _idParam, const etk::String& _name, const etk::String& _desc); /** * @brief Set the parameter name and description of the last parameter not set (increment id every element) * @param[in] _name Name of the parameter * @param[in] _desc Description of the parameter */ - void addParam(const std::string& _name, const std::string& _desc); + void addParam(const etk::String& _name, const etk::String& _desc); protected: - std::string m_returnDescription; //!< Return description of the Function + etk::String m_returnDescription; //!< Return description of the Function public: /** * @brief Set the return description of the Function * @param[in] _desc Description of the return parameter */ - void setReturn(const std::string& _desc); + void setReturn(const etk::String& _desc); public: /** * @brief Get the prototype of the function with the parameter name and type * @return The fucntion like "void maFonction(int32 parameter_1, vector:string parameter_2);" */ - std::string getPrototype() const; + etk::String getPrototype() const; /** * @brief Get the signature of the function * @return The signature of the function: "void(int32,vector:string);" */ - virtual std::string getSignature() const; + virtual etk::String getSignature() const; /** * @brief Get the string of the type of the return value * @return type string of the return value */ - virtual std::string getPrototypeReturn() const = 0; + virtual etk::String getPrototypeReturn() const = 0; /** * @brief Get the list of type of the parameter * @return List of types (zeus singature mode) */ - virtual std::vector getPrototypeParam() const = 0; + virtual etk::Vector getPrototypeParam() const = 0; /** * @brief Execute the function with all parameter properties * @param[in] _interfaceClient Web interface to anser values diff --git a/zeus/AbstractFunctionTypeClass.hpp b/zeus/AbstractFunctionTypeClass.hpp index 9cee0ba..7c2b1c7 100644 --- a/zeus/AbstractFunctionTypeClass.hpp +++ b/zeus/AbstractFunctionTypeClass.hpp @@ -165,17 +165,17 @@ namespace zeus { * @param[in] _name Name of the function * @param[in] _fptr Pointer on the function */ - AbstractActionTypeClass(const std::string& _name, functionType _fptr): + AbstractActionTypeClass(const etk::String& _name, functionType _fptr): AbstractFunction(_name), m_function(_fptr) { } - std::string getPrototypeReturn() const override { + etk::String getPrototypeReturn() const override { return m_returnType.getName(); } - std::vector getPrototypeParam() const override { - std::vector out; + etk::Vector getPrototypeParam() const override { + etk::Vector out; for (size_t iii=0; iiigetNumberParameter() != sizeof...(ZEUS_TYPES)) { ZEUS_ERROR("Wrong number of Parameters ..."); - std::string help = "request "; - help += etk::to_string(_obj->getNumberParameter()); + etk::String help = "request "; + help += etk::toString(_obj->getNumberParameter()); help += " parameters and need "; - help += etk::to_string(sizeof...(ZEUS_TYPES)); + help += etk::toString(sizeof...(ZEUS_TYPES)); help += " parameters. prototype function:"; help += getPrototype(); _interfaceClient->answerError(_obj->getTransactionId(), @@ -217,7 +217,7 @@ namespace zeus { _obj->getDestination(), _obj->getSource(), "WRONG-PARAMETER-TYPE", - std::string("Parameter id ") + etk::to_string(iii) + " not compatible with type: '" + m_paramType[iii].getName() + "'"); + etk::String("Parameter id ") + etk::toString(iii) + " not compatible with type: '" + m_paramType[iii].getName() + "'"); return; } } @@ -299,17 +299,17 @@ namespace zeus { * @param[in] _name Name of the function * @param[in] _fptr Pointer on the function */ - AbstractFunctionTypeClass(const std::string& _name, functionType _fptr): + AbstractFunctionTypeClass(const etk::String& _name, functionType _fptr): AbstractFunction(_name), m_function(_fptr) { } - std::string getPrototypeReturn() const override { + etk::String getPrototypeReturn() const override { return m_returnType.getName(); } - std::vector getPrototypeParam() const override { - std::vector out; + etk::Vector getPrototypeParam() const override { + etk::Vector out; for (size_t iii=0; iiigetNumberParameter() != sizeof...(ZEUS_TYPES)) { ZEUS_ERROR("Wrong number of Parameters ..."); - std::string help = "request "; - help += etk::to_string(_obj->getNumberParameter()); + etk::String help = "request "; + help += etk::toString(_obj->getNumberParameter()); help += " parameters and need "; - help += etk::to_string(sizeof...(ZEUS_TYPES)); + help += etk::toString(sizeof...(ZEUS_TYPES)); help += " parameters. prototype function:"; help += getPrototype(); _interfaceClient->answerError(_obj->getTransactionId(), @@ -351,7 +351,7 @@ namespace zeus { _obj->getDestination(), _obj->getSource(), "WRONG-PARAMETER-TYPE", - std::string("Parameter id ") + etk::to_string(iii) + " not compatible with type: '" + m_paramType[iii].getName() + "'"); + etk::String("Parameter id ") + etk::toString(iii) + " not compatible with type: '" + m_paramType[iii].getName() + "'"); return; } } @@ -436,7 +436,7 @@ namespace zeus { * @return Abstract type of the function */ template - AbstractFunction* createAbstractFunctionClass(const std::string& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(zeus::ActionNotification& _notifs, ZEUS_TYPES...)) { + AbstractFunction* createAbstractFunctionClass(const etk::String& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(zeus::ActionNotification& _notifs, ZEUS_TYPES...)) { return new AbstractActionTypeClass(_name, _fffp); } /** @@ -446,7 +446,7 @@ namespace zeus { * @return Abstract type of the function */ template - AbstractFunction* createAbstractFunctionClass(const std::string& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(ZEUS_TYPES...)) { + AbstractFunction* createAbstractFunctionClass(const etk::String& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(ZEUS_TYPES...)) { return new AbstractFunctionTypeClass(_name, _fffp); } } diff --git a/zeus/AbstractFunctionTypeDirect.hpp b/zeus/AbstractFunctionTypeDirect.hpp index 58a4161..c727018 100644 --- a/zeus/AbstractFunctionTypeDirect.hpp +++ b/zeus/AbstractFunctionTypeDirect.hpp @@ -90,17 +90,17 @@ namespace zeus { * @param[in] _name Name of the function * @param[in] _fptr Pointer on the function */ - AbstractFunctionTypeDirect(const std::string& _name, functionType _fptr): + AbstractFunctionTypeDirect(const etk::String& _name, functionType _fptr): AbstractFunction(_name), m_function(_fptr) { } - std::string getPrototypeReturn() const override { + etk::String getPrototypeReturn() const override { return m_returnType.getName(); } - std::vector getPrototypeParam() const override { - std::vector out; + etk::Vector getPrototypeParam() const override { + etk::Vector out; for (size_t iii=0; iiigetNumberParameter() != sizeof...(ZEUS_TYPES)) { - std::string help = "request "; - help += etk::to_string(_obj->getNumberParameter()); + etk::String help = "request "; + help += etk::toString(_obj->getNumberParameter()); help += " parameters and need "; - help += etk::to_string(sizeof...(ZEUS_TYPES)); + help += etk::toString(sizeof...(ZEUS_TYPES)); help += " parameters. prototype function:"; help += getPrototype(); _interfaceClient->answerError(_obj->getTransactionId(), @@ -136,7 +136,7 @@ namespace zeus { _obj->getDestination(), _obj->getSource(), "WRONG-PARAMETER-TYPE", - std::string("Parameter id ") + etk::to_string(iii) + " not compatible with type: '" + m_paramType[iii].getName() + "'"); + etk::String("Parameter id ") + etk::toString(iii) + " not compatible with type: '" + m_paramType[iii].getName() + "'"); return; } } @@ -215,7 +215,7 @@ namespace zeus { * @return Abstract type of the function */ template - zeus::AbstractFunction* createAbstractFunctionDirect(const std::string& _name, ZEUS_RETURN (*_fffp)(ZEUS_TYPES...)) { + zeus::AbstractFunction* createAbstractFunctionDirect(const etk::String& _name, ZEUS_RETURN (*_fffp)(ZEUS_TYPES...)) { return new AbstractFunctionTypeDirect(_name, _fffp); } } diff --git a/zeus/Client.cpp b/zeus/Client.cpp index 2ecb669..be07e25 100644 --- a/zeus/Client.cpp +++ b/zeus/Client.cpp @@ -8,10 +8,10 @@ #include #include -static const std::string protocolError = "PROTOCOL-ERROR"; +static const etk::String protocolError = "PROTOCOL-ERROR"; -void zeus::Client::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { +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(); ZEUS_TODO("Do this error return ... " << _errorHelp); @@ -57,16 +57,16 @@ void zeus::Client::onClientData(ememory::SharedPtr _value) { // Check if we are the destinated Of this message if (_value->getDestinationId() != m_interfaceWeb->getAddress()) { ZEUS_ERROR("Protocol error ==> Wrong ID of the interface " << _value->getDestinationId() << " != " << m_interfaceWeb->getAddress()); - answerProtocolError(transactionId, "wrong adress: request " + etk::to_string(_value->getDestinationId()) + " have " + etk::to_string(m_interfaceWeb->getAddress())); + answerProtocolError(transactionId, "wrong adress: request " + etk::toString(_value->getDestinationId()) + " have " + etk::toString(m_interfaceWeb->getAddress())); return; } if (_value->getDestinationObjectId() == ZEUS_ID_GATEWAY_OBJECT) { if (_value->getType() == zeus::message::type::call) { ememory::SharedPtr callObj = ememory::staticPointerCast(_value); - std::string callFunction = callObj->getCall(); + etk::String callFunction = callObj->getCall(); if (callFunction == "link") { // link with a specific service: - std::string serviceName = callObj->getParameter(0); + etk::String serviceName = callObj->getParameter(0); for (auto &it : m_listServicesAvaillable) { if (it.first == serviceName) { ZEUS_INFO("find service : " << it.first); @@ -82,7 +82,7 @@ void zeus::Client::onClientData(ememory::SharedPtr _value) { ememory::SharedPtr newService = it.second(this, tmpId, _value->getSourceId()); // TODO : Do it better ... - //m_listProvicedService.push_back(newService); + //m_listProvicedService.pushBack(newService); // Return the Value of the object service .... this is really bad, Maybe add a message type for this... m_interfaceWeb->answerValue(transactionId, _value->getDestination(), _value->getSource(), (uint32_t(m_interfaceWeb->getAddress())<<16)+tmpId); */ @@ -121,7 +121,7 @@ void zeus::Client::onClientData(ememory::SharedPtr _value) { return; } else if (callFunction == "removeInterface") { ZEUS_VERBOSE("Remove Object : " << callObj); - m_interfaceWeb->interfaceRemoved(callObj->getParameter>(0)); + m_interfaceWeb->interfaceRemoved(callObj->getParameter>(0)); return; } answerProtocolError(transactionId, "interact with client, musty only call: link/unlink/movelink/removeInterface"); @@ -135,7 +135,7 @@ void zeus::Client::onClientData(ememory::SharedPtr _value) { ZEUS_ERROR("Get Data On the Communication interface that is not understand ... : " << _value); } -bool zeus::Client::serviceAdd(const std::string& _serviceName, factoryService _factory) { +bool zeus::Client::serviceAdd(const etk::String& _serviceName, factoryService _factory) { // Check if we can provide new service: zeus::Future futValidate = m_interfaceWeb->call(uint32_t(m_interfaceWeb->getAddress())<<16, ZEUS_GATEWAY_ADDRESS, "serviceAdd", _serviceName); futValidate.wait(); // TODO: Set timeout ... @@ -143,11 +143,11 @@ bool zeus::Client::serviceAdd(const std::string& _serviceName, factoryService _f ZEUS_ERROR("Can not provide a new sevice ... '" << futValidate.getErrorType() << "' help:" << futValidate.getErrorHelp()); return false; } - m_listServicesAvaillable.insert(std::make_pair(_serviceName, _factory)); + m_listServicesAvaillable.insert(etk::makePair(_serviceName, _factory)); return true; } -bool zeus::Client::serviceRemove(const std::string& _serviceName) { +bool zeus::Client::serviceRemove(const etk::String& _serviceName) { // Check if we can provide new service: zeus::Future futValidate = m_interfaceWeb->call(uint32_t(m_interfaceWeb->getAddress())<<16, ZEUS_GATEWAY_ADDRESS, "serviceRemove", _serviceName); futValidate.wait(); // TODO: Set timeout ... @@ -159,7 +159,7 @@ bool zeus::Client::serviceRemove(const std::string& _serviceName) { return true; } -zeus::ObjectRemote zeus::Client::getService(const std::string& _name) { +zeus::ObjectRemote zeus::Client::getService(const etk::String& _name) { ZEUS_TODO("Lock here"); auto it = m_listConnectedService.begin(); while (it != m_listConnectedService.end()) { @@ -187,12 +187,12 @@ zeus::Future zeus::Client::getServiceCount() { return call(ZEUS_NO_ID_OBJECT, ZEUS_ID_GATEWAY, "getServiceCount"); } -zeus::Future> zeus::Client::getServiceList() { +zeus::Future> zeus::Client::getServiceList() { return call(ZEUS_NO_ID_OBJECT, ZEUS_ID_GATEWAY, "getServiceList"); } // TODO : This is an active waiting ==> this is bad ... ==> use future, it will be better -bool zeus::Client::waitForService(const std::string& _serviceName, echrono::Duration _delta) { +bool zeus::Client::waitForService(const etk::String& _serviceName, echrono::Duration _delta) { echrono::Steady start = echrono::Steady::now(); while (echrono::Steady::now() - start < _delta) { auto listValues = getServiceList(); @@ -221,10 +221,15 @@ void zeus::Client::onPropertyChangePort(){ } -bool zeus::Client::connectTo(const std::string& _address, echrono::Duration _timeOut) { +bool zeus::Client::connectTo(const etk::String& _address, echrono::Duration _timeOut) { ZEUS_DEBUG("connect [START]"); disconnect(); - enet::Tcp connection = std::move(enet::connectTcpClient(*propertyIp, *propertyPort, 1)); + enet::Tcp connection = etk::move(enet::connectTcpClient(*propertyIp, *propertyPort, 1)); + if (connection.getConnectionStatus() != enet::Tcp::status::link) { + ZEUS_WARNING("Can not connect on the TC interface ..."); + return false; + } + ZEUS_INFO("connect Connection TCP is OK"); m_interfaceWeb = ememory::makeShared(); if (m_interfaceWeb == nullptr) { ZEUS_ERROR("Allocate connection error"); @@ -232,7 +237,7 @@ bool zeus::Client::connectTo(const std::string& _address, echrono::Duration _tim } ZEUS_WARNING("Request connect user " << _address); m_interfaceWeb->connect(this, &zeus::Client::onClientData); - m_interfaceWeb->setInterface(std::move(connection), false, _address); + m_interfaceWeb->setInterface(etk::move(connection), false, _address); m_interfaceWeb->connect(); zeus::Future retIdentify = call(0, ZEUS_ID_GATEWAY, "getAddress").wait(); @@ -280,7 +285,7 @@ bool zeus::Client::connect(echrono::Duration _timeOut) { return retIdentify.get(); } -bool zeus::Client::connect(const std::string& _address, echrono::Duration _timeOut) { +bool zeus::Client::connect(const etk::String& _address, echrono::Duration _timeOut) { m_clientName = _address; bool ret = connectTo(_address, _timeOut); if (ret==false) { @@ -297,7 +302,7 @@ bool zeus::Client::connect(const std::string& _address, echrono::Duration _timeO return retIdentify.get(); } -bool zeus::Client::connect(const std::string& _address, const std::string& _userPassword, echrono::Duration _timeOut) { +bool zeus::Client::connect(const etk::String& _address, const etk::String& _userPassword, echrono::Duration _timeOut) { m_clientName = _address; bool ret = connectTo(_address, _timeOut); if (ret==false) { @@ -314,7 +319,7 @@ bool zeus::Client::connect(const std::string& _address, const std::string& _user return retIdentify.get(); } -bool zeus::Client::connect(const std::string& _address, const std::string& _clientName, const std::string& _clientTocken, echrono::Duration _timeOut) { +bool zeus::Client::connect(const etk::String& _address, const etk::String& _clientName, const etk::String& _clientTocken, echrono::Duration _timeOut) { m_clientName = _clientName; bool ret = connectTo(_address, _timeOut); if (ret==false) { diff --git a/zeus/Client.hpp b/zeus/Client.hpp index 3479bfc..fbeab44 100644 --- a/zeus/Client.hpp +++ b/zeus/Client.hpp @@ -22,19 +22,19 @@ namespace zeus { class Client : public eproperty::Interface { friend class ObjectRemote; public: - eproperty::Value propertyIp; //!< Ip of WebSocket TCP connection + eproperty::Value propertyIp; //!< Ip of WebSocket TCP connection eproperty::Value propertyPort; //!< Port of the WebSocket connection public: - std::string m_clientName; //!< Local client name to generate the local serrvice name if needed (if direct connection ==> no name) + etk::String m_clientName; //!< Local client name to generate the local serrvice name if needed (if direct connection ==> no name) ememory::SharedPtr m_interfaceWeb; //!< Interface on the Websocket interface - std::vector> m_listConnectedService; //!< Connect only one time on each service, not needed more. + etk::Vector> m_listConnectedService; //!< Connect only one time on each service, not needed more. public: /** * @brief answer a protocol error on the websocket ==> this stop the communication * @param[in] _transactionId The tansation ID that have an error * @param[in] _errorHelp Help developper/user to understand where the problem come from. */ - void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); /** * @brief Get the client web interface * @return A shared pointer on the client server @@ -56,7 +56,7 @@ namespace zeus { * @param[in] _address Address of the user: "ABCD.efgh~atria-soft.com:1993" * @param[in] _timeOut duration that we are waiting the server answer */ - bool connectTo(const std::string& _address, echrono::Duration _timeOut = echrono::seconds(1)); + bool connectTo(const etk::String& _address, echrono::Duration _timeOut = echrono::seconds(1)); public: /** * @brief Direct connection on a GateWay No Identification needed, the Port on the Gateway garenty the connection) @@ -69,14 +69,14 @@ namespace zeus { * @param[in] _address Address of the user: "ABCD.efgh~atria-soft.com:1993" * @param[in] _timeOut duration that we are waiting the server answer */ - bool connect(const std::string& _address, echrono::Duration _timeOut = echrono::seconds(1)); + bool connect(const etk::String& _address, echrono::Duration _timeOut = echrono::seconds(1)); /** * @brief Create a client on a specific user in a user mode (connect to your personnal account) * @param[in] _address Address of the user: "ABCD.efgh~atria-soft.com:1993" * @param[in] _userPassword Password of the user * @param[in] _timeOut duration that we are waiting the server answer */ - bool connect(const std::string& _address, const std::string& _userPassword, echrono::Duration _timeOut = echrono::seconds(1)); + bool connect(const etk::String& _address, const etk::String& _userPassword, echrono::Duration _timeOut = echrono::seconds(1)); /** * @brief Create a client on a specific user in a client mode with the tocken associated * @param[in] _address Address of the user: "ABCD.efgh~atria-soft.com:1993" @@ -84,7 +84,7 @@ namespace zeus { * @param[in] * @param[in] _timeOut duration that we are waiting the server answer */ - bool connect(const std::string& _address, const std::string& _clientName, const std::string& _clientTocken, echrono::Duration _timeOut = echrono::seconds(1)); + bool connect(const etk::String& _address, const etk::String& _clientName, const etk::String& _clientTocken, echrono::Duration _timeOut = echrono::seconds(1)); /** * @brief Disconnect of the current interface */ @@ -95,24 +95,24 @@ namespace zeus { * @param[in] _serviceName Name of the service * @return Pointer on an interface of remote service */ - zeus::ObjectRemote getService(const std::string& _serviceName); + zeus::ObjectRemote getService(const etk::String& _serviceName); using factoryService = std::function& _iface, uint32_t _destination)>; //!< call this function anser to the caller the requested Object - std::map m_listServicesAvaillable; //!< list of all factory availlable (to create new services) + etk::Map m_listServicesAvaillable; //!< list of all factory availlable (to create new services) /** * @brief Provide a service with a specific name * @param[in] _serviceName Name of the service * @param[in] _service handle on the service provided * @return true if the service is acepted or false if not */ - bool serviceAdd(const std::string& _serviceName, factoryService _factory); + bool serviceAdd(const etk::String& _serviceName, factoryService _factory); /** * @brief Revmove a service from the list of availlable services * @param[in] _serviceName Name of the service to remove * @return true The service has been removed, false otherwise. */ - bool serviceRemove(const std::string& _serviceName); + bool serviceRemove(const etk::String& _serviceName); private: /** * @brief When receive data from the websocket ... call this ... @@ -129,7 +129,7 @@ namespace zeus { template zeus::FutureBase call(uint16_t _srcObjectId, uint32_t _destination, - const std::string& _functionName, + const etk::String& _functionName, _ARGS&&... _args) { if (m_interfaceWeb == nullptr) { ememory::SharedPtr ret = zeus::message::Answer::create(nullptr); // TODO : This is really a bad case ... @@ -182,7 +182,7 @@ namespace zeus { * @brief Get the whole list of services availlable * @return Future on the list of service (names) */ - zeus::Future> getServiceList(); + zeus::Future> getServiceList(); // TODO : This is an active waiting ==> this is bad ... ==> use future, it will be better /** * @brief Wait for a service wake up (and be availlable) @@ -191,7 +191,7 @@ namespace zeus { * @return true The service is availlable * @return false The service is not availlable. */ - bool waitForService(const std::string& _serviceName, echrono::Duration _delta = echrono::seconds(1)); + bool waitForService(const etk::String& _serviceName, echrono::Duration _delta = echrono::seconds(1)); }; } diff --git a/zeus/Future.cpp b/zeus/Future.cpp index fdecbc8..d945665 100644 --- a/zeus/Future.cpp +++ b/zeus/Future.cpp @@ -144,7 +144,7 @@ namespace zeus { return static_cast(_promise->getRaw().get())->getAnswer(); } template<> - std::string futureGetValue(ememory::SharedPtr& _promise) { + etk::String futureGetValue(ememory::SharedPtr& _promise) { if ( _promise == nullptr || _promise->getRaw() == nullptr) { return ""; @@ -153,11 +153,11 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return ""; } - return static_cast(_promise->getRaw().get())->getAnswer(); + return static_cast(_promise->getRaw().get())->getAnswer(); } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -166,12 +166,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -180,12 +180,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -194,12 +194,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -208,12 +208,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -222,12 +222,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -236,12 +236,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -250,12 +250,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -264,12 +264,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -278,12 +278,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -292,12 +292,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -306,12 +306,12 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> - std::vector futureGetValue>(ememory::SharedPtr& _promise) { - std::vector out; + etk::Vector futureGetValue>(ememory::SharedPtr& _promise) { + etk::Vector out; if ( _promise == nullptr || _promise->getRaw() == nullptr) { return out; @@ -320,7 +320,7 @@ namespace zeus { ZEUS_WARNING("No Return value ..."); return out; } - out = static_cast(_promise->getRaw().get())->getAnswer>(); + out = static_cast(_promise->getRaw().get())->getAnswer>(); return out; } template<> diff --git a/zeus/Future.hpp b/zeus/Future.hpp index 74c9057..d63cb27 100644 --- a/zeus/Future.hpp +++ b/zeus/Future.hpp @@ -124,7 +124,7 @@ namespace zeus { Future& andThen(std::function _callback) { zeus::FutureBase::andThen( [=](zeus::FutureBase _fut) { - return _callback(std::move(zeus::Future(_fut).get())); + return _callback(etk::move(zeus::Future(_fut).get())); }); return *this; } @@ -145,7 +145,7 @@ namespace zeus { * @brief Attach callback on a specific return action (ERROR) * @param[in] _callback Handle on the function to call in case of error on the call (with error parameter (ERROR type, Help string) */ - Future& andElse(std::function _callback) { + Future& andElse(std::function _callback) { zeus::FutureBase::andElse( [=](zeus::FutureBase _fut) { return _callback(_fut.getErrorType(), _fut.getErrorHelp()); @@ -193,7 +193,7 @@ namespace zeus { if (_msg == nullptr) { return; } - _callback(std::move(_msg->getEvent())); + _callback(etk::move(_msg->getEvent())); }); return *this; } @@ -323,7 +323,7 @@ namespace zeus { * @brief Attach callback on a specific return action (ERROR) * @param[in] _callback Handle on the function to call in case of error on the call (with error parameter (ERROR type, Help string) */ - Future& andElse(std::function _callback) { + Future& andElse(std::function _callback) { zeus::FutureBase::andElse( [=](zeus::FutureBase _fut) { return _callback(_fut.getErrorType(), _fut.getErrorHelp()); @@ -358,7 +358,7 @@ namespace zeus { if (_msg == nullptr) { return; } - _callback(std::move(_msg->getEvent())); + _callback(etk::move(_msg->getEvent())); }); return *this; } diff --git a/zeus/FutureBase.cpp b/zeus/FutureBase.cpp index 8050cda..5d0e035 100644 --- a/zeus/FutureBase.cpp +++ b/zeus/FutureBase.cpp @@ -119,14 +119,14 @@ bool zeus::FutureBase::hasError() const { return m_promise->hasError(); } -std::string zeus::FutureBase::getErrorType() const { +etk::String zeus::FutureBase::getErrorType() const { if (m_promise == nullptr) { return "NULL_PTR"; } return m_promise->getErrorType(); } -std::string zeus::FutureBase::getErrorHelp() const { +etk::String zeus::FutureBase::getErrorHelp() const { if (m_promise == nullptr) { return "This is a nullptr future"; } diff --git a/zeus/FutureBase.hpp b/zeus/FutureBase.hpp index cbb4d9c..8c0cdff 100644 --- a/zeus/FutureBase.hpp +++ b/zeus/FutureBase.hpp @@ -110,12 +110,12 @@ namespace zeus { * @brief get type of the error * @return the string of the error type */ - std::string getErrorType() const; + etk::String getErrorType() const; /** * @brief get help of the error * @return the string of the error help */ - std::string getErrorHelp() const; + etk::String getErrorHelp() const; /** * @brief Check if the Futur is a valid data * @return return true if the data is valid diff --git a/zeus/FutureGroup.cpp b/zeus/FutureGroup.cpp index f20bb4a..6994c0e 100644 --- a/zeus/FutureGroup.cpp +++ b/zeus/FutureGroup.cpp @@ -8,7 +8,7 @@ #include void zeus::FutureGroup::add(const zeus::FutureBase& _fut) { - m_listFuture.push_back(_fut); + m_listFuture.pushBack(_fut); } void zeus::FutureGroup::wait() const { diff --git a/zeus/FutureGroup.hpp b/zeus/FutureGroup.hpp index ede6477..c1f132e 100644 --- a/zeus/FutureGroup.hpp +++ b/zeus/FutureGroup.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace zeus { /** @@ -15,7 +15,7 @@ namespace zeus { // TODO : Add the posiboilities to have a andFinished() class FutureGroup { private: - std::vector m_listFuture; //!< List of all Future that we need to wait the end. + etk::Vector m_listFuture; //!< List of all Future that we need to wait the end. public: /** * @brief Add an other Future to wait the end. diff --git a/zeus/Object.cpp b/zeus/Object.cpp index b6e4bff..d02d520 100644 --- a/zeus/Object.cpp +++ b/zeus/Object.cpp @@ -41,7 +41,7 @@ void zeus::Object::receive(ememory::SharedPtr _value) { ememory::SharedPtr callObj = ememory::staticPointerCast(_value); uint32_t source = callObj->getSource(); uint32_t sourceId = callObj->getSourceId(); - std::string callFunction = callObj->getCall(); + etk::String callFunction = callObj->getCall(); if (isFunctionAuthorized(sourceId, callFunction) == true) { callBinary(callFunction, callObj); return; diff --git a/zeus/Object.hpp b/zeus/Object.hpp index 9ba1274..4626d17 100644 --- a/zeus/Object.hpp +++ b/zeus/Object.hpp @@ -53,7 +53,7 @@ namespace zeus { * @param[in] _call Name of the function that is called. * @param[in] _value Message to process. */ - virtual void callBinary(const std::string& _call, ememory::SharedPtr _value) = 0; + virtual void callBinary(const etk::String& _call, ememory::SharedPtr _value) = 0; public: /** * @brief Advertise a new function in the service/object ==> it is force the start with "obj.". @@ -65,7 +65,7 @@ namespace zeus { template - zeus::AbstractFunction* advertise(std::string _name, + zeus::AbstractFunction* advertise(etk::String _name, ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args)) { _name = "obj." + _name; for (auto &it : m_listFunction) { @@ -84,7 +84,7 @@ namespace zeus { } tmp->setType(zeus::AbstractFunction::type::service); ZEUS_VERBOSE("Add function '" << _name << "' in local mode"); - m_listFunction.push_back(tmp); + m_listFunction.pushBack(tmp); return tmp; } }; @@ -114,7 +114,7 @@ namespace zeus { class ZEUS_ACTION_TYPE, class ZEUS_CLASS_TYPE, class... ZEUS_FUNC_ARGS_TYPE> - zeus::AbstractFunction* advertise(const std::string& _name, + zeus::AbstractFunction* advertise(const etk::String& _name, ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(zeus::ActionNotification& _notifs, ZEUS_FUNC_ARGS_TYPE... _args)) { if (etk::start_with(_name, "srv.") == true) { ZEUS_ERROR("Advertise function start with 'srv.' is not permited ==> only allow for internal service: '" << _name << "'"); @@ -136,7 +136,7 @@ namespace zeus { } tmp->setType(zeus::AbstractFunction::type::object); ZEUS_VERBOSE("Add function '" << _name << "' in object mode"); - m_listFunction.push_back(tmp); + m_listFunction.pushBack(tmp); return tmp; } /** @@ -149,7 +149,7 @@ namespace zeus { template - zeus::AbstractFunction* advertise(const std::string& _name, + zeus::AbstractFunction* advertise(const etk::String& _name, ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args)) { if (etk::start_with(_name, "srv.") == true) { ZEUS_ERROR("Advertise function start with 'srv.' is not permited ==> only allow for internal service: '" << _name << "'"); @@ -171,10 +171,10 @@ namespace zeus { } tmp->setType(zeus::AbstractFunction::type::object); ZEUS_VERBOSE("Add function '" << _name << "' in object mode"); - m_listFunction.push_back(tmp); + m_listFunction.pushBack(tmp); return tmp; } - bool isFunctionAuthorized(uint64_t _clientId, const std::string& _funcName) override { + bool isFunctionAuthorized(uint64_t _clientId, const etk::String& _funcName) override { /* auto it = m_interface.find(_clientId); if (it == m_interface.end()) { @@ -185,7 +185,7 @@ namespace zeus { */ return true; } - void callBinary(const std::string& _call, ememory::SharedPtr _value) override { + void callBinary(const etk::String& _call, ememory::SharedPtr _value) override { for (auto &it2 : m_listFunction) { if (it2 == nullptr) { continue; diff --git a/zeus/ObjectIntrospect.cpp b/zeus/ObjectIntrospect.cpp index ca96d31..eac9bc1 100644 --- a/zeus/ObjectIntrospect.cpp +++ b/zeus/ObjectIntrospect.cpp @@ -11,31 +11,31 @@ zeus::ObjectIntrospect::ObjectIntrospect(zeus::ObjectRemote& _obj): } -zeus::Future zeus::ObjectIntrospect::getDescription() { +zeus::Future zeus::ObjectIntrospect::getDescription() { return m_obj.call("sys.getDescription"); } -zeus::Future zeus::ObjectIntrospect::getVersion() { +zeus::Future zeus::ObjectIntrospect::getVersion() { return m_obj.call("sys.getVersion"); } -zeus::Future zeus::ObjectIntrospect::getType() { +zeus::Future zeus::ObjectIntrospect::getType() { return m_obj.call("sys.getType"); } -zeus::Future> zeus::ObjectIntrospect::getAuthors() { +zeus::Future> zeus::ObjectIntrospect::getAuthors() { return m_obj.call("sys.getAuthors"); } -zeus::Future> zeus::ObjectIntrospect::getFunctions() { +zeus::Future> zeus::ObjectIntrospect::getFunctions() { return m_obj.call("sys.getFunctions"); } -zeus::Future zeus::ObjectIntrospect::getFunctionPrototype(std::string _functionName) { +zeus::Future zeus::ObjectIntrospect::getFunctionPrototype(etk::String _functionName) { return m_obj.call("sys.getFunctionPrototype", _functionName); } -zeus::Future zeus::ObjectIntrospect::getFunctionDescription(std::string _functionName) { +zeus::Future zeus::ObjectIntrospect::getFunctionDescription(etk::String _functionName) { return m_obj.call("sys.getFunctionDescription", _functionName); } diff --git a/zeus/ObjectIntrospect.hpp b/zeus/ObjectIntrospect.hpp index ef752f3..9be772d 100644 --- a/zeus/ObjectIntrospect.hpp +++ b/zeus/ObjectIntrospect.hpp @@ -24,38 +24,38 @@ namespace zeus { * @brief Get the service/ object description * @return A future of the description */ - zeus::Future getDescription(); + zeus::Future getDescription(); /** * @brief Get the version of the service/Object * @return A future of the string version */ - zeus::Future getVersion(); + zeus::Future getVersion(); /** * @brief Get the Type of the service/object. ex: VIDEO, PICTURE, FILE * @return A future of the string type */ - zeus::Future getType(); + zeus::Future getType(); /** * @brief get the list of all authors of the objects * @return A future on the list of authors. Format: "NAME surname " */ - zeus::Future> getAuthors(); + zeus::Future> getAuthors(); /** * @brief get all the function names * @return Future on a list of function names */ - zeus::Future> getFunctions(); + zeus::Future> getFunctions(); /** * @brief Get the fonction prototype (same as IDL) * @param[in] _functionName Name of the function * @return a future on the function prototype */ - zeus::Future getFunctionPrototype(std::string _functionName); + zeus::Future getFunctionPrototype(etk::String _functionName); /** * @brief Det a fonction specific description * @param[in] _functionName Name of the function * @return a future on the function description */ - zeus::Future getFunctionDescription(std::string _functionName); + zeus::Future getFunctionDescription(etk::String _functionName); }; } diff --git a/zeus/ObjectRemote.cpp b/zeus/ObjectRemote.cpp index 0b13cdc..f8fc464 100644 --- a/zeus/ObjectRemote.cpp +++ b/zeus/ObjectRemote.cpp @@ -9,7 +9,7 @@ -zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const std::string& _type): +zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const etk::String& _type): zeus::WebObj(_iface, _localId, _localObjectId), m_type(_type), m_remoteAddress(_address), @@ -43,7 +43,7 @@ bool zeus::ObjectRemoteBase::exist() const { return m_isLinked; } -const std::string& zeus::ObjectRemoteBase::getName() const { +const etk::String& zeus::ObjectRemoteBase::getName() const { return m_type; } diff --git a/zeus/ObjectRemote.hpp b/zeus/ObjectRemote.hpp index 6a483bc..d858106 100644 --- a/zeus/ObjectRemote.hpp +++ b/zeus/ObjectRemote.hpp @@ -22,7 +22,7 @@ namespace zeus { class ObjectRemoteBase : public zeus::WebObj { friend class ObjectRemote; private: - std::string m_type; //!< name of the remote object + 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 public: @@ -45,7 +45,7 @@ namespace zeus { uint16_t _localId, uint16_t _localObjectId, uint32_t _address, - const std::string& _type); + const etk::String& _type); /** * @brief Generic destructor */ @@ -60,7 +60,7 @@ namespace zeus { * @brief Get the name of the object (use in client service check name) * @TODO: Remove this API */ - const std::string& getName() const; + const etk::String& getName() const; /** * @brief Get the remote interface ID * @return The Id of the remote interface @@ -109,7 +109,7 @@ namespace zeus { * @return A generic future with all datas */ template - zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) const { + zeus::FutureBase call(const etk::String& _functionName, _ARGS&&... _args) const { if ( m_interface == nullptr || m_interface->m_interfaceWeb == nullptr) { ememory::SharedPtr ret = zeus::message::Answer::create(nullptr); // TODO : This is a real bad case ... @@ -130,7 +130,7 @@ namespace zeus { * @return A generic future with all datas */ template - zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args) const { + zeus::FutureBase callAction(const etk::String& _functionName, _ARGS&&... _args) const { zeus::FutureBase tmp = call(_functionName, _args...); tmp.setAction(); return tmp; diff --git a/zeus/Promise.cpp b/zeus/Promise.cpp index 634b14e..008920c 100644 --- a/zeus/Promise.cpp +++ b/zeus/Promise.cpp @@ -142,7 +142,7 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { callback(ememory::staticPointerCast(_value)); { std::unique_lock lock(m_mutex); - m_callbackEvent = std::move(callback); + m_callbackEvent = etk::move(callback); } return false; // no error } @@ -163,13 +163,13 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { Observer callback; { std::unique_lock lock(m_mutex); - callback = std::move(m_callbackThen); + callback = etk::move(m_callbackThen); } if (callback != nullptr) { bool ret = callback(zeus::FutureBase(sharedFromThis())); { std::unique_lock lock(m_mutex); - m_callbackThen = std::move(callback); + m_callbackThen = etk::move(callback); } return ret; } @@ -183,7 +183,7 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { bool ret = callback(zeus::FutureBase(sharedFromThis())); { std::unique_lock lock(m_mutex); - m_callbackElse = std::move(callback); + m_callbackElse = etk::move(callback); } return ret; } @@ -210,7 +210,7 @@ bool zeus::Promise::hasError() const { return static_cast(m_message.get())->hasError(); } -std::string zeus::Promise::getErrorType() const { +etk::String zeus::Promise::getErrorType() const { std::unique_lock lock(m_mutex); if (m_message == nullptr) { return "NULL_PTR"; @@ -221,7 +221,7 @@ std::string zeus::Promise::getErrorType() const { return static_cast(m_message.get())->getError(); } -std::string zeus::Promise::getErrorHelp() const { +etk::String zeus::Promise::getErrorHelp() const { std::unique_lock lock(m_mutex); if (m_message == nullptr) { return "This is a nullptr future"; diff --git a/zeus/Promise.hpp b/zeus/Promise.hpp index 48443a6..9bf7488 100644 --- a/zeus/Promise.hpp +++ b/zeus/Promise.hpp @@ -112,12 +112,12 @@ namespace zeus { * @brief get type of the error * @return the string of the error type */ - std::string getErrorType() const; + etk::String getErrorType() const; /** * @brief get help of the error * @return the string of the error help */ - std::string getErrorHelp() const; + etk::String getErrorHelp() const; /** * @brief Check if the futur have finish receiving data * @return status of the fisnish state diff --git a/zeus/Raw.hpp b/zeus/Raw.hpp index 631a4a4..9aa10bd 100644 --- a/zeus/Raw.hpp +++ b/zeus/Raw.hpp @@ -15,7 +15,7 @@ namespace zeus { private: uint32_t m_size; //!< Size of the DATA const uint8_t* m_dataExternal; //!< The raw buffer is contituated with ecternal static data - std::vector m_dataInternal; //!< the data is allocated in local. + etk::Vector m_dataInternal; //!< the data is allocated in local. public: /** * @brief generic constructor diff --git a/zeus/RemoteProcessCall.cpp b/zeus/RemoteProcessCall.cpp index 0ae060c..cc7a16d 100644 --- a/zeus/RemoteProcessCall.cpp +++ b/zeus/RemoteProcessCall.cpp @@ -53,47 +53,47 @@ zeus::RemoteProcessCall::RemoteProcessCall(const ememory::SharedPtr>& zeus::RemoteProcessCall::getAuthors() const { +const etk::Vector>& zeus::RemoteProcessCall::getAuthors() const { return m_authors; } -std::vector zeus::RemoteProcessCall::getAuthors2() { - std::vector out; +etk::Vector zeus::RemoteProcessCall::getAuthors2() { + etk::Vector out; for (auto &it : m_authors) { - out.push_back(it.first + "<" + it.second + ">"); + out.pushBack(it.first + "<" + it.second + ">"); } return out; } -zeus::AbstractFunction* zeus::RemoteProcessCall::getFunction(std::string _funcName) { +zeus::AbstractFunction* zeus::RemoteProcessCall::getFunction(etk::String _funcName) { for (auto &it : m_listFunction) { if (it == nullptr) { continue; @@ -106,17 +106,17 @@ zeus::AbstractFunction* zeus::RemoteProcessCall::getFunction(std::string _funcNa return nullptr; } -std::string zeus::RemoteProcessCall::getType() { +etk::String zeus::RemoteProcessCall::getType() { return m_type; } -void zeus::RemoteProcessCall::setType(const std::string& _type) { +void zeus::RemoteProcessCall::setType(const etk::String& _type) { m_type = _type; } -std::vector zeus::RemoteProcessCall::getFunctions() { - std::vector out; +etk::Vector zeus::RemoteProcessCall::getFunctions() { + etk::Vector out; for (auto &it: m_listFunction) { if (it == nullptr) { continue; @@ -126,15 +126,15 @@ std::vector zeus::RemoteProcessCall::getFunctions() { continue; } */ - out.push_back(it->getName()); + out.pushBack(it->getName()); } return out; } -std::vector zeus::RemoteProcessCall::getFunctionSignature(std::string _funcName) { +etk::Vector zeus::RemoteProcessCall::getFunctionSignature(etk::String _funcName) { /* if (isFunctionAuthorized(_funcName) == false) { - return std::vector(); + return etk::Vector(); } */ for (auto &it: m_listFunction) { @@ -144,15 +144,15 @@ std::vector zeus::RemoteProcessCall::getFunctionSignature(std::stri if (it->getName() != _funcName) { continue; } - std::vector out; + etk::Vector out; out = it->getPrototypeParam(); out.insert(out.begin(), it->getPrototypeReturn()); return out; } - return std::vector(); + return etk::Vector(); } -std::string zeus::RemoteProcessCall::getFunctionPrototype(std::string _funcName) { +etk::String zeus::RemoteProcessCall::getFunctionPrototype(etk::String _funcName) { /* if (isFunctionAuthorized(_funcName) == false) { return ""; @@ -170,10 +170,10 @@ std::string zeus::RemoteProcessCall::getFunctionPrototype(std::string _funcName) return ""; } -std::string zeus::RemoteProcessCall::getFunctionDescription(std::string _funcName) { +etk::String zeus::RemoteProcessCall::getFunctionDescription(etk::String _funcName) { /* if (isFunctionAuthorized(_funcName) == false) { - return std::string("UNKNOW Function: ") + _funcName; + return etk::String("UNKNOW Function: ") + _funcName; } */ for (auto &it: m_listFunction) { @@ -189,7 +189,7 @@ std::string zeus::RemoteProcessCall::getFunctionDescription(std::string _funcNam } -bool zeus::RemoteProcessCall::isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName) { +bool zeus::RemoteProcessCall::isFunctionAuthorized(uint64_t _clientSessionID, const etk::String& _funcName) { ZEUS_ERROR("lllllllllllllllllllllllllllllllllllllllllllllllllllllllllll"); return true; } diff --git a/zeus/RemoteProcessCall.hpp b/zeus/RemoteProcessCall.hpp index 32e1ae7..498b5b1 100644 --- a/zeus/RemoteProcessCall.hpp +++ b/zeus/RemoteProcessCall.hpp @@ -25,109 +25,109 @@ namespace zeus { */ RemoteProcessCall(const ememory::SharedPtr& _iface, uint16_t _id, uint16_t _objectId); protected: - std::vector m_listFunction; //!< List of all functions callable + etk::Vector m_listFunction; //!< List of all functions callable protected: - std::string m_description; //!< Description of the service + etk::String m_description; //!< Description of the service public: /** * @brief Set service description * @param[in] _desc String with the describe of the service */ - void setDescription(const std::string& _desc); + void setDescription(const etk::String& _desc); /** * @brief Get service description * @return String with the describe of the service */ - std::string getDescription(); + etk::String getDescription(); protected: - std::string m_version; //!< Version of the service + etk::String m_version; //!< Version of the service public: /** * @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& _vers); + void setVersion(const etk::String& _vers); /** * @brief Get the Version of the service * @return String containing the version (form: 1.0[.x[.y]][-dev] */ - std::string getVersion(); + etk::String getVersion(); protected: - std::string m_versionImplement; //!< Version implementation of the service + etk::String m_versionImplement; //!< Version implementation of the service public: /** * @brief Set the Version implementation of the service * @param[in] _vers String containing the version (form: 1.0[.x[.y]][-dev] */ - void setVersionImplementation(const std::string& _vers); + void setVersionImplementation(const etk::String& _vers); /** * @brief Get the Version implementation of the service * @return String containing the version (form: 1.0[.x[.y]][-dev] */ - std::string getVersionImplementation(); + etk::String getVersionImplementation(); protected: - std::vector> m_authors;//! List of autors of the module (name, email) + etk::Vector> m_authors;//! List of autors of the module (name, email) public: /** * @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); + void addAuthor(const etk::String& _name, const etk::String& _email); /** * @brief Get the list of the Authors * @return Lisl of authors in a pair of name and email */ - const std::vector>& getAuthors() const; + const etk::Vector>& getAuthors() const; /** * @brief Get simple list of authors * @return List Of user and email in form: "john WHO " */ - std::vector getAuthors2(); + etk::Vector getAuthors2(); protected: - std::string m_type; //!< Generic type of the service + etk::String m_type; //!< Generic type of the service public: /** * @brief Get type of this object * @return Type of this object in string */ - std::string getType(); + etk::String getType(); /** * @brief Set the type of this object * @param[in] _type New type of this object */ - void setType(const std::string& _type); + void setType(const etk::String& _type); public: /** * @brief Get list of fucntion aaillable in this object * @return List of function name */ - std::vector getFunctions(); + etk::Vector getFunctions(); /** * @brief Get the AbstractFunction of a function with a specific name * @param[in] _funcName Name of the function * @return Pointer on the function */ - AbstractFunction* getFunction(std::string _funcName); + AbstractFunction* getFunction(etk::String _funcName); private: /** * @brief Get the signature of a function with a specific name * @param[in] _funcName Name of the function * @return IDL function signature */ - std::vector getFunctionSignature(std::string _funcName); + etk::Vector getFunctionSignature(etk::String _funcName); /** * @brief Get the signature of a function with a specific name * @param[in] _funcName Name of the function * @return IDL function prototype */ - std::string getFunctionPrototype(std::string _funcName); + etk::String getFunctionPrototype(etk::String _funcName); /** * @brief Get the descriptyion of a function with a specific name * @param[in] _funcName Name of the function * @return Description of this function */ - std::string getFunctionDescription(std::string _funcName); + etk::String getFunctionDescription(etk::String _funcName); protected: /** * @brief Check if the function is accessible for a specific user @@ -136,7 +136,7 @@ namespace zeus { * @return true The function is authorized * @return false The function is NOT authorized */ - virtual bool isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName); + virtual bool isFunctionAuthorized(uint64_t _clientSessionID, const etk::String& _funcName); public: /** * @brief Advertise a new function in the service/object. @@ -147,7 +147,7 @@ namespace zeus { // Add global fuction (no link with this class) template - zeus::AbstractFunction* advertise(const std::string& _name, + zeus::AbstractFunction* advertise(const etk::String& _name, ZEUS_RETURN_VALUE (*_func)(ZEUS_FUNC_ARGS_TYPE... _args)) { for (auto &it : m_listFunction) { if (it == nullptr) { @@ -165,7 +165,7 @@ namespace zeus { } tmp->setType(zeus::AbstractFunction::type::global); ZEUS_VERBOSE("Add function '" << _name << "' in global mode"); - m_listFunction.push_back(tmp); + m_listFunction.pushBack(tmp); return tmp; } /** @@ -178,7 +178,7 @@ namespace zeus { template - zeus::AbstractFunction* advertise(std::string _name, + zeus::AbstractFunction* advertise(etk::String _name, ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args)) { _name = "sys." + _name; for (auto &it : m_listFunction) { @@ -197,7 +197,7 @@ namespace zeus { } tmp->setType(zeus::AbstractFunction::type::local); ZEUS_VERBOSE("Add function '" << _name << "' in local mode"); - m_listFunction.push_back(tmp); + m_listFunction.pushBack(tmp); return tmp; } }; diff --git a/zeus/RemoteProperty.hpp b/zeus/RemoteProperty.hpp index 952a544..49c5701 100644 --- a/zeus/RemoteProperty.hpp +++ b/zeus/RemoteProperty.hpp @@ -19,12 +19,12 @@ namespace zeus { class RemoteProperty { private: zeus::ObjectRemote& m_remoteObject; //!< Remote ofject interface - std::string m_name; //!< Name of the property to call. + etk::String m_name; //!< Name of the property to call. public: /** * @brief generic constructor */ - RemoteProperty(zeus::ObjectRemote& _remoteObject, const std::string& _name) : + RemoteProperty(zeus::ObjectRemote& _remoteObject, const etk::String& _name) : m_remoteObject(_remoteObject), m_name(_name) { diff --git a/zeus/RemoteSignal.hpp b/zeus/RemoteSignal.hpp index eb9c435..6854b59 100644 --- a/zeus/RemoteSignal.hpp +++ b/zeus/RemoteSignal.hpp @@ -24,7 +24,7 @@ namespace zeus { /** * @brief generic constructor */ - RemoteProperty(zeus::ObjectRemote& _remoteObject, const std::string& _name) : + RemoteProperty(zeus::ObjectRemote& _remoteObject, const etk::String& _name) : esignal::Signal(&zeus::RemoteSignal::countConnection, _name), m_remoteObject(_remoteObject), m_name(_name) { diff --git a/zeus/WebObj.cpp b/zeus/WebObj.cpp index ebb35b8..5a2cf27 100644 --- a/zeus/WebObj.cpp +++ b/zeus/WebObj.cpp @@ -42,7 +42,7 @@ void zeus::WebObj::display() { } void zeus::WebObj::addRemote(uint32_t _id) { - m_listRemoteConnected.push_back(_id); + m_listRemoteConnected.pushBack(_id); } diff --git a/zeus/WebObj.hpp b/zeus/WebObj.hpp index 5f0d6df..3e145b7 100644 --- a/zeus/WebObj.hpp +++ b/zeus/WebObj.hpp @@ -19,7 +19,7 @@ namespace zeus { ememory::SharedPtr m_interfaceWeb; //!< web interface uint16_t m_id; //!< Id Of the local interface uint16_t m_objectId; //!< Local Object Id - std::vector m_listRemoteConnected; //!< Number of service connected + etk::Vector m_listRemoteConnected; //!< Number of service connected public: /** * @brief Contructor diff --git a/zeus/WebServer.cpp b/zeus/WebServer.cpp index c8c5e7d..7c6517f 100644 --- a/zeus/WebServer.cpp +++ b/zeus/WebServer.cpp @@ -15,7 +15,7 @@ ememory::SharedPtr zeus::createBaseCall(const ememory::Shar uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, - const std::string& _functionName) { + const etk::String& _functionName) { ememory::SharedPtr obj; obj = zeus::message::Call::create(_iface); if (obj == nullptr) { @@ -72,19 +72,19 @@ zeus::WebServer::WebServer(enet::Tcp _connection, bool _isServer) : m_threadAsync(nullptr) { m_interfaceId = interfaceId++; m_threadAsyncRunning = false; - setInterface(std::move(_connection), _isServer); + setInterface(etk::move(_connection), _isServer); } -void zeus::WebServer::setInterface(enet::Tcp _connection, bool _isServer, const std::string& _userName) { - m_connection.setInterface(std::move(_connection), _isServer); +void zeus::WebServer::setInterface(enet::Tcp _connection, bool _isServer, const etk::String& _userName) { + m_connection.setInterface(etk::move(_connection), _isServer); m_connection.connect(this, &zeus::WebServer::onReceiveData); if (_isServer == true) { m_connection.connectUri(this, &zeus::WebServer::onReceiveUri); m_connection.start(); } else { - std::vector protocols; - protocols.push_back("zeus/0.8"); - protocols.push_back("zeus/1.0"); + etk::Vector protocols; + protocols.pushBack("zeus/0.8"); + protocols.pushBack("zeus/1.0"); m_connection.start("/" + _userName, protocols); } } @@ -104,21 +104,21 @@ zeus::WebServer::~WebServer() { ZEUS_WARNING("destroy WebServer ... [STOP]"); } -void zeus::WebServer::setInterfaceName(const std::string& _name) { +void zeus::WebServer::setInterfaceName(const etk::String& _name) { //ethread::setName(*m_thread, "Tcp-" + _name); } void zeus::WebServer::addWebObj(ememory::SharedPtr _obj) { //std::unique_lock lock(m_mutex); - m_listObject.push_back(_obj); + m_listObject.pushBack(_obj); } void zeus::WebServer::addWebObjRemote(ememory::SharedPtr _obj) { //std::unique_lock lock(m_mutex); - m_listRemoteObject.push_back(_obj); + m_listRemoteObject.pushBack(_obj); } -void zeus::WebServer::interfaceRemoved(std::vector _list) { +void zeus::WebServer::interfaceRemoved(etk::Vector _list) { ZEUS_WARNING("Remove interface : " << _list); for (int32_t iii=0; iii < _list.size(); ++iii) { // Call All remote Object object @@ -213,14 +213,14 @@ void zeus::WebServer::disconnect(bool _inThreadStop){ class SendAsyncBinary { private: - std::vector m_async; + etk::Vector m_async; uint64_t m_transactionId; uint32_t m_source; uint32_t m_destination; uint32_t m_partId; public: - SendAsyncBinary(uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, std::vector _async) : - m_async(std::move(_async)), + SendAsyncBinary(uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, etk::Vector _async) : + m_async(etk::move(_async)), m_transactionId(_transactionId), m_source(_source), m_destination(_destination), @@ -273,14 +273,14 @@ int32_t zeus::WebServer::writeBinary(ememory::SharedPtr _obj) { ZEUS_LOG_INPUT_OUTPUT("Send :" << _obj); if (_obj->writeOn(m_connection) == true) { if (_obj->haveAsync() == true) { - addAsync(SendAsyncBinary(_obj->getTransactionId(), _obj->getSource(), _obj->getDestination(), std::move(_obj->moveAsync()))); + addAsync(SendAsyncBinary(_obj->getTransactionId(), _obj->getSource(), _obj->getDestination(), etk::move(_obj->moveAsync()))); } return 1; } return -1; } -bool zeus::WebServer::onReceiveUri(const std::string& _uri, const std::vector& _protocols) { +bool zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector& _protocols) { ZEUS_INFO("Receive Header uri: " << _uri); bool findProtocol = false; for (auto &it : _protocols) { @@ -305,7 +305,7 @@ bool zeus::WebServer::onReceiveUri(const std::string& _uri, const std::vector& _frame, bool _isBinary) { +void zeus::WebServer::onReceiveData(etk::Vector& _frame, bool _isBinary) { if (_isBinary == true) { ZEUS_ERROR("Receive non binary frame ..."); disconnect(true); @@ -351,7 +351,7 @@ void zeus::WebServer::newMessage(ememory::SharedPtr _buffer) { if ( _buffer->getPartFinish() == false && _buffer->getType() != zeus::message::type::data) { //std::unique_lock lock(m_mutex); - m_listPartialMessage.push_back(_buffer); + m_listPartialMessage.pushBack(_buffer); return; } if (_buffer->getType() == zeus::message::type::data) { @@ -602,7 +602,7 @@ bool zeus::WebServer::removeObjectOwnership(uint16_t _objectAddress, uint32_t _s void zeus::WebServer::addAsync(zeus::WebServer::ActionAsync _elem) { std::unique_lock lock(m_threadAsyncMutex); - m_threadAsyncList2.push_back(_elem); + m_threadAsyncList2.pushBack(_elem); ZEUS_DEBUG("ADD element to send ... " << m_threadAsyncList2.size()); } @@ -615,7 +615,7 @@ void zeus::WebServer::threadAsyncCallback() { if (m_threadAsyncList2.size() != 0) { std::unique_lock lock(m_threadAsyncMutex); for (auto &it : m_threadAsyncList2) { - m_threadAsyncList.push_back(it); + m_threadAsyncList.pushBack(it); } m_threadAsyncList2.clear(); } @@ -650,13 +650,13 @@ zeus::FutureBase zeus::WebServer::callBinary(ememory::SharedPtr _ zeus::FutureBase tmpFuture(_obj->getTransactionId()); { std::unique_lock lock(m_pendingCallMutex); - m_pendingCall.push_back(std::make_pair(uint64_t(0), tmpFuture)); + m_pendingCall.pushBack(etk::makePair(uint64_t(0), tmpFuture)); } writeBinary(_obj); return tmpFuture; } -void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const std::string& _errorValue, const std::string& _errorHelp) { +void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const etk::String& _errorValue, const etk::String& _errorHelp) { auto answer = zeus::message::Answer::create(sharedFromThis()); if (answer == nullptr) { return; diff --git a/zeus/WebServer.hpp b/zeus/WebServer.hpp index 3bbde4a..96f2897 100644 --- a/zeus/WebServer.hpp +++ b/zeus/WebServer.hpp @@ -41,7 +41,7 @@ namespace zeus { uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, - const std::string& _functionName); + const etk::String& _functionName); /** * @brief This is the last call of createParam recursive function (no more parameter to add) * @param[in] _parmaId Id of the parameter to add. @@ -70,7 +70,7 @@ namespace zeus { * @brief Template specialization in 'const char*' to add a parameter of a function in recursive form * @param[in] _parmaId Id of the parameter to add. * @param[in] _obj message where to add the parameter. - * @param[in] _param Parameter value to add (char* that is converted in std::string). + * @param[in] _param Parameter value to add (char* that is converted in etk::String). * @param[in] _args... other argument to add (in recursive call) */ template @@ -78,7 +78,7 @@ namespace zeus { ememory::SharedPtr _obj, const char* _param, _ARGS&&... _args) { - createParam(_paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...); + createParam(_paramId, _obj, etk::String(_param), std::forward<_ARGS>(_args)...); } /** * @brieftemplate to create a ZEUS CALL message with all the parameter in arguments @@ -95,7 +95,7 @@ namespace zeus { uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, - const std::string& _functionName, + const etk::String& _functionName, _ARGS&&... _args) { ememory::SharedPtr callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName); if (callElem == nullptr) { @@ -111,11 +111,11 @@ namespace zeus { protected: std::mutex m_mutex; //!< main interface lock public: - std::vector> m_actifObject; //!< List of all active object created and that remove is in progress ... + etk::Vector> m_actifObject; //!< List of all active object created and that remove is in progress ... 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 - std::vector> m_listPartialMessage; //!< list of all message that data has not finished to arrive. + etk::Vector> 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. public: @@ -142,8 +142,8 @@ namespace zeus { return m_localIdObjectIncrement++; } private: - std::vector> m_listObject; //!< List of all local object that is reference in the system. - std::vector> m_listRemoteObject; //!< List of all object that we have a reference in the local interface. + etk::Vector> m_listObject; //!< List of all local object that is reference in the system. + etk::Vector> m_listRemoteObject; //!< List of all object that we have a reference in the local interface. public: /** * @brief Add a local WebObject to maage all his callback @@ -162,7 +162,7 @@ namespace zeus { /** * @brief Set the list of interface that has been removed ... */ - void interfaceRemoved(std::vector _list); + void interfaceRemoved(etk::Vector _list); private: uint32_t m_interfaceId; //!< local client interface ID uint16_t m_transmissionId; //!< Unique Id of a transmission (it is != 0) @@ -172,7 +172,7 @@ namespace zeus { */ uint16_t getId(); std::mutex m_pendingCallMutex; //!< local call of a pendinc call venctor update - std::vector> m_pendingCall; //!< List of pending call interface + etk::Vector> m_pendingCall; //!< List of pending call interface public: using Observer = std::function)>; //!< Define an Observer: function pointer Observer m_observerElement; //!< Observer on a new message arriving @@ -188,7 +188,7 @@ namespace zeus { }; } public: - using ObserverRequestUri = std::function; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not) + using ObserverRequestUri = std::function; //!< 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,8 +198,8 @@ namespace zeus { * @param[in] _func Function to call. */ template - void connectUri(CLASS_TYPE* _class, bool (CLASS_TYPE::*_func)(const std::string&)) { - m_observerRequestUri = [=](const std::string& _value){ + void connectUri(CLASS_TYPE* _class, bool (CLASS_TYPE::*_func)(const etk::String&)) { + m_observerRequestUri = [=](const etk::String& _value){ return (*_class.*_func)(_value); }; } @@ -232,7 +232,7 @@ namespace zeus { * @param[in] _userName Name on the user connected * @return */ - void setInterface(enet::Tcp _connection, bool _isServer, const std::string& _userName=""); + void setInterface(enet::Tcp _connection, bool _isServer, const etk::String& _userName=""); /** * @brief Connect on the remote interface * @param[in] _async if true, the cunnection does not wait all the connection process is done to return @@ -253,7 +253,7 @@ namespace zeus { * @brief set the interface name * @param[in] _name Ne name of the interface */ - void setInterfaceName(const std::string& _name); + void setInterfaceName(const etk::String& _name); /** * @brief Write a message preformated * @param[in] _data Message to write @@ -271,13 +271,13 @@ namespace zeus { * @return true the connection is accepted * @return false the connection is rejected */ - bool onReceiveUri(const std::string& _uri, const std::vector& _protocols); + bool onReceiveUri(const etk::String& _uri, const etk::Vector& _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 * @param[in] _isBinary the frame is binary if true, it is a string id false */ - void onReceiveData(std::vector& _frame, bool _isBinary); + void onReceiveData(etk::Vector& _frame, bool _isBinary); /** * @brief Receive a message to parse * @param[in] _buffer Message to interprete @@ -303,8 +303,8 @@ namespace zeus { std::mutex m_threadAsyncMutex; //!< Mutex fot the thread to send async data std::thread* m_threadAsync; //!< sending async data thread. TODO: Set it in a thread pool ... bool m_threadAsyncRunning; //!< Threa is running - std::vector m_threadAsyncList; //!< List of action to send (current) - std::vector m_threadAsyncList2; //!< list of action to send whenwurrent is sending in progress + etk::Vector m_threadAsyncList; //!< List of action to send (current) + etk::Vector m_threadAsyncList2; //!< list of action to send whenwurrent is sending in progress // TODO: Abord async sender ... private: /** @@ -334,7 +334,7 @@ namespace zeus { * @return Future that will get the return values */ template - zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) { + zeus::FutureBase call(const uint32_t& _source, const uint32_t& _destination, const etk::String& _functionName, _ARGS&&... _args) { uint16_t id = getId(); ememory::SharedPtr callElem = zeus::createCall(sharedFromThis(), id, _source, _destination, _functionName, std::forward<_ARGS>(_args)...); return callBinary(callElem); @@ -362,7 +362,7 @@ namespace zeus { * @param[in] _transactionId Current trasaction ID * @param[in] _errorHelp Help for the user to understand the error and correct it */ - void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); + void answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp); /** * @brief Send an Answer of a function with single value * @param[in] _clientTransactionId Transaction ID @@ -391,7 +391,7 @@ namespace zeus { * @param[in] _errorComment Help comment of the error * @param[in] _srcObjectId Client to send control */ - void answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const std::string& _errorValue, const std::string& _errorComment=""); + void answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const etk::String& _errorValue, const etk::String& _errorComment=""); public: /** * @brief Display list of all objects diff --git a/zeus/message/Answer.cpp b/zeus/message/Answer.cpp index dd700d5..5abe02e 100644 --- a/zeus/message/Answer.cpp +++ b/zeus/message/Answer.cpp @@ -10,7 +10,7 @@ #include #include -void zeus::message::Answer::generateDisplay(std::ostream& _os) const { +void zeus::message::Answer::generateDisplay(etk::Stream& _os) const { zeus::Message::generateDisplay(_os); if (getNumberParameter() != 0) { _os << " '" + simpleStringParam(0) + "'"; @@ -26,15 +26,15 @@ bool zeus::message::Answer::hasError() const { return m_errorType.size() != 0; } -const std::string& zeus::message::Answer::getError() const { +const etk::String& zeus::message::Answer::getError() const { return m_errorType; } -const std::string& zeus::message::Answer::getErrorHelp() const { +const etk::String& zeus::message::Answer::getErrorHelp() const { return m_errorHelp; } -void zeus::message::Answer::addError(const std::string& _value, const std::string& _comment) { +void zeus::message::Answer::addError(const etk::String& _value, const etk::String& _comment) { m_errorType = _value; m_errorHelp = _comment; } diff --git a/zeus/message/Answer.hpp b/zeus/message/Answer.hpp index b6d3070..33491e1 100644 --- a/zeus/message/Answer.hpp +++ b/zeus/message/Answer.hpp @@ -16,8 +16,8 @@ namespace zeus { public message::Parameter { friend class zeus::Message; protected: - std::string m_errorType; - std::string m_errorHelp; + etk::String m_errorType; + etk::String m_errorHelp; protected: /** * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Answer::create @@ -29,7 +29,7 @@ namespace zeus { void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; void appendMessageData(ememory::SharedPtr _obj) override; bool writeOn(enet::WebSocket& _interface) override; - void generateDisplay(std::ostream& _os) const override; + void generateDisplay(etk::Stream& _os) const override; public: /** * @brief Create a shared pointer on the Answer @@ -61,7 +61,7 @@ namespace zeus { * @param[in] _value error value (simple string with no space with all capital letter separaete with '_' * @param[in] _comment Human readable help to understand the error */ - void addError(const std::string& _value, const std::string& _comment); + void addError(const etk::String& _value, const etk::String& _comment); /** * @brief Check if the answer have an error * @return status of the error. @@ -71,12 +71,12 @@ namespace zeus { * @brief get the error value (if exist) * @return string of the error */ - const std::string& getError() const; + const etk::String& getError() const; /** * @brief get the error help (if exist) * @return string of the error help */ - const std::string& getErrorHelp() const; + const etk::String& getErrorHelp() const; }; } } diff --git a/zeus/message/Call.cpp b/zeus/message/Call.cpp index 657cfa0..3296880 100644 --- a/zeus/message/Call.cpp +++ b/zeus/message/Call.cpp @@ -10,10 +10,10 @@ #include #include -void zeus::message::Call::generateDisplay(std::ostream& _os) const { +void zeus::message::Call::generateDisplay(etk::Stream& _os) const { zeus::Message::generateDisplay(_os); _os << " '" + m_callName + "'"; - _os << " nbParam=" + etk::to_string(getNumberParameter()); + _os << " nbParam=" + etk::toString(getNumberParameter()); if (getNumberParameter() != 0) { _os << " paramType("; for (int32_t iii=0; iii _obj) override; bool writeOn(enet::WebSocket& _interface) override; - void generateDisplay(std::ostream& _os) const override; + void generateDisplay(etk::Stream& _os) const override; public: /** * @brief Create a shared pointer on the MessageCall @@ -42,12 +42,12 @@ namespace zeus { * @brief get the call value of the buffer * @return string of the function to call */ - const std::string& getCall() const; + const etk::String& getCall() const; /** * @brief Set the call value of the buffer * @param[in] _value Function to call */ - void setCall(const std::string& _value); + void setCall(const etk::String& _value); }; } diff --git a/zeus/message/Data.cpp b/zeus/message/Data.cpp index 1c7e5b0..bb47f25 100644 --- a/zeus/message/Data.cpp +++ b/zeus/message/Data.cpp @@ -10,11 +10,11 @@ #include #include -void zeus::message::Data::generateDisplay(std::ostream& _os) const { +void zeus::message::Data::generateDisplay(etk::Stream& _os) const { zeus::Message::generateDisplay(_os); - _os << " paramId=" << etk::to_string(m_parameterId); - _os << " part=" << etk::to_string(m_partId); - _os << " nbData=" << etk::to_string(m_data.size()); + _os << " paramId=" << etk::toString(m_parameterId); + _os << " part=" << etk::toString(m_partId); + _os << " nbData=" << etk::toString(m_data.size()); } void zeus::message::Data::addData(uint16_t _parameterId, void* _data, uint32_t _size) { diff --git a/zeus/message/Data.hpp b/zeus/message/Data.hpp index 65ae671..f1c9509 100644 --- a/zeus/message/Data.hpp +++ b/zeus/message/Data.hpp @@ -17,7 +17,7 @@ namespace zeus { protected: uint32_t m_partId; uint16_t m_parameterId; - std::vector m_data; + etk::Vector m_data; protected: /** * @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Data::create @@ -30,7 +30,7 @@ namespace zeus { void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; // TODO :... void appendMessageData(ememory::SharedPtr _obj) override; bool writeOn(enet::WebSocket& _interface) override; - void generateDisplay(std::ostream& _os) const override; + void generateDisplay(etk::Stream& _os) const override; public: /** * @brief Create a shared pointer on the MessageData @@ -68,7 +68,7 @@ namespace zeus { /** * @brief Get data reference */ - const std::vector& getData() const { + const etk::Vector& getData() const { return m_data; } diff --git a/zeus/message/Event.cpp b/zeus/message/Event.cpp index f957d96..4a8a33f 100644 --- a/zeus/message/Event.cpp +++ b/zeus/message/Event.cpp @@ -10,7 +10,7 @@ #include #include -void zeus::message::Event::generateDisplay(std::ostream& _os) const { +void zeus::message::Event::generateDisplay(etk::Stream& _os) const { zeus::Message::generateDisplay(_os); if (getNumberParameter() != 0) { _os << " '" + simpleStringParam(0) + "'"; diff --git a/zeus/message/Event.hpp b/zeus/message/Event.hpp index 4b0db4f..b05cf4b 100644 --- a/zeus/message/Event.hpp +++ b/zeus/message/Event.hpp @@ -27,7 +27,7 @@ namespace zeus { }; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; bool writeOn(enet::WebSocket& _interface) override; - void generateDisplay(std::ostream& _os) const override; + void generateDisplay(etk::Stream& _os) const override; public: /** * @brief Create a shared pointer on the Event diff --git a/zeus/message/Message.cpp b/zeus/message/Message.cpp index f3ae017..4bc8b73 100644 --- a/zeus/message/Message.cpp +++ b/zeus/message/Message.cpp @@ -64,7 +64,7 @@ void zeus::Message::clear() { m_header.flags = ZEUS_BUFFER_FLAG_FINISH; } -std::ostream& zeus::operator <<(std::ostream& _os, ememory::SharedPtr _obj) { +etk::Stream& zeus::operator <<(etk::Stream& _os, ememory::SharedPtr _obj) { _os << "zeus::Message: "; if (_obj == nullptr) { _os << "nullptr"; @@ -73,12 +73,12 @@ std::ostream& zeus::operator <<(std::ostream& _os, ememory::SharedPtr zeus::Message::create(ememory::SharedPtr(new zeus::Message(_iface)); } -ememory::SharedPtr zeus::Message::create(ememory::SharedPtr _iface, const std::vector& _buffer) { +ememory::SharedPtr zeus::Message::create(ememory::SharedPtr _iface, const etk::Vector& _buffer) { zeus::message::headerBin header; if (_buffer.size() < sizeof(zeus::message::headerBin)) { ZEUS_ERROR("wrong size of the buffer: " << _buffer.size() << " must be " << sizeof(zeus::message::headerBin)); diff --git a/zeus/message/Message.hpp b/zeus/message/Message.hpp index f2ca448..60f8034 100644 --- a/zeus/message/Message.hpp +++ b/zeus/message/Message.hpp @@ -141,7 +141,7 @@ namespace zeus { * */ class Message { - friend std::ostream& operator<<(std::ostream&, zeus::Message*); + friend etk::Stream& operator<<(etk::Stream&, zeus::Message*); protected: ememory::SharedPtr m_iface; //!< link to the interface protected: @@ -164,11 +164,11 @@ namespace zeus { * @param[in] _buffer Message on the data * @return Allocated Message. */ - static ememory::SharedPtr create(ememory::SharedPtr _iface, const std::vector& _buffer); + static ememory::SharedPtr create(ememory::SharedPtr _iface, const etk::Vector& _buffer); protected: uint32_t m_interfaceID; //!< For debug ==> unterface ID ... message::headerBin m_header; //!< header of the protocol - std::vector m_multipleSend; //!< Async element to send data on the webinterface when too big ... + etk::Vector m_multipleSend; //!< Async element to send data on the webinterface when too big ... public: /** * @brief Check if async element are present on this buffer @@ -181,8 +181,8 @@ namespace zeus { * @brief Get the list of async data to send * @return Vector of the async data (the async are moved out ... call only one time) */ - std::vector moveAsync() { - return std::move(m_multipleSend); + etk::Vector moveAsync() { + return etk::move(m_multipleSend); } /** * @brief When multiple frame buffer, they need to concatenate the data... call this function with the new data to append it ... @@ -305,7 +305,7 @@ namespace zeus { */ // This fucntion does not lock the interface virtual bool writeOn(enet::WebSocket& _interface); - virtual void generateDisplay(std::ostream& _os) const ; + virtual void generateDisplay(etk::Stream& _os) const ; }; /** * @brief generate a display of the typemessage @@ -313,7 +313,7 @@ namespace zeus { * @value[in] _obj Message to display * @return a reference of the stream */ - std::ostream& operator <<(std::ostream& _os, ememory::SharedPtr _obj); + etk::Stream& operator <<(etk::Stream& _os, ememory::SharedPtr _obj); namespace message { // internal: @@ -322,13 +322,13 @@ namespace zeus { * @param[in] _data Message to add type * @param[in] _type generic type to add */ - void addType(std::vector& _data, zeus::message::ParamType _type); + void addType(etk::Vector& _data, zeus::message::ParamType _type); /** * @brief Add a parameter object type in the buffer * @param[in] _data Message to add type * @param[in] _type string of the type to add */ - void addTypeObject(std::vector& _data, const std::string _type); + void addTypeObject(etk::Vector& _data, const etk::String _type); } } diff --git a/zeus/message/ParamType.cpp b/zeus/message/ParamType.cpp index f498103..ac4f67e 100644 --- a/zeus/message/ParamType.cpp +++ b/zeus/message/ParamType.cpp @@ -22,7 +22,7 @@ bool zeus::message::checkCompatibility(const ParamType& _type, const ParamType& } -std::ostream& zeus::message::operator <<(std::ostream& _os, const zeus::message::ParamType& _obj) { +etk::Stream& zeus::message::operator <<(etk::Stream& _os, const zeus::message::ParamType& _obj) { _os << "{" << _obj.getId() << ":" << _obj.getName() << "}"; return _os; } @@ -34,7 +34,7 @@ zeus::message::ParamType::ParamType(const char* _name, uint16_t _id, bool _isNum m_isVector(_isVector) { } -zeus::message::ParamType::ParamType(const std::string& _name, uint16_t _id, bool _isNumber, bool _isVector): +zeus::message::ParamType::ParamType(const etk::String& _name, uint16_t _id, bool _isNumber, bool _isVector): m_typeName(_name), m_id(_id), m_isNumber(_isNumber), @@ -49,7 +49,7 @@ bool zeus::message::ParamType::isNumber() const { bool zeus::message::ParamType::isVector() const { return m_isVector; } -const std::string& zeus::message::ParamType::getName() const { +const etk::String& zeus::message::ParamType::getName() const { return m_typeName; } @@ -76,10 +76,10 @@ bool zeus::message::ParamType::operator != (const ParamType& _obj) const { return false; } -bool zeus::message::ParamType::operator == (const std::string& _value) const { +bool zeus::message::ParamType::operator == (const etk::String& _value) const { return _value == m_typeName; } -bool zeus::message::ParamType::operator != (const std::string& _value) const { +bool zeus::message::ParamType::operator != (const etk::String& _value) const { return _value != m_typeName; } @@ -113,22 +113,22 @@ generate_basic_type(uint64_t, "uint64", 0x0009, true, false); generate_basic_type(uint32_t, "uint32", 0x000A, true, false); generate_basic_type(uint16_t, "uint16", 0x000B, true, false); generate_basic_type(uint8_t, "uint8", 0x000C, true, false); -generate_basic_type(std::string, "string", 0x000D, false, false); +generate_basic_type(etk::String, "string", 0x000D, false, false); generate_basic_type(zeus::Raw, "raw", 0x000E, false, false); -generate_basic_type(std::vector, "vector:empty", 0x0102, true, true); -generate_basic_type(std::vector, "vector:bool", 0x0102, false, true); -generate_basic_type(std::vector, "vector:float", 0x0103, true, true); -generate_basic_type(std::vector, "vector:double", 0x0104, true, true); -generate_basic_type(std::vector, "vector:int64", 0x0105, true, true); -generate_basic_type(std::vector, "vector:int32", 0x0106, true, true); -generate_basic_type(std::vector, "vector:int16", 0x0107, true, true); -generate_basic_type(std::vector, "vector:int8", 0x0108, true, true); -generate_basic_type(std::vector, "vector:uint64", 0x0109, true, true); -generate_basic_type(std::vector, "vector:uint32", 0x010A, true, true); -generate_basic_type(std::vector, "vector:uint16", 0x010B, true, true); -generate_basic_type(std::vector, "vector:uint8", 0x010C, true, true); -generate_basic_type(std::vector, "vector:string", 0x010D, false, true); +generate_basic_type(etk::Vector, "vector:empty", 0x0102, true, true); +generate_basic_type(etk::Vector, "vector:bool", 0x0102, false, true); +generate_basic_type(etk::Vector, "vector:float", 0x0103, true, true); +generate_basic_type(etk::Vector, "vector:double", 0x0104, true, true); +generate_basic_type(etk::Vector, "vector:int64", 0x0105, true, true); +generate_basic_type(etk::Vector, "vector:int32", 0x0106, true, true); +generate_basic_type(etk::Vector, "vector:int16", 0x0107, true, true); +generate_basic_type(etk::Vector, "vector:int8", 0x0108, true, true); +generate_basic_type(etk::Vector, "vector:uint64", 0x0109, true, true); +generate_basic_type(etk::Vector, "vector:uint32", 0x010A, true, true); +generate_basic_type(etk::Vector, "vector:uint16", 0x010B, true, true); +generate_basic_type(etk::Vector, "vector:uint8", 0x010C, true, true); +generate_basic_type(etk::Vector, "vector:string", 0x010D, false, true); const uint16_t zeus::message::paramTypeObject = 0xFFFF; diff --git a/zeus/message/ParamType.hpp b/zeus/message/ParamType.hpp index bd99687..95adc33 100644 --- a/zeus/message/ParamType.hpp +++ b/zeus/message/ParamType.hpp @@ -5,7 +5,7 @@ */ #pragma once -#include +#include namespace zeus { namespace message { @@ -14,7 +14,7 @@ namespace zeus { */ class ParamType { protected: - const std::string m_typeName; //!< generic type + const etk::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) @@ -31,12 +31,12 @@ namespace zeus { /** * @copydoc zeus::message::ParamType::ParamType */ - ParamType(const std::string& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false); + ParamType(const etk::String& _name, uint16_t _id, bool _isNumber=false, bool _isVector=false); /** * @brief Get name of tha parameter * @return string describing the TYPE */ - const std::string& getName() const; + const etk::String& getName() const; /** * @brief Get generic Id of the type * @return unsigned int containing the type @@ -59,13 +59,13 @@ namespace zeus { * @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; + bool operator == (const etk::String& _value) const; /** * @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; + bool operator != (const etk::String& _value) const; /** * @brief Egality comparaison with an other parameter * @param[in] _obj Other parameter to compare type enum integer @@ -96,7 +96,7 @@ namespace zeus { * @param[in] _obj Object to display * @return The inpout stream */ - std::ostream& operator <<(std::ostream& _os, const zeus::message::ParamType& _obj); + etk::Stream& operator <<(etk::Stream& _os, const zeus::message::ParamType& _obj); /** * @brief Template to automaticly get the type of an generic std type without create a dynamic element * @return generic parameter created diff --git a/zeus/message/Parameter.cpp b/zeus/message/Parameter.cpp index f568019..6e497bf 100644 --- a/zeus/message/Parameter.cpp +++ b/zeus/message/Parameter.cpp @@ -40,7 +40,7 @@ void zeus::message::Parameter::composeWith(const uint8_t* _buffer, uint32_t _len uint32_t offset = 0; memcpy(&nbParameters, &_buffer[offset], sizeof(uint16_t)); offset += sizeof(uint16_t); - m_parameter.resize(nbParameters, std::make_pair(-1, std::vector())); + m_parameter.resize(nbParameters, etk::makePair(-1, etk::Vector())); // Load all Parameters nbParameters = 0; while ( nbParameters < m_parameter.size() @@ -53,7 +53,7 @@ void zeus::message::Parameter::composeWith(const uint8_t* _buffer, uint32_t _len ZEUS_ERROR("Wrong parameter size : " << sizeParam << " / availlable=" << _lenght-offset); return; } - std::vector data; + etk::Vector data; data.resize(sizeParam); memcpy(&data[0], &_buffer[offset], data.size() * sizeof(uint8_t)); offset += data.size() * sizeof(uint8_t); @@ -85,20 +85,20 @@ zeus::message::ParamType zeus::message::Parameter::getParameterType(int32_t _id) if (typeId == createType().getId()) { m_parameter[_id].first = 2; return createType(); } if (typeId == createType().getId()) { m_parameter[_id].first = 2; return createType(); } if (typeId == createType().getId()) { m_parameter[_id].first = 2; return createType(); } - if (typeId == createType().getId()) { m_parameter[_id].first = 2; return createType(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } - if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType().getId()) { m_parameter[_id].first = 2; return createType(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } + if (typeId == createType>().getId()) { m_parameter[_id].first = 2; return createType>(); } if (typeId == createType().getId()) { m_parameter[_id].first = 2; return createType(); } if (typeId == paramTypeObject) { const char* tmp = reinterpret_cast(&m_parameter[_id].second[2]); @@ -114,7 +114,7 @@ zeus::message::ParamType zeus::message::Parameter::getParameterType(int32_t _id) m_parameter[_id].first = 0; return zeus::message::ParamType("no-name", typeId); } - std::string type(tmp); + etk::String type(tmp); m_parameter[_id].first = type.size() + sizeof(uint16_t) + 1; // add \0 return zeus::message::ParamType(type, typeId); } @@ -158,21 +158,21 @@ uint16_t zeus::message::Parameter::getNumberParameter() const { return m_parameter.size(); } -std::string zeus::message::Parameter::simpleStringParam(uint32_t _id) const { +etk::String zeus::message::Parameter::simpleStringParam(uint32_t _id) const { zeus::message::ParamType paramType = getParameterType(_id); if (paramType.isVector() == false) { if (paramType.isNumber() == true) { - return etk::to_string(getParameter(_id)); + return etk::toString(getParameter(_id)); } } if (paramType == createType()) { - return etk::to_string(getParameter(_id)); + return etk::toString(getParameter(_id)); } - if (paramType == createType()) { - return "{" + getParameter(_id) + "}"; + if (paramType == createType()) { + return "{" + getParameter(_id) + "}"; } - if (paramType == createType>()) { - return "[" + etk::to_string(getParameter>(_id)) + "]"; + if (paramType == createType>()) { + return "[" + etk::toString(getParameter>(_id)) + "]"; } return paramType.getName(); } diff --git a/zeus/message/Parameter.hpp b/zeus/message/Parameter.hpp index 7fdd61d..e6a1424 100644 --- a/zeus/message/Parameter.hpp +++ b/zeus/message/Parameter.hpp @@ -15,7 +15,7 @@ namespace zeus { class Parameter: public Message { protected: - mutable std::vector>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...) + mutable etk::Vector>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...) public: Parameter(ememory::SharedPtr _iface); /** @@ -62,7 +62,7 @@ namespace zeus { * @param[in] _id Number of the parameter * @return readable string */ - std::string simpleStringParam(uint32_t _id) const; + etk::String simpleStringParam(uint32_t _id) const; void composeWith(const uint8_t* _buffer, uint32_t _lenght) override; // !! This function does not lock the socket interface bool writeOn(enet::WebSocket& _interface) override; diff --git a/zeus/message/Parameter_addParameter.cpp b/zeus/message/Parameter_addParameter.cpp index a46eeeb..d114d44 100644 --- a/zeus/message/Parameter_addParameter.cpp +++ b/zeus/message/Parameter_addParameter.cpp @@ -16,47 +16,47 @@ #include -void zeus::message::addType(std::vector& _data, zeus::message::ParamType _type) { - _data.push_back(uint8_t(_type.getId()>>8)); - _data.push_back(uint8_t(_type.getId())); +void zeus::message::addType(etk::Vector& _data, zeus::message::ParamType _type) { + _data.pushBack(uint8_t(_type.getId()>>8)); + _data.pushBack(uint8_t(_type.getId())); } -void zeus::message::addTypeObject(std::vector& _data, const std::string _type) { - _data.push_back(uint8_t(zeus::message::paramTypeObject>>8)); - _data.push_back(uint8_t(zeus::message::paramTypeObject)); +void zeus::message::addTypeObject(etk::Vector& _data, const etk::String _type) { + _data.pushBack(uint8_t(zeus::message::paramTypeObject>>8)); + _data.pushBack(uint8_t(zeus::message::paramTypeObject)); for (auto &it : _type) { - _data.push_back(uint8_t(it)); + _data.pushBack(uint8_t(it)); } - _data.push_back(0); + _data.pushBack(0); } void zeus::message::Parameter::addParameter() { - std::vector data; + etk::Vector data; addType(data, createType()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } void zeus::message::Parameter::addParameterEmptyVector() { // special case of json change mode - std::vector data; - addType(data, createType>()); - m_parameter.push_back(std::make_pair(2,data)); + etk::Vector data; + addType(data, createType>()); + m_parameter.pushBack(etk::makePair(2,data)); } namespace zeus { namespace message { template<> - void Parameter::addParameter(uint16_t _paramId, const std::string& _value) { - std::vector data; - addType(data, createType()); + void Parameter::addParameter(uint16_t _paramId, const etk::String& _value) { + etk::Vector data; + addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+_value.size()); memcpy(&data[currentOffset], &_value[0], _value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // count all datas: uint32_t size = 0; for (auto &it : _value) { @@ -73,13 +73,13 @@ namespace zeus { data[currentOffset] = '\0'; currentOffset++; } - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: uint16_t nb = _value.size(); int32_t currentOffset = data.size(); @@ -92,180 +92,180 @@ namespace zeus { } currentOffset++; } - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(int8_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(int8_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(int16_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(int16_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(int32_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(int32_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(int64_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(int64_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(uint8_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(uint8_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); ZEUS_INFO("add " << _value.size() << " elements"); data.resize(data.size()+sizeof(uint16_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(uint16_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(uint32_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(uint32_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(uint64_t)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(uint64_t)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(float)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(float)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> - void Parameter::addParameter>(uint16_t _paramId, const std::vector& _value) { - std::vector data; - addType(data, createType>()); + void Parameter::addParameter>(uint16_t _paramId, const etk::Vector& _value) { + etk::Vector data; + addType(data, createType>()); // add size: int32_t currentOffset = data.size(); data.resize(data.size()+sizeof(double)*_value.size()); memcpy(&data[currentOffset], &_value[0], sizeof(double)*_value.size()); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const int8_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); - data.push_back(uint8_t(_value)); - m_parameter.push_back(std::make_pair(2,data)); + data.pushBack(uint8_t(_value)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const uint8_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); - data.push_back(_value); - m_parameter.push_back(std::make_pair(2,data)); + data.pushBack(_value); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const int16_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+2); memcpy(&data[currentOffset], &_value, 2); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const uint16_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+2); memcpy(&data[currentOffset], &_value, 2); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const int32_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+4); memcpy(&data[currentOffset], &_value, 4); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const uint32_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+4); memcpy(&data[currentOffset], &_value, 4); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const int64_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+8); memcpy(&data[currentOffset], &_value, 8); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const uint64_t& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+8); memcpy(&data[currentOffset], &_value, 8); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } #if defined(__TARGET_OS__MacOs) \ || defined(__TARGET_OS__IOs) @@ -276,32 +276,32 @@ namespace zeus { #endif template<> void Parameter::addParameter(uint16_t _paramId, const float& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+4); memcpy(&data[currentOffset], &_value, 4); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const double& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); int32_t currentOffset = data.size(); data.resize(data.size()+8); memcpy(&data[currentOffset], &_value, 8); - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } template<> void Parameter::addParameter(uint16_t _paramId, const bool& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); if (_value == true) { - data.push_back('T'); + data.pushBack('T'); } else { - data.push_back('F'); + data.pushBack('F'); } - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } #define ZEUS_MINIMUM_SIZE_MULTIPLE (1024*50) class SendData { @@ -349,7 +349,7 @@ namespace zeus { }; template<> void Parameter::addParameter(uint16_t _paramId, const zeus::Raw& _value) { - std::vector data; + etk::Vector data; addType(data, createType()); // set mine type in string: int32_t currentOffset = data.size(); @@ -358,10 +358,10 @@ namespace zeus { data.resize(data.size()+_value.size()); memcpy(&data[currentOffset], _value.data(), _value.size()); } else { - m_multipleSend.push_back(zeus::message::SendData(_value, _paramId)); + m_multipleSend.pushBack(zeus::message::SendData(_value, _paramId)); } } - m_parameter.push_back(std::make_pair(2,data)); + m_parameter.pushBack(etk::makePair(2,data)); } } } diff --git a/zeus/message/Parameter_getParameter.cpp b/zeus/message/Parameter_getParameter.cpp index 9fdf0bf..6122258 100644 --- a/zeus/message/Parameter_getParameter.cpp +++ b/zeus/message/Parameter_getParameter.cpp @@ -32,8 +32,8 @@ namespace zeus { } template<> - std::string Parameter::getParameter(int32_t _id) const { - std::string out; + etk::String Parameter::getParameter(int32_t _id) const { + etk::String out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); @@ -60,18 +60,18 @@ namespace zeus { } else if (createType() == type) { uint16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint16_t(UCHAR_MAX)); + return etk::min(tmp, uint16_t(UCHAR_MAX)); } else if (createType() == type) { uint32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint32_t(UCHAR_MAX)); + return etk::min(tmp, uint32_t(UCHAR_MAX)); } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(UCHAR_MAX)); + return etk::min(tmp, uint64_t(UCHAR_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); - return std::max(int8_t(0), *tmp); + return etk::max(int8_t(0), *tmp); } else if (createType() == type) { int16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); @@ -112,18 +112,18 @@ namespace zeus { } else if (createType() == type) { uint32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint32_t(USHRT_MAX)); + return etk::min(tmp, uint32_t(USHRT_MAX)); } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(USHRT_MAX)); + return etk::min(tmp, uint64_t(USHRT_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); - return std::max(int8_t(0), *tmp); + return etk::max(int8_t(0), *tmp); } else if (createType() == type) { int16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::max(int16_t(0), tmp); + return etk::max(int16_t(0), tmp); } else if (createType() == type) { int32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); @@ -166,18 +166,18 @@ namespace zeus { } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(ULONG_MAX)); + return etk::min(tmp, uint64_t(ULONG_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); - return std::max(int8_t(0), *tmp); + return etk::max(int8_t(0), *tmp); } else if (createType() == type) { int16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::max(int16_t(0), tmp); + return etk::max(int16_t(0), tmp); } else if (createType() == type) { int32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::max(int32_t(0), tmp); + return etk::max(int32_t(0), tmp); } else if (createType() == type) { int64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); @@ -219,19 +219,19 @@ namespace zeus { return tmp; } else if (createType() == type) { int8_t* tmp = reinterpret_cast(pointer); - return std::max(int8_t(0), *tmp); + return etk::max(int8_t(0), *tmp); } else if (createType() == type) { int16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::max(int16_t(0), tmp); + return etk::max(int16_t(0), tmp); } else if (createType() == type) { int32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::max(int32_t(0), tmp); + return etk::max(int32_t(0), tmp); } else if (createType() == type) { int64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::max(int64_t(0), tmp); + return etk::max(int64_t(0), tmp); } else if (createType() == type) { float tmp; memcpy(&tmp, pointer, sizeof(tmp)); @@ -260,19 +260,19 @@ namespace zeus { // TODO : Check size ... if (createType() == type) { const uint8_t* tmp = reinterpret_cast(pointer); - return std::min(*tmp, uint8_t(SCHAR_MAX)); + return etk::min(*tmp, uint8_t(SCHAR_MAX)); } else if (createType() == type) { uint16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint16_t(SCHAR_MAX)); + return etk::min(tmp, uint16_t(SCHAR_MAX)); } else if (createType() == type) { uint32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint32_t(SCHAR_MAX)); + return etk::min(tmp, uint32_t(SCHAR_MAX)); } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(SCHAR_MAX)); + return etk::min(tmp, uint64_t(SCHAR_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); return *tmp; @@ -313,15 +313,15 @@ namespace zeus { } else if (createType() == type) { uint16_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint16_t(SHRT_MAX)); + return etk::min(tmp, uint16_t(SHRT_MAX)); } else if (createType() == type) { uint32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint32_t(SHRT_MAX)); + return etk::min(tmp, uint32_t(SHRT_MAX)); } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(SHRT_MAX)); + return etk::min(tmp, uint64_t(SHRT_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); return *tmp; @@ -367,11 +367,11 @@ namespace zeus { } else if (createType() == type) { uint32_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint32_t(LONG_MAX)); + return etk::min(tmp, uint32_t(LONG_MAX)); } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(LONG_MAX)); + return etk::min(tmp, uint64_t(LONG_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); return *tmp; @@ -421,7 +421,7 @@ namespace zeus { } else if (createType() == type) { uint64_t tmp; memcpy(&tmp, pointer, sizeof(tmp)); - return std::min(tmp, uint64_t(LLONG_MAX)); + return etk::min(tmp, uint64_t(LLONG_MAX)); } else if (createType() == type) { const int8_t* tmp = reinterpret_cast(pointer); return *tmp; @@ -571,52 +571,52 @@ namespace zeus { template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(uint8_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); @@ -624,7 +624,7 @@ namespace zeus { out[iii] = etk::avg(int16_t(0), tmp[iii], int16_t(UCHAR_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -632,7 +632,7 @@ namespace zeus { out[iii] = etk::avg(int32_t(0), tmp[iii], int32_t(UCHAR_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -640,7 +640,7 @@ namespace zeus { out[iii] = etk::avg(int64_t(0), tmp[iii], int64_t(UCHAR_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -648,7 +648,7 @@ namespace zeus { out[iii] = uint8_t(etk::avg(float(0), tmp[iii], float(UCHAR_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -661,15 +661,15 @@ namespace zeus { return out; } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -677,44 +677,44 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(uint16_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -722,7 +722,7 @@ namespace zeus { out[iii] = etk::avg(int32_t(0), tmp[iii], int32_t(USHRT_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -730,7 +730,7 @@ namespace zeus { out[iii] = etk::avg(int64_t(0), tmp[iii], int64_t(USHRT_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -738,7 +738,7 @@ namespace zeus { out[iii] = uint16_t(etk::avg(float(0), tmp[iii], float(USHRT_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -752,15 +752,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -768,7 +768,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); @@ -776,44 +776,44 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(uint32_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -821,7 +821,7 @@ namespace zeus { out[iii] = etk::avg(int64_t(0), tmp[iii], int64_t(ULONG_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -829,7 +829,7 @@ namespace zeus { out[iii] = uint32_t(etk::avg(float(0), tmp[iii], float(ULONG_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -843,15 +843,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -859,7 +859,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); @@ -867,7 +867,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); @@ -875,44 +875,44 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(uint64_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -920,7 +920,7 @@ namespace zeus { out[iii] = uint64_t(etk::avg(float(0), tmp[iii], float(ULONG_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -934,52 +934,52 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(int8_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); @@ -987,7 +987,7 @@ namespace zeus { out[iii] = etk::avg(int16_t(SCHAR_MIN), tmp[iii], int16_t(SCHAR_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -995,7 +995,7 @@ namespace zeus { out[iii] = etk::avg(int32_t(SCHAR_MIN), tmp[iii], int32_t(SCHAR_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -1003,7 +1003,7 @@ namespace zeus { out[iii] = etk::avg(int64_t(SCHAR_MIN), tmp[iii], int64_t(SCHAR_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -1011,7 +1011,7 @@ namespace zeus { out[iii] = int8_t(etk::avg(float(SCHAR_MIN), tmp[iii], float(SCHAR_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -1025,15 +1025,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -1041,31 +1041,31 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); @@ -1073,12 +1073,12 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(int16_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -1086,7 +1086,7 @@ namespace zeus { out[iii] = etk::avg(int32_t(SHRT_MIN), tmp[iii], int32_t(SHRT_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -1094,7 +1094,7 @@ namespace zeus { out[iii] = etk::avg(int64_t(SHRT_MIN), tmp[iii], int64_t(SHRT_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -1102,7 +1102,7 @@ namespace zeus { out[iii] = int16_t(etk::avg(float(SHRT_MIN), tmp[iii], float(SHRT_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -1116,15 +1116,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -1132,7 +1132,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); @@ -1140,23 +1140,23 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); @@ -1164,7 +1164,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); @@ -1172,12 +1172,12 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(int32_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -1185,7 +1185,7 @@ namespace zeus { out[iii] = etk::avg(int64_t(LONG_MIN), tmp[iii], int64_t(LONG_MAX)); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -1193,7 +1193,7 @@ namespace zeus { out[iii] = int32_t(etk::avg(float(LONG_MIN), tmp[iii], float(LONG_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -1207,15 +1207,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -1223,7 +1223,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); @@ -1231,7 +1231,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); @@ -1239,15 +1239,15 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); for (size_t iii=0; iii>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); @@ -1255,7 +1255,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); @@ -1263,7 +1263,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -1271,12 +1271,12 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(int64_t)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -1284,7 +1284,7 @@ namespace zeus { out[iii] = int64_t(etk::avg(float(LLONG_MIN), tmp[iii], float(LLONG_MAX))); } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -1298,15 +1298,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -1314,7 +1314,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); @@ -1322,7 +1322,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); @@ -1330,7 +1330,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); @@ -1338,7 +1338,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); @@ -1346,7 +1346,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); @@ -1354,7 +1354,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -1362,7 +1362,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -1370,12 +1370,12 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(float)); return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const double* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); @@ -1389,15 +1389,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -1405,7 +1405,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint16_t); out.resize(nbElement); @@ -1413,7 +1413,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint32_t); out.resize(nbElement); @@ -1421,7 +1421,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint64_t); out.resize(nbElement); @@ -1429,7 +1429,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int8_t); out.resize(nbElement); @@ -1437,7 +1437,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int16_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int16_t); out.resize(nbElement); @@ -1445,7 +1445,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int32_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int32_t); out.resize(nbElement); @@ -1453,7 +1453,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const int64_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(int64_t); out.resize(nbElement); @@ -1461,7 +1461,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const float* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(float); out.resize(nbElement); @@ -1469,7 +1469,7 @@ namespace zeus { out[iii] = tmp[iii]; } return out; - } else if (createType>() == type) { + } else if (createType>() == type) { int32_t nbElement = dataSize / sizeof(double); out.resize(nbElement); memcpy(&out[0], pointer, nbElement * sizeof(double)); @@ -1480,15 +1480,15 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); // TODO : Check size ... - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { const uint8_t* tmp = reinterpret_cast(pointer); int32_t nbElement = dataSize / sizeof(uint8_t); out.resize(nbElement); @@ -1502,14 +1502,14 @@ namespace zeus { } template<> - std::vector Parameter::getParameter>(int32_t _id) const { - std::vector out; + etk::Vector Parameter::getParameter>(int32_t _id) const { + etk::Vector out; zeus::message::ParamType type = getParameterType(_id); const uint8_t* pointer = getParameterPointer(_id); uint32_t dataSize = getParameterSize(_id); - if (type == createType>()) { + if (type == createType>()) { return out; - } else if (createType>() == type) { + } else if (createType>() == type) { // first element is the number of elements: const uint16_t* tmp = reinterpret_cast(pointer); out.resize(*tmp); diff --git a/zeus/message/type.cpp b/zeus/message/type.cpp index 98f8c23..43195d0 100644 --- a/zeus/message/type.cpp +++ b/zeus/message/type.cpp @@ -8,7 +8,7 @@ #include namespace etk { - template<> std::string to_string(const enum zeus::message::type& _value) { + template<> etk::String toString(const enum zeus::message::type& _value) { switch (_value) { case zeus::message::type::unknow: return "unknow"; @@ -24,8 +24,8 @@ namespace etk { return "???"; } } -std::ostream& zeus::message::operator <<(std::ostream& _os, enum zeus::message::type _value) { - _os << etk::to_string(_value); +etk::Stream& zeus::message::operator <<(etk::Stream& _os, enum zeus::message::type _value) { + _os << etk::toString(_value); return _os; } diff --git a/zeus/message/type.hpp b/zeus/message/type.hpp index 52446ee..a51b34f 100644 --- a/zeus/message/type.hpp +++ b/zeus/message/type.hpp @@ -26,7 +26,7 @@ namespace zeus { * @value[in] _value Value to add * @return a reference of the stream */ - std::ostream& operator <<(std::ostream& _os, enum zeus::message::type _value); + etk::Stream& operator <<(etk::Stream& _os, enum zeus::message::type _value); /** * @brief convert the type in a correct enumeration value * @param[in] _value Value of type to convert diff --git a/zeus/mineType.cpp b/zeus/mineType.cpp index b10d0a1..8f77331 100644 --- a/zeus/mineType.cpp +++ b/zeus/mineType.cpp @@ -8,7 +8,7 @@ #include -static std::vector> mineList = { +static etk::Vector> mineList = { /* Video files */ { "webm", "video/webm"}, { "asf", "video/x-ms-asf"}, @@ -151,7 +151,7 @@ static std::vector> mineList = { { "js", "code/javascript"}, }; -std::string zeus::getMineType(std::string _extention) { +etk::String zeus::getMineType(etk::String _extention) { _extention = etk::tolower(_extention); for (auto &it : mineList) { if (it.first == _extention) { @@ -164,7 +164,7 @@ std::string zeus::getMineType(std::string _extention) { return "unknow/" + _extention; } -std::string zeus::getExtention(std::string _mineType) { +etk::String zeus::getExtention(etk::String _mineType) { _mineType = etk::tolower(_mineType); for (auto &it : mineList) { if (it.second == _mineType) { diff --git a/zeus/mineType.hpp b/zeus/mineType.hpp index 5ecd42b..7417d03 100644 --- a/zeus/mineType.hpp +++ b/zeus/mineType.hpp @@ -12,12 +12,12 @@ namespace zeus { * @param[in] _extention file extention (without the '.') * @return The generic mine tipe in http format */ - std::string getMineType(std::string _extention); + etk::String getMineType(etk::String _extention); /** * @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(std::string _mineType); + etk::String getExtention(etk::String _mineType); }; diff --git a/zeus/zeus-File.impl.cpp b/zeus/zeus-File.impl.cpp index 23881d6..8906933 100644 --- a/zeus/zeus-File.impl.cpp +++ b/zeus/zeus-File.impl.cpp @@ -12,31 +12,31 @@ #include "debug.hpp" -ememory::SharedPtr zeus::File::create(std::string _fileNameReal) { +ememory::SharedPtr zeus::File::create(etk::String _fileNameReal) { return ememory::makeShared(_fileNameReal); } -ememory::SharedPtr zeus::File::create(std::string _fileNameReal, std::string _sha512) { +ememory::SharedPtr zeus::File::create(etk::String _fileNameReal, etk::String _sha512) { return ememory::makeShared(_fileNameReal, _sha512); } -ememory::SharedPtr zeus::File::create(std::string _fileNameReal, std::string _fileNameShow, std::string _mineType) { +ememory::SharedPtr zeus::File::create(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType) { return ememory::makeShared(_fileNameReal, _fileNameShow, _mineType); } -ememory::SharedPtr zeus::File::create(std::string _fileNameReal, std::string _fileNameShow, std::string _mineType, std::string _sha512) { +ememory::SharedPtr zeus::File::create(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512) { return ememory::makeShared(_fileNameReal, _fileNameShow, _mineType, _sha512); } -zeus::FileImpl::FileImpl(std::string _fileNameReal, std::string _sha512) : +zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _sha512) : m_filename(_fileNameReal), m_node(_fileNameReal), m_gettedData(0), m_sha512(_sha512) { m_size = m_node.fileSize(); - std::string extention; - if ( _fileNameReal.rfind('.') != std::string::npos + etk::String extention; + if ( _fileNameReal.rfind('.') != etk::String::npos && _fileNameReal.rfind('.') != 0) { - extention = std::string(_fileNameReal.begin()+_fileNameReal.rfind('.')+1, _fileNameReal.end()); + extention = etk::String(_fileNameReal.begin()+_fileNameReal.rfind('.')+1, _fileNameReal.end()); } m_mineType = zeus::getMineType(extention); if ( _sha512.size() > 0 @@ -48,7 +48,7 @@ zeus::FileImpl::FileImpl(std::string _fileNameReal, std::string _sha512) : // sha 512 example: 6134b4a4b5b116cf1b1b757c5aa48bd8b3482b86c6d3fee389a0a3232f74e7331e5f8af6ad516d2ca92eda0a475f44e1291618562ce6f9e54634ba052650dcd7 // 000000000100000000020000000003000000000400000000050000000006000000000700000000080000000009000000000A000000000B000000000C00000000 -zeus::FileImpl::FileImpl(std::string _fileNameReal, std::string _fileNameShow, std::string _mineType, std::string _sha512) : +zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512) : m_filename(_fileNameShow), m_node(_fileNameReal), m_gettedData(0), @@ -72,11 +72,11 @@ uint64_t zeus::FileImpl::getSize() { return m_size; } -std::string zeus::FileImpl::getName() { +etk::String zeus::FileImpl::getName() { return m_filename; } -std::string zeus::FileImpl::getSha512() { +etk::String zeus::FileImpl::getSha512() { if (m_sha512 == "") { ZEUS_INFO("calculation of sha 512 (start)"); m_sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_node.getFileSystemName())); @@ -85,18 +85,18 @@ std::string zeus::FileImpl::getSha512() { return m_sha512; } -std::string zeus::FileImpl::getMineType() { +etk::String zeus::FileImpl::getMineType() { return m_mineType; } zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) { if ((_stop - _start) > 25*1024*1024) { ZEUS_ERROR("REQUEST more that 25 Mo in a part file ..."); - throw std::invalid_argument("REQUEST more that 25 Mo in a part file ..." + etk::to_string(_stop - _start) + " Bytes"); + throw std::invalid_argument("REQUEST more that 25 Mo in a part file ..." + etk::toString(_stop - _start) + " Bytes"); return zeus::Raw(); } if (_start >= m_size) { - throw std::invalid_argument("REQUEST start position out of file size" + etk::to_string(_start) + " > " + etk::to_string(m_size)); + throw std::invalid_argument("REQUEST start position out of file size" + etk::toString(_start) + " > " + etk::toString(m_size)); } if (m_node.fileIsOpen() == false) { m_node.fileOpenRead(); @@ -115,15 +115,15 @@ zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) { m_node.fileClose(); } // TODO : Check if copy is correct ... - return std::move(tmp); + return etk::move(tmp); } -std::string zeus::storeInFile(zeus::ProxyFile _file, std::string _filename) { - zeus::ActionNotification tmp; +etk::String zeus::storeInFile(zeus::ProxyFile _file, etk::String _filename) { + zeus::ActionNotification tmp; return zeus::storeInFileNotify(_file, _filename, tmp); } -std::string zeus::storeInFileNotify(zeus::ProxyFile _file, std::string _filename, zeus::ActionNotification _notification) { +etk::String zeus::storeInFileNotify(zeus::ProxyFile _file, etk::String _filename, zeus::ActionNotification _notification) { auto futSize = _file.getSize(); auto futSha = _file.getSha512(); futSize.wait(); @@ -150,11 +150,11 @@ std::string zeus::storeInFileNotify(zeus::ProxyFile _file, std::string _filename offset += nbElement; retSize -= nbElement; ZEUS_VERBOSE("read: " << offset << "/" << futSize.get() << " " << buffer.size()); - _notification.notify("{\"pourcent\":" + etk::to_string(float(offset)/float(buffer.size())) + ", \"comment\":\"download\""); + _notification.notify("{\"pourcent\":" + etk::toString(float(offset)/float(buffer.size())) + ", \"comment\":\"download\""); } nodeFile.fileClose(); // get the final sha512 of the file: - std::string sha512String = algue::stringConvert(shaCtx.finalize()); + etk::String sha512String = algue::stringConvert(shaCtx.finalize()); futSha.wait(); if (sha512String != futSha.get()) { ZEUS_ERROR("get wrong Sha512 local : '" << sha512String << "'"); @@ -164,8 +164,8 @@ std::string zeus::storeInFileNotify(zeus::ProxyFile _file, std::string _filename return sha512String; } -std::vector zeus::storeInMemory(zeus::ProxyFile _file) { - std::vector out; +etk::Vector zeus::storeInMemory(zeus::ProxyFile _file) { + etk::Vector out; auto futSize = _file.getSize(); auto futSha = _file.getSha512(); futSize.wait(); @@ -195,7 +195,7 @@ std::vector zeus::storeInMemory(zeus::ProxyFile _file) { ZEUS_VERBOSE("read: " << offset << "/" << futSize.get() << " " << buffer.size()); } // get the final sha512 of the file: - std::string sha512String = algue::stringConvert(shaCtx.finalize()); + etk::String sha512String = algue::stringConvert(shaCtx.finalize()); futSha.wait(); if (sha512String != futSha.get()) { ZEUS_ERROR("get wrong Sha512 local : '" << sha512String << "'"); diff --git a/zeus/zeus-File.impl.hpp b/zeus/zeus-File.impl.hpp index f9aeb14..f618902 100644 --- a/zeus/zeus-File.impl.hpp +++ b/zeus/zeus-File.impl.hpp @@ -11,20 +11,20 @@ namespace zeus { class FileImpl : public zeus::File { private: - std::string m_filename; //!< Name of the file + etk::String m_filename; //!< Name of the file etk::FSNode m_node; //!< File node access size_t m_size; //!< Size of the file size_t m_gettedData; //!< Number of byte loaded by the remote client - std::string m_mineType; //!< Mine Type of the file - std::string m_sha512; //!< Global file sha-512 + etk::String m_mineType; //!< Mine Type of the file + etk::String m_sha512; //!< Global file sha-512 public: - FileImpl(std::string _fileNameReal, std::string _fileNameShow, std::string _mineType, std::string _sha512=""); - FileImpl(std::string _fileNameReal, std::string _sha512=""); + FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512=""); + FileImpl(etk::String _fileNameReal, etk::String _sha512=""); ~FileImpl(); uint64_t getSize() override; - std::string getName() override; - std::string getSha512() override; - std::string getMineType() override; + etk::String getName() override; + etk::String getSha512() override; + etk::String getMineType() override; zeus::Raw getPart(uint64_t _start, uint64_t _stop) override; }; diff --git a/zeus/zeus-Media.impl.cpp b/zeus/zeus-Media.impl.cpp index f957be9..41388c4 100644 --- a/zeus/zeus-Media.impl.cpp +++ b/zeus/zeus-Media.impl.cpp @@ -11,7 +11,7 @@ #include #include "debug.hpp" -ememory::SharedPtr zeus::Media::create(std::string _fileNameReal) { +ememory::SharedPtr zeus::Media::create(etk::String _fileNameReal) { return ememory::makeShared(0, _fileNameReal); } @@ -29,7 +29,7 @@ ejson::Object zeus::MediaImpl::getJson() { return out; } -zeus::MediaImpl::MediaImpl(const std::string& _basePath, ejson::Object _property) : +zeus::MediaImpl::MediaImpl(const etk::String& _basePath, ejson::Object _property) : m_basePath(_basePath) { m_id = _property["id"].toNumber().getU64(); ZEUS_INFO("get ID : " << m_id); @@ -39,7 +39,7 @@ zeus::MediaImpl::MediaImpl(const std::string& _basePath, ejson::Object _property for (auto itValue = tmpObj.begin(); itValue != tmpObj.end(); ++itValue) { - m_metadata.insert(std::make_pair(itValue.getKey(), (*itValue).toString().get())); + m_metadata.insert(etk::makePair(itValue.getKey(), (*itValue).toString().get())); } } } @@ -48,15 +48,15 @@ uint64_t zeus::MediaImpl::getUniqueId() { return m_id; } -zeus::MediaImpl::MediaImpl(uint64_t _id, const std::string& _fileNameReal, const std::string& _basePath): +zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const etk::String& _basePath): m_id(_id), m_basePath(_basePath), m_fileName(_fileNameReal) { - std::string extention; - if ( m_fileName.rfind('.') != std::string::npos + etk::String extention; + if ( m_fileName.rfind('.') != etk::String::npos && m_fileName.rfind('.') != 0) { - extention = etk::tolower(std::string(m_fileName.begin()+m_fileName.rfind('.')+1, m_fileName.end())); - m_fileName = std::string(m_fileName.begin(), m_fileName.begin()+m_fileName.rfind('.')); + extention = etk::tolower(etk::String(m_fileName.begin()+m_fileName.rfind('.')+1, m_fileName.end())); + m_fileName = etk::String(m_fileName.begin(), m_fileName.begin()+m_fileName.rfind('.')); } if (extention != "") { setMetadata("mime-type", zeus::getMineType(extention)); @@ -68,18 +68,18 @@ zeus::MediaImpl::~MediaImpl() { } -std::string zeus::MediaImpl::getMineType() { +etk::String zeus::MediaImpl::getMineType() { return getMetadata("mime-type"); } -std::string zeus::MediaImpl::getSha512() { +etk::String zeus::MediaImpl::getSha512() { try { return getMetadata("sha512"); } catch (std::invalid_argument _eee) { // Nothing to do ... } - std::string sha512; + etk::String sha512; auto it = m_metadata.find("mime-type"); if (it != m_metadata.end()) { sha512 = algue::stringConvert(algue::sha512::encodeFromFile(m_basePath + m_fileName + "." + zeus::getExtention(it->second))); @@ -93,13 +93,13 @@ std::string zeus::MediaImpl::getSha512() { void zeus::MediaImpl::forceUpdateDecoratedName() { // force the new calculation .. - std::string value = getDecoratedNameFrom(m_metadata); + etk::String value = getDecoratedNameFrom(m_metadata); setMetadata("decorated-name", value); } -std::string zeus::MediaImpl::getDecoratedName() { +etk::String zeus::MediaImpl::getDecoratedName() { try { - std::string out = getMetadata("decorated-name"); + etk::String out = getMetadata("decorated-name"); if (out != "") { return out; } @@ -107,7 +107,7 @@ std::string zeus::MediaImpl::getDecoratedName() { // Nothing to do ... } // Store the metadat to not calculated it all the time ... - std::string value = getDecoratedNameFrom(m_metadata); + etk::String value = getDecoratedNameFrom(m_metadata); setMetadata("decorated-name", value); return value; } @@ -121,15 +121,15 @@ ememory::SharedPtr zeus::MediaImpl::getFile() { return zeus::File::create(m_basePath + m_fileName, "", ""); } -std::vector zeus::MediaImpl::getMetadataKeys() { - std::vector out; +etk::Vector zeus::MediaImpl::getMetadataKeys() { + etk::Vector out; for (auto &it : m_metadata) { - out.push_back(it.first); + out.pushBack(it.first); } return out; } -std::string zeus::MediaImpl::getMetadata(std::string _key) { +etk::String zeus::MediaImpl::getMetadata(etk::String _key) { auto it = m_metadata.find(_key); if (it != m_metadata.end()) { return it->second; @@ -137,7 +137,7 @@ std::string zeus::MediaImpl::getMetadata(std::string _key) { throw std::invalid_argument("KEY '" + _key + "' Does not exist"); } -void zeus::MediaImpl::setMetadata(std::string _key, std::string _value) { +void zeus::MediaImpl::setMetadata(etk::String _key, etk::String _value) { ZEUS_INFO("metadataSetKey: '" << _key << "' value='" << _value << "'"); auto it = m_metadata.find(_key); if (it != m_metadata.end()) { @@ -149,7 +149,7 @@ void zeus::MediaImpl::setMetadata(std::string _key, std::string _value) { it->second = _value; } } else { - m_metadata.insert(std::make_pair(_key, _value)); + m_metadata.insert(etk::makePair(_key, _value)); } // hook to remove some case that does not call the callback ==> can change many times ... if ( _key == "sha512" @@ -171,7 +171,7 @@ bool zeus::MediaImpl::erase() { return etk::FSNodeRemove(m_basePath + m_fileName); } -bool zeus::MediaImpl::move(const std::string& _newOffsetFile) { +bool zeus::MediaImpl::move(const etk::String& _newOffsetFile) { ZEUS_INFO("move file : '" << m_basePath + m_fileName << "' ==> " << m_basePath + _newOffsetFile << "'"); if (_newOffsetFile == m_fileName) { // nothing to do ... @@ -194,7 +194,7 @@ bool zeus::MediaImpl::move(const std::string& _newOffsetFile) { -std::string zeus::MediaImpl::getMetadataFrom(const std::map& _metadata, std::string _key) { +etk::String zeus::MediaImpl::getMetadataFrom(const etk::Map& _metadata, etk::String _key) { auto it = _metadata.find(_key); if (it != _metadata.end()) { return it->second; @@ -202,21 +202,21 @@ std::string zeus::MediaImpl::getMetadataFrom(const std::map& _metadata) { - std::string basePath; - std::string type = getMetadataFrom(_metadata, "type"); - std::string title = getMetadataFrom(_metadata, "title"); +etk::String zeus::MediaImpl::getDecoratedNameFrom(const etk::Map& _metadata) { + etk::String basePath; + etk::String type = getMetadataFrom(_metadata, "type"); + etk::String title = getMetadataFrom(_metadata, "title"); /* ZEUS_INFO("---- : " << type << " " << title << " "); for (auto &it: _metadata) { ZEUS_INFO(" " << it.first << " " << it.second); } */ - std::string out; + etk::String out; if (type == "film") { - std::string productionMethode = getMetadataFrom(_metadata, "production-methode"); - std::string serie = getMetadataFrom(_metadata, "series-name"); - std::string episode = getMetadataFrom(_metadata, "episode"); + etk::String productionMethode = getMetadataFrom(_metadata, "production-methode"); + etk::String serie = getMetadataFrom(_metadata, "series-name"); + etk::String episode = getMetadataFrom(_metadata, "episode"); if (productionMethode == "picture") { // real film with real human basePath += "film/"; @@ -236,10 +236,10 @@ std::string zeus::MediaImpl::getDecoratedNameFrom(const std::map simple sharing of files - std::string path = getMetadataFrom(_metadata, "path"); + etk::String path = getMetadataFrom(_metadata, "path"); basePath += type + "/"; if (path != "") { basePath += path + "/"; } } else { - std::string author = getMetadataFrom(_metadata, "author"); - std::string group = getMetadataFrom(_metadata, "group"); - std::string episode = getMetadataFrom(_metadata, "episode"); - std::string serie = getMetadataFrom(_metadata, "series-name"); + etk::String author = getMetadataFrom(_metadata, "author"); + etk::String group = getMetadataFrom(_metadata, "group"); + etk::String episode = getMetadataFrom(_metadata, "episode"); + etk::String serie = getMetadataFrom(_metadata, "series-name"); basePath += "unknow/"; if (author != "") { out += author + "-"; @@ -348,7 +348,7 @@ std::string zeus::MediaImpl::getDecoratedNameFrom(const std::map m_metadata; //!< all extra property - std::function m_callback; + etk::String m_basePath; //!< basic global path + etk::String m_fileName; //!< Name of the file + etk::Map m_metadata; //!< all extra property + std::function m_callback; public: - void setCallbackMetadataChange(std::function _callback) { + void setCallbackMetadataChange(std::function _callback) { m_callback = _callback; } public: /** * @brief Generic json constructor */ - MediaImpl(const std::string& _basePath, ejson::Object _property); + MediaImpl(const etk::String& _basePath, ejson::Object _property); /** * @brief Generic file constructor */ - MediaImpl(uint64_t _id, const std::string& _fileNameReal, const std::string& _basePath=""); + MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const etk::String& _basePath=""); /** * @brief Generic destructor */ ~MediaImpl(); uint64_t getUniqueId() override; - std::string getMineType() override; + etk::String getMineType() override; ememory::SharedPtr getFile() override; - std::vector getMetadataKeys() override; - std::string getMetadata(std::string _key) override; - void setMetadata(std::string _key, std::string _value) override; - std::string getSha512() override; - std::string getDecoratedName() override; + etk::Vector getMetadataKeys() override; + etk::String getMetadata(etk::String _key) override; + void setMetadata(etk::String _key, etk::String _value) override; + etk::String getSha512() override; + etk::String getDecoratedName() override; /** * @brief Export json property * @return A json Object with data */ ejson::Object getJson(); - const std::string& getFileName() { + const etk::String& getFileName() { return m_fileName; } bool erase(); - bool move(const std::string& _newOffsetFile); - const std::map& getMetadataDirect() { + bool move(const etk::String& _newOffsetFile); + const etk::Map& getMetadataDirect() { return m_metadata; } void forceUpdateDecoratedName(); public: // local tools: - static std::string getMetadataFrom(const std::map& _metadata, std::string _key); - static std::string getDecoratedNameFrom(const std::map& _metadata); + static etk::String getMetadataFrom(const etk::Map& _metadata, etk::String _key); + static etk::String getDecoratedNameFrom(const etk::Map& _metadata); }; } diff --git a/zeus/zeus.cpp b/zeus/zeus.cpp index 906c69b..27a36ab 100644 --- a/zeus/zeus.cpp +++ b/zeus/zeus.cpp @@ -14,7 +14,7 @@ static bool& getInitSatatus() { void zeus::init(int _argc, const char** _argv) { for (int32_t iii=0; iii<_argc; ++iii) { - std::string value = _argv[iii]; + etk::String value = _argv[iii]; if (etk::start_with(value, "--zeus") == true) { ZEUS_ERROR("Unknow parameter type: '" << value << "'"); }