[DEV] continue removing stl
This commit is contained in:
parent
ce60711d56
commit
b1b52cef16
@ -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<bool>"],
|
||||
["vector:string", "std::vector<std::string>"],
|
||||
["vector:int8", "std::vector<int8_t>"],
|
||||
["vector:int16", "std::vector<int16_t>"],
|
||||
["vector:int32", "std::vector<int32_t>"],
|
||||
["vector:int64", "std::vector<int64_t>"],
|
||||
["vector:uint8", "std::vector<uint8_t>"],
|
||||
["vector:uint16", "std::vector<uint16_t>"],
|
||||
["vector:uint32", "std::vector<uint32_t>"],
|
||||
["vector:uint64", "std::vector<uint64_t>"],
|
||||
["vector:float32", "std::vector<float>"],
|
||||
["vector:float64", "std::vector<double>"],
|
||||
["vector:bool", "etk::Vector<bool>"],
|
||||
["vector:string", "etk::Vector<etk::String>"],
|
||||
["vector:int8", "etk::Vector<int8_t>"],
|
||||
["vector:int16", "etk::Vector<int16_t>"],
|
||||
["vector:int32", "etk::Vector<int32_t>"],
|
||||
["vector:int64", "etk::Vector<int64_t>"],
|
||||
["vector:uint8", "etk::Vector<uint8_t>"],
|
||||
["vector:uint16", "etk::Vector<uint16_t>"],
|
||||
["vector:uint32", "etk::Vector<uint32_t>"],
|
||||
["vector:uint64", "etk::Vector<uint64_t>"],
|
||||
["vector:float32", "etk::Vector<float>"],
|
||||
["vector:float64", "etk::Vector<double>"],
|
||||
["duration", "echrono::Duration"],
|
||||
["time", "echrono::Time"],
|
||||
["file", "zeus::File"],
|
||||
["stream", "zeus::Stream"],
|
||||
["json", "ejson::Object"],
|
||||
["raw", "zeus::Raw"],
|
||||
["ActionNotif", "zeus::ActionNotification<std::string>"],
|
||||
["ActionNotif", "zeus::ActionNotification<etk::String>"],
|
||||
]
|
||||
|
||||
|
||||
@ -439,8 +439,8 @@ class ServiceDefinition:
|
||||
out += "#include <etk/types.hpp>\n"
|
||||
out += "#include <eproperty/Value.hpp>\n"
|
||||
out += "#include <zeus/Raw.hpp>\n"
|
||||
out += "#include <string>\n"
|
||||
out += "#include <vector>\n"
|
||||
out += "#include <etk/String.hpp>\n"
|
||||
out += "#include <etk/Vector.hpp>\n"
|
||||
out += "#include <ememory/memory.hpp>\n"
|
||||
out += "#include <zeus/ActionNotification.hpp>\n"
|
||||
for elem in self.imports:
|
||||
@ -540,7 +540,7 @@ class ServiceDefinition:
|
||||
out += " \n"
|
||||
out += " template<>\n"
|
||||
out += " void Parameter::addParameter<ememory::SharedPtr<" + self.prop["name_class"] + ">>(uint16_t _paramId, const ememory::SharedPtr<" + self.prop["name_class"] + ">& _value) {\n"
|
||||
out += " std::vector<uint8_t> data;\n"
|
||||
out += " etk::Vector<uint8_t> 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 <zeus/Object.hpp>\n"
|
||||
out += "#include <zeus/Client.hpp>\n"
|
||||
out += "#include <" + self.prop["file_name_class_header"] + ">\n"
|
||||
out += "#include <string>\n"
|
||||
out += "#include <vector>\n"
|
||||
out += "#include <etk/String.hpp>\n"
|
||||
out += "#include <etk/Vector.hpp>\n"
|
||||
out += "\n"
|
||||
space = ""
|
||||
for elem in self.name[:-1]:
|
||||
@ -713,8 +713,8 @@ class ServiceDefinition:
|
||||
out += "#include <zeus/ObjectRemote.hpp>\n"
|
||||
out += "#include <zeus/Proxy.hpp>\n"
|
||||
out += "#include <zeus/RemoteProperty.hpp>\n"
|
||||
out += "#include <string>\n"
|
||||
out += "#include <vector>\n"
|
||||
out += "#include <etk/String.hpp>\n"
|
||||
out += "#include <etk/Vector.hpp>\n"
|
||||
out += "#include <" + self.prop["file_name_class_header"] + ">\n"
|
||||
for elem in self.imports:
|
||||
prop = zeus_object_to_dictionary(elem)
|
||||
|
@ -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<int32_t> retNbService = client1.getServiceCount();
|
||||
zeus::Future<std::vector<std::string>> retServiceList = client1.getServiceList();
|
||||
zeus::Future<etk::Vector<etk::String>> retServiceList = client1.getServiceList();
|
||||
retNbService.wait();
|
||||
APPL_INFO("Nb services = " << retNbService.get());
|
||||
retServiceList.wait();
|
||||
|
@ -25,10 +25,10 @@
|
||||
#include <zeus/zeus-Media.impl.hpp>
|
||||
|
||||
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<ememory::SharedPtr<zeus::MediaImpl>> m_listFile;
|
||||
static etk::Vector<ememory::SharedPtr<zeus::MediaImpl>> 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<uint32_t> getVU32(std::vector<uint32_t> _value) override {
|
||||
etk::Vector<uint32_t> getVU32(etk::Vector<uint32_t> _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<std::mutex> lock(g_mutex);
|
||||
APPL_INFO("Load USER: " << g_basePath);
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include <zeus/FutureGroup.hpp>
|
||||
#include <algue/sha512.hpp>
|
||||
|
||||
static std::string extractAndRemove(const std::string& _inputValue, const char _startMark, const char _stopMark, std::vector<std::string>& _values) {
|
||||
static etk::String extractAndRemove(const etk::String& _inputValue, const char _startMark, const char _stopMark, etk::Vector<etk::String>& _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<std::string,std::string> _basicKey = std::map<std::string,std::string>()) {
|
||||
std::string extention;
|
||||
if ( _path.rfind('.') != std::string::npos
|
||||
bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,std::string>()) {
|
||||
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<std::string> dates;
|
||||
etk::Vector<etk::String> 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<std::string,std::string>("date", it));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("title2", it));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("title2", it));
|
||||
}
|
||||
}
|
||||
// remove unneeded date
|
||||
if (haveDate == false) {
|
||||
_basicKey.insert(std::pair<std::string,std::string>("date", ""));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("date", ""));
|
||||
}
|
||||
// remove unneeded title 2
|
||||
if (haveTitle == false) {
|
||||
_basicKey.insert(std::pair<std::string,std::string>("title2", ""));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("title2", ""));
|
||||
}
|
||||
// Remove the actors [XXX YYY][EEE TTT]...
|
||||
std::vector<std::string> acthors;
|
||||
etk::Vector<etk::String> 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<std::string,std::string>("acthors", actorList));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string> listElementBase = etk::split(fileName, '-');
|
||||
etk::Vector<etk::String> listElementBase = etk::split(fileName, '-');
|
||||
|
||||
std::vector<std::string> listElement;
|
||||
std::string tmpStartString;
|
||||
etk::Vector<etk::String> listElement;
|
||||
etk::String tmpStartString;
|
||||
for (size_t iii=0; iii<listElementBase.size(); ++iii) {
|
||||
if ( listElementBase[iii][0] != 's'
|
||||
&& listElementBase[iii][0] != 'e') {
|
||||
@ -226,20 +226,20 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map<
|
||||
}
|
||||
tmpStartString += listElementBase[iii];
|
||||
} else {
|
||||
listElement.push_back(tmpStartString);
|
||||
listElement.pushBack(tmpStartString);
|
||||
tmpStartString = "";
|
||||
for (/* nothing to do */; iii<listElementBase.size(); ++iii) {
|
||||
listElement.push_back(listElementBase[iii]);
|
||||
listElement.pushBack(listElementBase[iii]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (tmpStartString != "") {
|
||||
listElement.push_back(tmpStartString);
|
||||
listElement.pushBack(tmpStartString);
|
||||
}
|
||||
if (listElement.size() == 1) {
|
||||
// nothing to do , it might be a film ...
|
||||
_basicKey.insert(std::pair<std::string,std::string>("title", etk::to_string(listElement[0])));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("series-name", etk::to_string(seriesName)));
|
||||
std::string fullEpisodeName = listElement[3];
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("series-name", etk::toString(seriesName)));
|
||||
etk::String fullEpisodeName = listElement[3];
|
||||
for (int32_t yyy=4; yyy<listElement.size(); ++yyy) {
|
||||
fullEpisodeName += "-" + listElement[yyy];
|
||||
}
|
||||
_basicKey.insert(std::pair<std::string,std::string>("title", etk::to_string(fullEpisodeName)));
|
||||
if (std::string(&listElement[1][1]) == "XX") {
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("episode", etk::to_string(episode)));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("saison", etk::to_string(saison)));
|
||||
saisonPrint = "0" + etk::toString(saison);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("saison", etk::toString(saison)));
|
||||
} else {
|
||||
saisonPrint = etk::to_string(saison);
|
||||
_basicKey.insert(std::pair<std::string,std::string>("saison", etk::to_string(saison)));
|
||||
saisonPrint = etk::toString(saison);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("saison", etk::toString(saison)));
|
||||
}
|
||||
if (episode < 0) {
|
||||
// nothing to do
|
||||
} else if(episode < 10) {
|
||||
episodePrint = "0" + etk::to_string(episode);
|
||||
_basicKey.insert(std::pair<std::string,std::string>("episode", etk::to_string(episode)));
|
||||
episodePrint = "0" + etk::toString(episode);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("episode", etk::toString(episode)));
|
||||
} else {
|
||||
episodePrint = etk::to_string(episode);
|
||||
_basicKey.insert(std::pair<std::string,std::string>("episode", etk::to_string(episode)));
|
||||
episodePrint = etk::toString(episode);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string> _basicKey = std::map<std::string,std::string>()) {
|
||||
void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,std::string>()) {
|
||||
etk::FSNode node(_path);
|
||||
APPL_INFO("Parse : '" << _path << "'");
|
||||
std::vector<std::string> listSubPath = node.folderGetSub(true, false, "*");
|
||||
etk::Vector<etk::String> listSubPath = node.folderGetSub(true, false, "*");
|
||||
for (auto &itPath : listSubPath) {
|
||||
std::map<std::string,std::string> basicKeyTmp = _basicKey;
|
||||
etk::Map<etk::String,etk::String> 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<std::string,std::string>("type", "film"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "picture"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "film"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "picture"));
|
||||
} else if (lastPathName == "film-annimation") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "film"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "draw"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "film"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "draw"));
|
||||
} else if (lastPathName == "film-short") { // short films
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "film"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "short"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "film"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "short"));
|
||||
} else if (lastPathName == "tv-show") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "tv-show"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "picture"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "tv-show"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "picture"));
|
||||
} else if (lastPathName == "tv-show-annimation") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "tv-show"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "draw"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "tv-show"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "draw"));
|
||||
} else if (lastPathName == "theater") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "theater"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "theater"));
|
||||
} else if (lastPathName == "one-man") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "one-man"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "one-man"));
|
||||
}
|
||||
} else {
|
||||
APPL_INFO("find B '" << lastPathName << "' " << basicKeyTmp.size());
|
||||
if (lastPathName == "saison_01") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "1"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "1"));
|
||||
} else if (lastPathName == "saison_02") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "2"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "2"));
|
||||
} else if (lastPathName == "saison_03") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "3"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "3"));
|
||||
} else if (lastPathName == "saison_04") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "4"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "4"));
|
||||
} else if (lastPathName == "saison_05") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "5"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "5"));
|
||||
} else if (lastPathName == "saison_06") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "6"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "6"));
|
||||
} else if (lastPathName == "saison_07") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "7"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "7"));
|
||||
} else if (lastPathName == "saison_08") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "8"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "8"));
|
||||
} else if (lastPathName == "saison_09") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "9"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "9"));
|
||||
} else if (lastPathName == "saison_10") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "10"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "10"));
|
||||
} else if (lastPathName == "saison_11") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "11"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "11"));
|
||||
} else if (lastPathName == "saison_12") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "12"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "12"));
|
||||
} else if (lastPathName == "saison_13") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "13"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "13"));
|
||||
} else if (lastPathName == "saison_14") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "14"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "14"));
|
||||
} else if (lastPathName == "saison_15") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "15"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "15"));
|
||||
} else if (lastPathName == "saison_16") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "16"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "16"));
|
||||
} else if (lastPathName == "saison_17") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "17"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "17"));
|
||||
} else if (lastPathName == "saison_18") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "18"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "18"));
|
||||
} else if (lastPathName == "saison_19") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "19"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "19"));
|
||||
} else if (lastPathName == "saison_20") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "20"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "20"));
|
||||
} else if (lastPathName == "saison_21") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "21"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "21"));
|
||||
} else if (lastPathName == "saison_22") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "22"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "22"));
|
||||
} else if (lastPathName == "saison_23") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "23"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "23"));
|
||||
} else if (lastPathName == "saison_24") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "24"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "24"));
|
||||
} else if (lastPathName == "saison_25") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "25"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "25"));
|
||||
} else if (lastPathName == "saison_26") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "26"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "26"));
|
||||
} else if (lastPathName == "saison_27") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "27"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "27"));
|
||||
} else if (lastPathName == "saison_28") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "28"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "28"));
|
||||
} else if (lastPathName == "saison_29") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "29"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "29"));
|
||||
} else {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("series-name", lastPathName));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("series-name", lastPathName));
|
||||
}
|
||||
}
|
||||
installVideoPath(_srv, itPath, basicKeyTmp);
|
||||
}
|
||||
// Add files :
|
||||
std::vector<std::string> listSubFile = node.folderGetSub(false, true, "*");
|
||||
etk::Vector<etk::String> listSubFile = node.folderGetSub(false, true, "*");
|
||||
for (auto &itFile : listSubFile) {
|
||||
|
||||
std::map<std::string,std::string> basicKeyTmp = _basicKey;
|
||||
etk::Map<etk::String,etk::String> 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<std::string> args;
|
||||
etk::String pass = "coucou";
|
||||
etk::String requestAction = "";
|
||||
etk::Vector<etk::String> 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<std::string> listElem = etk::split(&data[8], '~');
|
||||
etk::Vector<etk::String> 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<std::string> listElem2 = etk::split(listElem[1], ':');
|
||||
etk::Vector<etk::String> 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<count ; iii += 1024) {
|
||||
uint32_t tmpMax = std::min(iii + 1024, count);
|
||||
uint32_t tmpMax = etk::min(iii + 1024, count);
|
||||
APPL_DEBUG("read section " << iii << " -> " << tmpMax);
|
||||
std::vector<uint32_t> list = remoteServiceVideo.getIds(iii,tmpMax).wait().get();
|
||||
etk::Vector<uint32_t> 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<count ; iii += 1024) {
|
||||
uint32_t tmpMax = std::min(iii + 1024, count);
|
||||
uint32_t tmpMax = etk::min(iii + 1024, count);
|
||||
APPL_DEBUG("read section " << iii << " -> " << tmpMax);
|
||||
std::vector<uint32_t> list = remoteServiceVideo.getIds(iii, tmpMax).wait().get();
|
||||
etk::Vector<uint32_t> 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 + "-";
|
||||
}
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <zeus/FutureGroup.hpp>
|
||||
#include <algue/sha512.hpp>
|
||||
|
||||
static std::string extractAndRemove(const std::string& _inputValue, const char _startMark, const char _stopMark, std::vector<std::string>& _values) {
|
||||
static etk::String extractAndRemove(const etk::String& _inputValue, const char _startMark, const char _stopMark, etk::Vector<etk::String>& _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<std::string,std::string> _basicKey = std::map<std::string,std::string>()) {
|
||||
std::string extention;
|
||||
if ( _path.rfind('.') != std::string::npos
|
||||
bool pushVideoFile(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,std::string>()) {
|
||||
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<std::string> dates;
|
||||
etk::Vector<etk::String> 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<std::string,std::string>("date", it));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("title2", it));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("title2", it));
|
||||
}
|
||||
}
|
||||
// remove unneeded date
|
||||
if (haveDate == false) {
|
||||
_basicKey.insert(std::pair<std::string,std::string>("date", ""));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("date", ""));
|
||||
}
|
||||
// remove unneeded title 2
|
||||
if (haveTitle == false) {
|
||||
_basicKey.insert(std::pair<std::string,std::string>("title2", ""));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("title2", ""));
|
||||
}
|
||||
// Remove the actors [XXX YYY][EEE TTT]...
|
||||
std::vector<std::string> acthors;
|
||||
etk::Vector<etk::String> 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<std::string,std::string>("acthors", actorList));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string> listElementBase = etk::split(fileName, '-');
|
||||
etk::Vector<etk::String> listElementBase = etk::split(fileName, '-');
|
||||
|
||||
std::vector<std::string> listElement;
|
||||
std::string tmpStartString;
|
||||
etk::Vector<etk::String> listElement;
|
||||
etk::String tmpStartString;
|
||||
for (size_t iii=0; iii<listElementBase.size(); ++iii) {
|
||||
if ( listElementBase[iii][0] != 's'
|
||||
&& listElementBase[iii][0] != 'e') {
|
||||
@ -203,20 +203,20 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map<
|
||||
}
|
||||
tmpStartString += listElementBase[iii];
|
||||
} else {
|
||||
listElement.push_back(tmpStartString);
|
||||
listElement.pushBack(tmpStartString);
|
||||
tmpStartString = "";
|
||||
for (/* nothing to do */; iii<listElementBase.size(); ++iii) {
|
||||
listElement.push_back(listElementBase[iii]);
|
||||
listElement.pushBack(listElementBase[iii]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (tmpStartString != "") {
|
||||
listElement.push_back(tmpStartString);
|
||||
listElement.pushBack(tmpStartString);
|
||||
}
|
||||
if (listElement.size() == 1) {
|
||||
// nothing to do , it might be a film ...
|
||||
_basicKey.insert(std::pair<std::string,std::string>("title", etk::to_string(listElement[0])));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("series-name", etk::to_string(seriesName)));
|
||||
std::string fullEpisodeName = listElement[3];
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("series-name", etk::toString(seriesName)));
|
||||
etk::String fullEpisodeName = listElement[3];
|
||||
for (int32_t yyy=4; yyy<listElement.size(); ++yyy) {
|
||||
fullEpisodeName += "-" + listElement[yyy];
|
||||
}
|
||||
_basicKey.insert(std::pair<std::string,std::string>("title", etk::to_string(fullEpisodeName)));
|
||||
if (std::string(&listElement[1][1]) == "XX") {
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("episode", etk::to_string(episode)));
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string>("saison", etk::to_string(saison)));
|
||||
saisonPrint = "0" + etk::toString(saison);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("saison", etk::toString(saison)));
|
||||
} else {
|
||||
saisonPrint = etk::to_string(saison);
|
||||
_basicKey.insert(std::pair<std::string,std::string>("saison", etk::to_string(saison)));
|
||||
saisonPrint = etk::toString(saison);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("saison", etk::toString(saison)));
|
||||
}
|
||||
if (episode < 0) {
|
||||
// nothing to do
|
||||
} else if(episode < 10) {
|
||||
episodePrint = "0" + etk::to_string(episode);
|
||||
_basicKey.insert(std::pair<std::string,std::string>("episode", etk::to_string(episode)));
|
||||
episodePrint = "0" + etk::toString(episode);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("episode", etk::toString(episode)));
|
||||
} else {
|
||||
episodePrint = etk::to_string(episode);
|
||||
_basicKey.insert(std::pair<std::string,std::string>("episode", etk::to_string(episode)));
|
||||
episodePrint = etk::toString(episode);
|
||||
_basicKey.insert(etk::Pair<etk::String,etk::String>("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<std::string,std::string> _basicKey = std::map<std::string,std::string>()) {
|
||||
void installVideoPath(zeus::service::ProxyVideo& _srv, etk::String _path, etk::Map<etk::String,etk::String> _basicKey = etk::Map<etk::String,std::string>()) {
|
||||
etk::FSNode node(_path);
|
||||
APPL_INFO("Parse : '" << _path << "'");
|
||||
std::vector<std::string> listSubPath = node.folderGetSub(true, false, "*");
|
||||
etk::Vector<etk::String> listSubPath = node.folderGetSub(true, false, "*");
|
||||
for (auto &itPath : listSubPath) {
|
||||
std::map<std::string,std::string> basicKeyTmp = _basicKey;
|
||||
etk::Map<etk::String,etk::String> 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<std::string,std::string>("type", "film"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "picture"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "film"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "picture"));
|
||||
} else if (lastPathName == "film-annimation") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "film"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "draw"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "film"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "draw"));
|
||||
} else if (lastPathName == "film-short") { // short films
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "film"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "short"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "film"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "short"));
|
||||
} else if (lastPathName == "tv-show") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "tv-show"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "picture"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "tv-show"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "picture"));
|
||||
} else if (lastPathName == "tv-show-annimation") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "tv-show"));
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("production-methode", "draw"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "tv-show"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("production-methode", "draw"));
|
||||
} else if (lastPathName == "theater") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "theater"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "theater"));
|
||||
} else if (lastPathName == "one-man") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("type", "one-man"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("type", "one-man"));
|
||||
}
|
||||
} else {
|
||||
APPL_INFO("find B '" << lastPathName << "' " << basicKeyTmp.size());
|
||||
if (lastPathName == "saison_01") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "1"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "1"));
|
||||
} else if (lastPathName == "saison_02") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "2"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "2"));
|
||||
} else if (lastPathName == "saison_03") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "3"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "3"));
|
||||
} else if (lastPathName == "saison_04") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "4"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "4"));
|
||||
} else if (lastPathName == "saison_05") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "5"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "5"));
|
||||
} else if (lastPathName == "saison_06") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "6"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "6"));
|
||||
} else if (lastPathName == "saison_07") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "7"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "7"));
|
||||
} else if (lastPathName == "saison_08") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "8"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "8"));
|
||||
} else if (lastPathName == "saison_09") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "9"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "9"));
|
||||
} else if (lastPathName == "saison_10") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "10"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "10"));
|
||||
} else if (lastPathName == "saison_11") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "11"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "11"));
|
||||
} else if (lastPathName == "saison_12") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "12"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "12"));
|
||||
} else if (lastPathName == "saison_13") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "13"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "13"));
|
||||
} else if (lastPathName == "saison_14") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "14"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "14"));
|
||||
} else if (lastPathName == "saison_15") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "15"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "15"));
|
||||
} else if (lastPathName == "saison_16") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "16"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "16"));
|
||||
} else if (lastPathName == "saison_17") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "17"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "17"));
|
||||
} else if (lastPathName == "saison_18") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "18"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "18"));
|
||||
} else if (lastPathName == "saison_19") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "19"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "19"));
|
||||
} else if (lastPathName == "saison_20") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "20"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "20"));
|
||||
} else if (lastPathName == "saison_21") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "21"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "21"));
|
||||
} else if (lastPathName == "saison_22") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "22"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "22"));
|
||||
} else if (lastPathName == "saison_23") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "23"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "23"));
|
||||
} else if (lastPathName == "saison_24") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "24"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "24"));
|
||||
} else if (lastPathName == "saison_25") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "25"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "25"));
|
||||
} else if (lastPathName == "saison_26") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "26"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "26"));
|
||||
} else if (lastPathName == "saison_27") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "27"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "27"));
|
||||
} else if (lastPathName == "saison_28") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "28"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "28"));
|
||||
} else if (lastPathName == "saison_29") {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("saison", "29"));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("saison", "29"));
|
||||
} else {
|
||||
basicKeyTmp.insert(std::pair<std::string,std::string>("series-name", lastPathName));
|
||||
basicKeyTmp.insert(etk::Pair<etk::String,etk::String>("series-name", lastPathName));
|
||||
}
|
||||
}
|
||||
installVideoPath(_srv, itPath, basicKeyTmp);
|
||||
}
|
||||
// Add files :
|
||||
std::vector<std::string> listSubFile = node.folderGetSub(false, true, "*");
|
||||
etk::Vector<etk::String> listSubFile = node.folderGetSub(false, true, "*");
|
||||
for (auto &itFile : listSubFile) {
|
||||
|
||||
std::map<std::string,std::string> basicKeyTmp = _basicKey;
|
||||
etk::Map<etk::String,etk::String> 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<std::string> args;
|
||||
etk::String pass = "coucou";
|
||||
etk::String requestAction = "";
|
||||
etk::Vector<etk::String> 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<std::string> listElem = etk::split(&data[8], '~');
|
||||
etk::Vector<etk::String> 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<std::string> listElem2 = etk::split(listElem[1], ':');
|
||||
etk::Vector<etk::String> 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<int32_t> retNbService = client1.getServiceCount();
|
||||
zeus::Future<std::vector<std::string>> retServiceList = client1.getServiceList();
|
||||
zeus::Future<etk::Vector<etk::String>> 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<std::vector<std::string>> retServiceList = client1.getServiceList();
|
||||
zeus::Future<etk::Vector<etk::String>> 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<std::vector<std::string>> retServiceList = client1.getServiceList();
|
||||
zeus::Future<etk::Vector<etk::String>> retServiceList = client1.getServiceList();
|
||||
retServiceList.wait();
|
||||
bool exist = false;
|
||||
for (auto &it: retServiceList.get()) {
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
#include <zeus/AbstractFunction.hpp>
|
||||
|
||||
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<std::string> listValue = etk::split(tmpURI, '?');
|
||||
etk::Vector<etk::String> 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<zeus::Message> _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);
|
||||
|
@ -20,8 +20,8 @@ namespace appl {
|
||||
bool start(appl::GateWay* _gateway);
|
||||
void receive(ememory::SharedPtr<zeus::Message> _data);
|
||||
void send(ememory::SharedPtr<zeus::Message> _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;
|
||||
}
|
||||
|
@ -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<appl::DirectInterface> tmp = ememory::makeShared<appl::DirectInterface>(std::move(_connection));
|
||||
ememory::SharedPtr<appl::DirectInterface> tmp = ememory::makeShared<appl::DirectInterface>(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<appl::IOInterface>& _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<std::string> appl::GateWay::getAllServiceName() {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> appl::GateWay::getAllServiceName() {
|
||||
etk::Vector<etk::String> out;
|
||||
// TODO : Change this it is old and deprecated ...
|
||||
for (auto &it : m_listIO) {
|
||||
if (it == nullptr) {
|
||||
@ -183,7 +183,7 @@ std::vector<std::string> 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<zeus::Message> _data) {
|
||||
|
||||
void appl::GateWay::cleanIO() {
|
||||
APPL_VERBOSE("Check if something need to be clean ...");
|
||||
std::vector<uint16_t> tmpIDToRemove;
|
||||
etk::Vector<uint16_t> 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;
|
||||
}
|
||||
|
@ -18,17 +18,17 @@ namespace appl {
|
||||
ememory::SharedPtr<appl::RouterInterface> m_routerClient; //!< Interface with the Gateway Front End
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceNewService;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyUserName;
|
||||
eproperty::Value<etk::String> propertyUserName;
|
||||
eproperty::Value<bool> propertyRouterNo;
|
||||
eproperty::Value<std::string> propertyRouterIp;
|
||||
eproperty::Value<etk::String> propertyRouterIp;
|
||||
eproperty::Value<uint16_t> propertyRouterPort;
|
||||
eproperty::Value<bool> propertyServiceExtern;
|
||||
eproperty::Value<std::string> propertyServiceIp;
|
||||
eproperty::Value<etk::String> propertyServiceIp;
|
||||
eproperty::Value<uint16_t> propertyServicePort;
|
||||
eproperty::Value<uint16_t> propertyServiceMax;
|
||||
public:
|
||||
std::vector<ememory::SharedPtr<appl::DirectInterface>> m_listTemporaryIO; //!< List of all service availlable with their specific connection interface
|
||||
std::vector<ememory::SharedPtr<appl::IOInterface>> m_listIO;
|
||||
etk::Vector<ememory::SharedPtr<appl::DirectInterface>> m_listTemporaryIO; //!< List of all service availlable with their specific connection interface
|
||||
etk::Vector<ememory::SharedPtr<appl::IOInterface>> m_listIO;
|
||||
void addIO(const ememory::SharedPtr<appl::IOInterface>& _io);
|
||||
void removeIO(const ememory::SharedPtr<appl::IOInterface>& _io);
|
||||
|
||||
@ -37,8 +37,8 @@ namespace appl {
|
||||
virtual ~GateWay();
|
||||
void start();
|
||||
void stop();
|
||||
//ememory::SharedPtr<appl::ServiceInterface> get(const std::string& _serviceName);
|
||||
std::vector<std::string> getAllServiceName();
|
||||
//ememory::SharedPtr<appl::ServiceInterface> get(const etk::String& _serviceName);
|
||||
etk::Vector<etk::String> getAllServiceName();
|
||||
bool send(ememory::SharedPtr<zeus::Message> _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);
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <zeus/AbstractFunction.hpp>
|
||||
|
||||
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<std::string>& appl::IOInterface::getServiceList() {
|
||||
const etk::Vector<etk::String>& appl::IOInterface::getServiceList() {
|
||||
return m_listService;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_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<zeus::Message> _value) {
|
||||
}
|
||||
#if 0
|
||||
if (callFunction == "identify") {
|
||||
std::string clientName = callObj->getParameter<std::string>(0);
|
||||
std::string clientTocken = callObj->getParameter<std::string>(1);
|
||||
etk::String clientName = callObj->getParameter<etk::String>(0);
|
||||
etk::String clientTocken = callObj->getParameter<etk::String>(1);
|
||||
if (m_userService == nullptr) {
|
||||
answerProtocolError(transactionId, "gateWay internal error 3");
|
||||
return;
|
||||
@ -144,7 +144,7 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
m_clientName = clientName;
|
||||
}
|
||||
if (callFunction == "auth") {
|
||||
std::string password = callObj->getParameter<std::string>(0);
|
||||
etk::String password = callObj->getParameter<etk::String>(0);
|
||||
zeus::Future<bool> 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<zeus::Message> _value) {
|
||||
// --------------------------------
|
||||
// -- Get groups:
|
||||
// --------------------------------
|
||||
zeus::Future<std::vector<std::string>> futGroup = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "clientGroupsGet", m_clientName);
|
||||
zeus::Future<etk::Vector<etk::String>> 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<zeus::Message> _value) {
|
||||
// --------------------------------
|
||||
// -- Get services:
|
||||
// --------------------------------
|
||||
std::vector<std::string> currentServices = m_gatewayInterface->getAllServiceName();
|
||||
zeus::Future<std::vector<std::string>> futServices = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "filterClientServices", m_clientName, currentServices);
|
||||
etk::Vector<etk::String> currentServices = m_gatewayInterface->getAllServiceName();
|
||||
zeus::Future<etk::Vector<etk::String>> 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<zeus::Message> _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<zeus::Message> _value) {
|
||||
}
|
||||
if (callFunction == "link") {
|
||||
// TODO : Filter services access ...
|
||||
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||
etk::String serviceName = callObj->getParameter<etk::String>(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<zeus::Message> _value) {
|
||||
{
|
||||
if (callFunction == "serviceAdd") {
|
||||
zeus::WebServer* iface = getInterface();
|
||||
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||
etk::String serviceName = callObj->getParameter<etk::String>(0);
|
||||
if (serviceName == "") {
|
||||
iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false);
|
||||
return;
|
||||
@ -240,13 +240,13 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _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<std::string>(0);
|
||||
etk::String serviceName = callObj->getParameter<etk::String>(0);
|
||||
if (serviceName == "") {
|
||||
iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false);
|
||||
}
|
||||
@ -278,7 +278,7 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
}
|
||||
if (callFunction == "link") {
|
||||
// TODO : Filter services access ...
|
||||
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||
etk::String serviceName = callObj->getParameter<etk::String>(0);
|
||||
if (m_gateway->serviceExist(serviceName) == false) {
|
||||
zeus::WebServer* iface = getInterface();
|
||||
iface->answerValue(transactionId, _value->getDestination(), _value->getSource(), false);
|
||||
|
@ -22,9 +22,9 @@ namespace appl {
|
||||
appl::GateWay* m_gateway;
|
||||
protected:
|
||||
uint16_t m_uid; //!< Client unique ID (for routing)
|
||||
std::vector<std::string> m_listService;
|
||||
etk::Vector<etk::String> m_listService;
|
||||
public:
|
||||
const std::vector<std::string>& getServiceList();
|
||||
const etk::Vector<etk::String>& 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; };
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <zeus/AbstractFunction.hpp>
|
||||
|
||||
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<zeus::Message> _v
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_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<zeus::Message> _v
|
||||
return;
|
||||
}
|
||||
if (callFunction == "identify") {
|
||||
std::string clientName = callObj->getParameter<std::string>(0);
|
||||
std::string clientTocken = callObj->getParameter<std::string>(1);
|
||||
etk::String clientName = callObj->getParameter<etk::String>(0);
|
||||
etk::String clientTocken = callObj->getParameter<etk::String>(1);
|
||||
if (m_userService == nullptr) {
|
||||
answerProtocolError(transactionId, "gateWay internal error 3");
|
||||
return;
|
||||
@ -149,7 +149,7 @@ void appl::clientSpecificInterface::receive(ememory::SharedPtr<zeus::Message> _v
|
||||
m_clientName = clientName;
|
||||
}
|
||||
if (callFunction == "auth") {
|
||||
std::string password = callObj->getParameter<std::string>(0);
|
||||
etk::String password = callObj->getParameter<etk::String>(0);
|
||||
zeus::Future<bool> 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<zeus::Message> _v
|
||||
// --------------------------------
|
||||
// -- Get groups:
|
||||
// --------------------------------
|
||||
zeus::Future<std::vector<std::string>> futGroup = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "clientGroupsGet", m_clientName);
|
||||
zeus::Future<etk::Vector<etk::String>> 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<zeus::Message> _v
|
||||
// --------------------------------
|
||||
// -- Get services:
|
||||
// --------------------------------
|
||||
std::vector<std::string> currentServices = m_gatewayInterface->getAllServiceName();
|
||||
zeus::Future<std::vector<std::string>> futServices = m_userService->m_interfaceClient.call(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "filterClientServices", m_clientName, currentServices);
|
||||
etk::Vector<etk::String> currentServices = m_gatewayInterface->getAllServiceName();
|
||||
zeus::Future<etk::Vector<etk::String>> 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<zeus::Message> _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<zeus::Message> _v
|
||||
}
|
||||
if (callFunction == "link") {
|
||||
// first param:
|
||||
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||
etk::String serviceName = callObj->getParameter<etk::String>(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<zeus::Message> _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<zeus::Message> _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<zeus::Message> _valu
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_listClients.push_back(ememory::makeShared<clientSpecificInterface>());
|
||||
m_listClients.pushBack(ememory::makeShared<clientSpecificInterface>());
|
||||
size_t localId = m_listClients.size()-1;
|
||||
bool ret = m_listClients[localId]->start(m_gateway, &m_interfaceWeb, sourceId);
|
||||
if (ret == false) {
|
||||
|
@ -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<zeus::Message> _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<ememory::SharedPtr<clientSpecificInterface>> m_listClients; // TODO : Maybe remove this ...
|
||||
etk::Vector<ememory::SharedPtr<clientSpecificInterface>> 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<zeus::Message> _value);
|
||||
|
@ -27,29 +27,29 @@
|
||||
#include <zeus/Client.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
|
||||
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<zeus::WebServer>&, 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<std::string> services;
|
||||
etk::String basePath;
|
||||
etk::Vector<etk::String> 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<std::pair<std::string,std::string>> listAvaillableServices;
|
||||
etk::Vector<etk::Pair<etk::String,etk::String>> listAvaillableServices;
|
||||
if (services.size() != 0) {
|
||||
// find all services:
|
||||
etk::FSNode dataPath(etk::FSNodeGetApplicationPath() + "/../share");
|
||||
std::vector<std::string> listSubPath = dataPath.folderGetSub(true, false, ".*");
|
||||
etk::Vector<etk::String> 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<std::string> listServices = dataPath.folderGetSub(false, true, ".*\\.srv");
|
||||
etk::Vector<etk::String> listServices = dataPath.folderGetSub(false, true, ".*\\.srv");
|
||||
for (auto &it2: listServices) {
|
||||
std::string nameFileSrv = etk::FSNode(it2).getNameFile();
|
||||
std::vector<std::string> spl = etk::split(std::string(nameFileSrv.begin(), nameFileSrv.end()-4), "-service-");
|
||||
etk::String nameFileSrv = etk::FSNode(it2).getNameFile();
|
||||
etk::Vector<etk::String> 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<ememory::SharedPtr<PlugginAccess>> listElements;
|
||||
etk::Vector<ememory::SharedPtr<PlugginAccess>> listElements;
|
||||
if ( services.size() == 1
|
||||
&& services[0] == "all") {
|
||||
for (auto &it: listAvaillableServices) {
|
||||
ememory::SharedPtr<PlugginAccess> tmp = ememory::makeShared<PlugginAccess>(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<PlugginAccess> tmp = ememory::makeShared<PlugginAccess>(it2.first, it2.second);
|
||||
listElements.push_back(tmp);
|
||||
listElements.pushBack(tmp);
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
|
@ -19,27 +19,27 @@
|
||||
#include <zeus/Client.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
|
||||
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<zeus::WebServer>&, 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<std::string> services;
|
||||
etk::String basePath;
|
||||
etk::Vector<etk::String> 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<ememory::SharedPtr<PlugginAccess>> listElements;
|
||||
etk::Vector<ememory::SharedPtr<PlugginAccess>> listElements;
|
||||
|
||||
for (auto &it: services) {
|
||||
ememory::SharedPtr<PlugginAccess> tmp = ememory::makeShared<PlugginAccess>(it);
|
||||
listElements.push_back(tmp);
|
||||
listElements.pushBack(tmp);
|
||||
}
|
||||
|
||||
for (auto &it: listElements) {
|
||||
|
@ -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<std::string> listElem = etk::split(_login, '~');
|
||||
etk::String login;
|
||||
etk::Vector<etk::String> 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<std::string> listElem2 = etk::split(listElem[1], ':');
|
||||
etk::Vector<etk::String> 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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<float,4> 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<uint32_t,uint32_t>(_positionRequest, _positionRequest + _data.size()));
|
||||
m_bufferFillSection.insert(it, etk::Pair<uint32_t,uint32_t>(_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) {
|
||||
|
@ -51,10 +51,10 @@ namespace appl {
|
||||
};
|
||||
class MessageElementAudio : public appl::MessageElement {
|
||||
public:
|
||||
std::vector<uint8_t> m_buffer; //!< raw audio data
|
||||
etk::Vector<uint8_t> m_buffer; //!< raw audio data
|
||||
audio::format m_format; //!< Audio format buffer
|
||||
uint32_t m_sampleRate; //!< sample rate of the buffer
|
||||
std::vector<audio::channel> m_map; //!< Channel map of the buffer
|
||||
etk::Vector<audio::channel> 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<StreamBuffering> {
|
||||
@ -64,9 +64,9 @@ namespace appl {
|
||||
ememory::SharedPtr<appl::ClientProperty> 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<uint8_t> m_buffer; //!< preallocated with all needed data
|
||||
etk::Vector<uint8_t> m_buffer; //!< preallocated with all needed data
|
||||
int32_t m_bufferReadPosition; //!< Current position that is read
|
||||
std::vector<std::pair<uint32_t,uint32_t>> m_bufferFillSection; //!< List of <start-stop> position that contain data
|
||||
etk::Vector<etk::Pair<uint32_t,uint32_t>> m_bufferFillSection; //!< List of <start-stop> position that contain data
|
||||
bool m_callInProgress;
|
||||
bool m_stopRequested;
|
||||
public:
|
||||
@ -76,7 +76,7 @@ namespace appl {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
return m_buffer.size();
|
||||
}
|
||||
std::vector<std::pair<uint32_t,uint32_t>> getDownloadPart() {
|
||||
etk::Vector<etk::Pair<uint32_t,uint32_t>> getDownloadPart() {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
return m_bufferFillSection;
|
||||
}
|
||||
@ -98,9 +98,9 @@ namespace appl {
|
||||
return m_duration;
|
||||
}
|
||||
public:
|
||||
std::vector<MessageElementAudio> m_audioPool;
|
||||
etk::Vector<MessageElementAudio> m_audioPool;
|
||||
echrono::Duration m_currentAudioTime;
|
||||
std::vector<MessageElementVideo> m_videoPool;
|
||||
etk::Vector<MessageElementVideo> 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<audio::channel> m_audioMap; //!< Channel map of the buffer
|
||||
etk::Vector<audio::channel> m_audioMap; //!< Channel map of the buffer
|
||||
bool haveAudio() {
|
||||
return m_audioPresent;
|
||||
}
|
||||
uint32_t audioGetSampleRate() {
|
||||
return m_audioSampleRate;
|
||||
}
|
||||
std::vector<audio::channel> audioGetChannelMap() {
|
||||
etk::Vector<audio::channel> 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<std::pair<float,float>> getDownloadPart() {
|
||||
std::vector<std::pair<float,float>> out;
|
||||
etk::Vector<etk::Pair<float,float>> getDownloadPart() {
|
||||
etk::Vector<etk::Pair<float,float>> out;
|
||||
if (m_remote == nullptr) {
|
||||
return out;
|
||||
}
|
||||
std::vector<std::pair<uint32_t,uint32_t>> vals = m_remote->getDownloadPart();
|
||||
etk::Vector<etk::Pair<uint32_t,uint32_t>> 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,float>(float(it.first)*size, float(it.second)*size));
|
||||
out.pushBack(etk::Pair<float,float>(float(it.first)*size, float(it.second)*size));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <appl/widget/Player.hpp>
|
||||
|
||||
|
||||
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<appl::widget::VideoDisplay> tmpDisp = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace appl {
|
||||
ememory::SharedPtr<ClientProperty> m_clientProp;
|
||||
appl::widget::ListViewerShared m_listViewer;
|
||||
appl::widget::PlayerShared m_player;
|
||||
std::vector<std::string> m_list;
|
||||
etk::Vector<etk::String> 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<ClientProperty>& _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();
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
//#include <vector>
|
||||
#include <vector>
|
||||
//#include <etk/Vector.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
@ -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::SharedPtr<appl::ClientProper
|
||||
}
|
||||
m_login = m_baseProperty->getLogin();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,8 @@ namespace appl {
|
||||
esignal::Signal<ememory::SharedPtr<appl::ClientProperty>> signalConnectionError; //!< Error on connection
|
||||
protected:
|
||||
ememory::SharedPtr<appl::ClientProperty> 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<appl::ClientProperty> _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);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -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<zeus::ProxyMedia> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<uint8_t> bufferData = zeus::storeInMemory(_media);
|
||||
etk::Vector<uint8_t> 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<std::mutex> 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<uint8_t> bufferData = zeus::storeInMemory(_media);
|
||||
etk::Vector<uint8_t> 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<std::mutex> 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<std::mutex> 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<uint8_t> bufferData = zeus::storeInMemory(_media);
|
||||
etk::Vector<uint8_t> 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<std::mutex> 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<std::vector<std::string>> listElem = remoteServiceVideo.getMetadataValuesWhere(m_currentGroup, m_currentFilter).wait();
|
||||
zeus::Future<etk::Vector<etk::String>> listElem = remoteServiceVideo.getMetadataValuesWhere(m_currentGroup, m_currentFilter).wait();
|
||||
if (listElem.hasError() == true) {
|
||||
APPL_ERROR(" ==> Can not get elements from video service <with fileter ! '" << m_currentFilter << "' : " << listElem.getErrorType() << " : " << listElem.getErrorHelp());
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> returnValues = listElem.get();
|
||||
etk::Vector<etk::String> 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<std::vector<uint32_t>> listElem = remoteServiceVideo.getSQL(m_currentFilter).wait();
|
||||
zeus::Future<etk::Vector<uint32_t>> listElem = remoteServiceVideo.getSQL(m_currentFilter).wait();
|
||||
if (listElem.hasError() == true) {
|
||||
APPL_ERROR(" ==> Can not get element from video service <with fileter ! '" << m_currentFilter << "' : " << listElem.getErrorType() << " : " << listElem.getErrorHelp());
|
||||
return;
|
||||
}
|
||||
std::vector<uint32_t> returnValues = listElem.get();
|
||||
etk::Vector<uint32_t> returnValues = listElem.get();
|
||||
APPL_INFO("Get some Values: " << returnValues << "");
|
||||
for (auto &it : returnValues) {
|
||||
auto elem = ememory::makeShared<ElementProperty>(remoteServiceVideo, ememory::staticPointerCast<ewol::Widget>(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<verticalNumber; ++iii) {
|
||||
auto elem = ememory::makeShared<ElementDisplayed>();
|
||||
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 += "<br/><i>Loading in progress</i> ... " + etk::to_string(m_property->m_nbElementLoaded) + "/8";
|
||||
textToDisplay += "<br/><i>Loading in progress</i> ... " + etk::toString(m_property->m_nbElementLoaded) + "/8";
|
||||
} else {
|
||||
std::unique_lock<std::mutex> 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";
|
||||
|
@ -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<ewol::resource::Texture> m_resource;
|
||||
echrono::Steady m_lastRequestTime;
|
||||
};
|
||||
|
||||
class CacheImageManager {
|
||||
private:
|
||||
std::vector<ElementCache> m_imageCoverGroupCache; //!< All image cash of the group cover
|
||||
etk::Vector<ElementCache> m_imageCoverGroupCache; //!< All image cash of the group cover
|
||||
|
||||
};
|
||||
|
||||
@ -137,11 +137,11 @@ namespace appl {
|
||||
protected:
|
||||
ememory::SharedPtr<ClientProperty> m_clientProp; //!< Generic entrypoint on the Client
|
||||
protected:
|
||||
std::vector<ememory::SharedPtr<ElementProperty>> m_listElement; //!< list of all element getted in the remote access
|
||||
std::vector<ememory::SharedPtr<ElementPropertyGroup>> m_listElementGroup; //!< list of all element getted in the remote access
|
||||
std::string m_currentFilter;
|
||||
std::string m_currentGroup;
|
||||
std::vector<ememory::SharedPtr<ElementDisplayed>> m_listDisplay; //!< list of element in the current local display
|
||||
etk::Vector<ememory::SharedPtr<ElementProperty>> m_listElement; //!< list of all element getted in the remote access
|
||||
etk::Vector<ememory::SharedPtr<ElementPropertyGroup>> m_listElementGroup; //!< list of all element getted in the remote access
|
||||
etk::String m_currentFilter;
|
||||
etk::String m_currentGroup;
|
||||
etk::Vector<ememory::SharedPtr<ElementDisplayed>> 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<ClientProperty> _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<std::pair<std::string,std::string>> m_history;
|
||||
etk::Vector<etk::Pair<etk::String,etk::String>> m_history;
|
||||
public:
|
||||
void backHistory();
|
||||
public:
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
@ -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<appl::widget::VideoDisplay>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display"));
|
||||
m_progress = ememory::dynamicPointerCast<appl::widget::ProgressBar>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar"));
|
||||
m_display = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("[" + etk::toString(getId()) + "]appl-player-display"));
|
||||
m_progress = ememory::dynamicPointerCast<appl::widget::ProgressBar>(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<appl::ClientProperty> _
|
||||
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<std::pair<float,float>> tmp;
|
||||
etk::Vector<etk::Pair<float,float>> 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", "<font color='black'>--:--</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-duration", "value", "<font color='black'>--:--</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-time", "value", "<font color='black'>--:--</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-duration", "value", "<font color='black'>--:--</font>");
|
||||
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", "<font color='black'>" + timeToStaticString(_time) + "</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-duration", "value", "<font color='black'>" + timeToStaticString(_time) + "</font>");
|
||||
}
|
||||
|
||||
void appl::widget::Player::onCallbackPosition(const echrono::Duration& _time) {
|
||||
//APPL_ERROR("time = " << _time);
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-time", "value", "<font color='black'>" + timeToStaticString(_time) + "</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-time", "value", "<font color='black'>" + timeToStaticString(_time) + "</font>");
|
||||
if (m_progress != nullptr) {
|
||||
m_progress->propertyValue.set(_time.toSeconds());
|
||||
}
|
||||
if (m_display != nullptr) {
|
||||
std::vector<std::pair<float,float>> tmp = m_display->getDownloadPart();
|
||||
etk::Vector<etk::Pair<float,float>> 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=<font color='orangered'>" + _plop + "</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-fps", "value", "FPS=<font color='orangered'>" + _plop + "</font>");
|
||||
}
|
||||
|
||||
void appl::widget::Player::onCallbackFPS(const int32_t& _fps) {
|
||||
APPL_DEBUG("FPS = " << _fps);
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-fps", "value", "FPS=<font color='orangered'>" + etk::to_string(_fps) + "</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-player-label-fps", "value", "FPS=<font color='orangered'>" + etk::toString(_fps) + "</font>");
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
};
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace appl {
|
||||
public: // signals
|
||||
esignal::Signal<float> signalChange;
|
||||
public:
|
||||
//eproperty::Value<std::string> propertyShape; //!< name of the shape used
|
||||
//eproperty::Value<etk::String> propertyShape; //!< name of the shape used
|
||||
eproperty::Value<float> propertyValue; //!< current value of the ProgressBar
|
||||
eproperty::Value<float> 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<std::pair<float,float>> m_listAvaillable;
|
||||
etk::Vector<etk::Pair<float,float>> m_listAvaillable;
|
||||
public:
|
||||
void setRangeAvaillable(std::vector<std::pair<float,float>>& _values) {
|
||||
void setRangeAvaillable(etk::Vector<etk::Pair<float,float>>& _values) {
|
||||
m_listAvaillable = _values;
|
||||
}
|
||||
protected:
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
@ -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 {
|
||||
|
@ -20,7 +20,7 @@ namespace appl {
|
||||
using UpBarWeak = ememory::WeakPtr<appl::widget::UpBar>;
|
||||
class UpBar : public ewol::widget::Composer {
|
||||
public: // properties
|
||||
eproperty::Value<std::string> propertyType; //!< Type of the bar
|
||||
eproperty::Value<etk::String> propertyType; //!< Type of the bar
|
||||
eproperty::Value<float> propertyValue; //!< value of the bar ...
|
||||
public: // signals
|
||||
esignal::Signal<float> signalChange; //!< Value of the bar
|
||||
|
@ -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
|
||||
|
@ -25,7 +25,7 @@ namespace appl {
|
||||
namespace widget {
|
||||
class VideoDisplay : public ewol::Widget {
|
||||
public:
|
||||
esignal::Signal<std::string> signalOther;
|
||||
esignal::Signal<etk::String> signalOther;
|
||||
esignal::Signal<int32_t> signalFps;
|
||||
esignal::Signal<echrono::Duration> signalPosition; //!< signal the current duration of the video duration
|
||||
esignal::Signal<echrono::Duration> 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<ClientProperty> _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<std::pair<float,float>> getDownloadPart() {
|
||||
etk::Vector<etk::Pair<float,float>> getDownloadPart() {
|
||||
if (m_decoder == nullptr) {
|
||||
return std::vector<std::pair<float,float>>();
|
||||
return etk::Vector<etk::Pair<float,float>>();
|
||||
}
|
||||
return m_decoder->getDownloadPart();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace appl {
|
||||
esignal::Signal<float> signalChange;
|
||||
esignal::Signal<float> signalHide; //!< Hide value [0..1] ==> 0 is hidden
|
||||
public:
|
||||
//eproperty::Value<std::string> propertyShape; //!< name of the shape used
|
||||
//eproperty::Value<etk::String> propertyShape; //!< name of the shape used
|
||||
eproperty::Value<float> propertyValue; //!< current value of the VolumeBar
|
||||
eproperty::Value<float> propertyStep; //!< Up and down step value
|
||||
eproperty::Value<float> 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<std::pair<float,float>> m_listAvaillable;
|
||||
etk::Vector<etk::Pair<float,float>> m_listAvaillable;
|
||||
public:
|
||||
void setRangeAvaillable(std::vector<std::pair<float,float>>& _values) {
|
||||
void setRangeAvaillable(etk::Vector<etk::Pair<float,float>>& _values) {
|
||||
m_listAvaillable = _values;
|
||||
}
|
||||
protected:
|
||||
|
@ -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")
|
||||
|
@ -13,11 +13,11 @@
|
||||
#include <zeus/AbstractFunction.hpp>
|
||||
|
||||
|
||||
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<zeus::Message> _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<zeus::Message> _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
|
||||
|
@ -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<appl::GateWayInterface> 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);
|
||||
|
||||
|
||||
};
|
||||
|
@ -10,13 +10,13 @@
|
||||
#include <appl/Router.hpp>
|
||||
|
||||
// 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<zeus::Message> _data) {
|
||||
}
|
||||
|
||||
uint16_t appl::GateWayInterface::addClient(ememory::SharedPtr<appl::ClientInterface> _value) {
|
||||
m_clientConnected.push_back(_value);
|
||||
m_clientConnected.pushBack(_value);
|
||||
return m_lastSourceID++;
|
||||
}
|
||||
|
||||
@ -106,14 +106,14 @@ void appl::GateWayInterface::onServiceData(ememory::SharedPtr<zeus::Message> _va
|
||||
uint32_t transactionId = _value->getTransactionId();
|
||||
if (_value->getType() == zeus::message::type::call) {
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_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<std::string>(0));
|
||||
ZEUS_WARNING("Service interface ==> try change the servie name after init: '" << callObj->getParameter<etk::String>(0));
|
||||
m_interfaceClient.answerValue(transactionId, _value->getDestination(), _value->getSource(), false);
|
||||
return;
|
||||
}
|
||||
m_name = callObj->getParameter<std::string>(0);
|
||||
m_name = callObj->getParameter<etk::String>(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<zeus::Message> _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);
|
||||
}
|
||||
|
@ -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<ememory::SharedPtr<appl::ClientInterface>> m_clientConnected;
|
||||
std::string m_name;
|
||||
bool requestURI(const std::string& _uri);
|
||||
etk::Vector<ememory::SharedPtr<appl::ClientInterface>> 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<appl::ClientInterface> _value);
|
||||
void rmClient(ememory::SharedPtr<appl::ClientInterface> _value);
|
||||
void send(ememory::SharedPtr<zeus::Message> _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);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,16 +9,16 @@
|
||||
#include <enet/TcpServer.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
|
||||
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<UserAvaillable> g_listUserAvaillable;
|
||||
etk::Vector<UserAvaillable> 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<appl::GateWayInterface> tmp = ememory::makeShared<appl::GateWayInterface>(std::move(_connection), this);
|
||||
ememory::SharedPtr<appl::GateWayInterface> tmp = ememory::makeShared<appl::GateWayInterface>(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<appl::ClientInterface> tmp = ememory::makeShared<appl::ClientInterface>(std::move(_connection), this);
|
||||
ememory::SharedPtr<appl::ClientInterface> tmp = ememory::makeShared<appl::ClientInterface>(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 <unistd.h>
|
||||
|
||||
|
||||
ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const std::string& _userName) {
|
||||
ememory::SharedPtr<appl::GateWayInterface> 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::GateWayInterface> 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::GateWayInterface> 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::GateWayInterface> 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::GateWayInterface> appl::Router::get(const std::string&
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> appl::Router::getAllUserName() {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> appl::Router::getAllUserName() {
|
||||
etk::Vector<etk::String> out;
|
||||
/*
|
||||
for (auto &it : m_GateWayList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
out.push_back(it->getName());
|
||||
out.pushBack(it->getName());
|
||||
}
|
||||
*/
|
||||
return out;
|
||||
|
@ -15,17 +15,17 @@ namespace appl {
|
||||
private:
|
||||
uint64_t m_clientUID;
|
||||
private:
|
||||
std::vector<ememory::SharedPtr<appl::GateWayInterface>> m_GateWayList; //!< List of all service availlable with their specific connection interface
|
||||
std::vector<ememory::SharedPtr<appl::ClientInterface>> m_clientList; //!< List of all Client interface with their own connection
|
||||
etk::Vector<ememory::SharedPtr<appl::GateWayInterface>> m_GateWayList; //!< List of all service availlable with their specific connection interface
|
||||
etk::Vector<ememory::SharedPtr<appl::ClientInterface>> m_clientList; //!< List of all Client interface with their own connection
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceClientServer;
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceGateWayServer;
|
||||
ejson::Document m_listUser;
|
||||
public:
|
||||
eproperty::Value<bool> propertyStdOut; //!< not set the log in the stdout or in the local file
|
||||
eproperty::Value<std::string> propertyClientIp;
|
||||
eproperty::Value<etk::String> propertyClientIp;
|
||||
eproperty::Value<uint16_t> propertyClientPort;
|
||||
eproperty::Value<uint16_t> propertyClientMax;
|
||||
eproperty::Value<std::string> propertyGateWayIp;
|
||||
eproperty::Value<etk::String> propertyGateWayIp;
|
||||
eproperty::Value<uint16_t> propertyGateWayPort;
|
||||
eproperty::Value<uint16_t> propertyGateWayMax;
|
||||
eproperty::Value<int32_t> propertyDelayToStop;
|
||||
@ -35,10 +35,10 @@ namespace appl {
|
||||
void start();
|
||||
void stop();
|
||||
// Get a specific user gateway:
|
||||
ememory::SharedPtr<appl::GateWayInterface> get(const std::string& _userName);
|
||||
bool userIsConnected(const std::string& _userName);
|
||||
ememory::SharedPtr<appl::GateWayInterface> get(const etk::String& _userName);
|
||||
bool userIsConnected(const etk::String& _userName);
|
||||
|
||||
std::vector<std::string> getAllUserName();
|
||||
etk::Vector<etk::String> getAllUserName();
|
||||
void newClientGateWay(enet::Tcp _connection);
|
||||
void newClient(enet::Tcp _connection);
|
||||
void cleanIO();
|
||||
|
@ -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<uivfknejc<wxphogkbezdsj<cxhwdséznreS<WJCXHKJ"));
|
||||
//etk::String OUT2 = algue::stringConvert(algue::sha512::encode("jkhlkjhlkjhlkjhlkjhlkjhlkjhiugouuyrtfkvjhbnj,owixhuvkfn r;,dcxwjo ppxicodsn,kwp<uivfknejc<wxphogkbezdsj<cxhwdséznreS<WJCXHKJ"));
|
||||
//APPL_PRINT("2: " << OUT2);
|
||||
//return 0;
|
||||
appl::Router basicRouter;
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if (data == "--stdout") {
|
||||
basicRouter.propertyStdOut.set(true);
|
||||
} else if (etk::start_with(data, "--client-ip=") == true) {
|
||||
basicRouter.propertyClientIp.set(std::string(&data[12]));
|
||||
basicRouter.propertyClientIp.set(etk::String(&data[12]));
|
||||
} else if (etk::start_with(data, "--client-port=") == true) {
|
||||
basicRouter.propertyClientPort.set(etk::string_to_uint16_t(std::string(&data[14])));
|
||||
basicRouter.propertyClientPort.set(etk::string_to_uint16_t(etk::String(&data[14])));
|
||||
} else if (etk::start_with(data, "--client-max=") == true) {
|
||||
basicRouter.propertyClientMax.set(etk::string_to_uint16_t(std::string(&data[13])));
|
||||
basicRouter.propertyClientMax.set(etk::string_to_uint16_t(etk::String(&data[13])));
|
||||
} else if (etk::start_with(data, "--gw-ip=") == true) {
|
||||
basicRouter.propertyGateWayIp.set(std::string(&data[8]));
|
||||
basicRouter.propertyGateWayIp.set(etk::String(&data[8]));
|
||||
} else if (etk::start_with(data, "--gw-port=") == true) {
|
||||
basicRouter.propertyGateWayPort.set(etk::string_to_uint16_t(std::string(&data[10])));
|
||||
basicRouter.propertyGateWayPort.set(etk::string_to_uint16_t(etk::String(&data[10])));
|
||||
} else if (etk::start_with(data, "--gw-max=") == true) {
|
||||
basicRouter.propertyGateWayMax.set(etk::string_to_uint16_t(std::string(&data[9])));
|
||||
basicRouter.propertyGateWayMax.set(etk::string_to_uint16_t(etk::String(&data[9])));
|
||||
} else if (etk::start_with(data, "--delay-stop-user=") == true) {
|
||||
basicRouter.propertyDelayToStop.set(etk::string_to_int32_t(std::string(&data[18])));
|
||||
basicRouter.propertyDelayToStop.set(etk::string_to_int32_t(etk::String(&data[18])));
|
||||
} else if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
APPL_PRINT(etk::getApplicationName() << " - help : ");
|
||||
|
@ -94,12 +94,12 @@ void appl::ClientProperty::connect() {
|
||||
}
|
||||
}
|
||||
|
||||
void appl::ClientProperty::setLogin(std::string _login) {
|
||||
void appl::ClientProperty::setLogin(etk::String _login) {
|
||||
fromUser = "";
|
||||
toUser = "";
|
||||
// separate loggin and IP adress ...
|
||||
std::string login;
|
||||
std::vector<std::string> listElem = etk::split(_login, '~');
|
||||
etk::String login;
|
||||
etk::Vector<etk::String> 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<std::string> listElem2 = etk::split(listElem[1], ':');
|
||||
etk::Vector<etk::String> 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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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" );
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <appl/widget/meta/StdPopUp.hpp>
|
||||
|
||||
|
||||
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<void> 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<void> 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")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@ namespace appl {
|
||||
|
||||
void onCallbackConnectionValidate(const ememory::SharedPtr<ClientProperty>& _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);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
//#include <vector>
|
||||
#include <vector>
|
||||
//#include <etk/Vector.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
@ -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::SharedPtr<appl::ClientProper
|
||||
}
|
||||
m_login = m_baseProperty->getLogin();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,8 @@ namespace appl {
|
||||
esignal::Signal<ememory::SharedPtr<appl::ClientProperty>> signalValidate; //!< select file(s)
|
||||
protected:
|
||||
ememory::SharedPtr<appl::ClientProperty> 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<appl::ClientProperty> _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);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -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(".")
|
||||
|
@ -25,28 +25,28 @@
|
||||
#include <zeus/ProxyFile.hpp>
|
||||
|
||||
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<std::string, std::string> m_metadata;
|
||||
etk::Map<etk::String, etk::String> m_metadata;
|
||||
};
|
||||
static std::vector<FileProperty> m_listFile;
|
||||
static etk::Vector<FileProperty> 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<uint32_t> 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<uint32_t> m_listMedia; //!< List of media in this album
|
||||
};
|
||||
static std::vector<Album> m_listAlbum;
|
||||
static etk::Vector<Album> m_listAlbum;
|
||||
|
||||
static uint64_t m_lastMaxId = 0;
|
||||
static bool g_needToStore = false;
|
||||
@ -61,10 +61,10 @@ namespace appl {
|
||||
private:
|
||||
//ememory::SharedPtr<zeus::ClientProperty>& m_client;
|
||||
zeus::ProxyClientProperty m_client;
|
||||
std::string m_userName;
|
||||
etk::String m_userName;
|
||||
public:
|
||||
/*
|
||||
PictureService(ememory::SharedPtr<zeus::ClientProperty>& _client, const std::string& _userName) :
|
||||
PictureService(ememory::SharedPtr<zeus::ClientProperty>& _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<uint32_t> mediaIdGetRange(uint32_t _start, uint32_t _stop) override {
|
||||
etk::Vector<uint32_t> mediaIdGetRange(uint32_t _start, uint32_t _stop) override {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
// TODO : Check right ...
|
||||
std::vector<uint32_t> out;
|
||||
etk::Vector<uint32_t> out;
|
||||
for (size_t iii=_start; iii<m_listFile.size() && iii<_stop; ++iii) {
|
||||
out.push_back(m_listFile[iii].m_id);
|
||||
out.pushBack(m_listFile[iii].m_id);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -118,8 +118,8 @@ namespace appl {
|
||||
|
||||
auto futType = _dataFile.getMineType();
|
||||
auto futName = _dataFile.getName();
|
||||
std::string tmpFileName = g_basePath + "tmpImport_" + etk::to_string(id);
|
||||
std::string sha512String = zeus::storeInFile(_dataFile, tmpFileName);
|
||||
etk::String tmpFileName = g_basePath + "tmpImport_" + etk::toString(id);
|
||||
etk::String sha512String = zeus::storeInFile(_dataFile, tmpFileName);
|
||||
futType.wait();
|
||||
futName.wait();
|
||||
// TODO : Get internal data of the file and remove all the meta-data ==> 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<std::string> mediaMetadataGetKeys(uint32_t _mediaId) override {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> mediaMetadataGetKeys(uint32_t _mediaId) override {
|
||||
etk::Vector<etk::String> 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<std::string> out;
|
||||
etk::String mediaMetadataGetKey(uint32_t _mediaId, etk::String _key) override {
|
||||
etk::Vector<etk::String> 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<std::mutex> 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<uint32_t> albumGetList() override {
|
||||
etk::Vector<uint32_t> albumGetList() override {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
std::vector<uint32_t> out;
|
||||
etk::Vector<uint32_t> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<uint32_t> albumMediaIdGet(uint32_t _albumId, uint32_t _start, uint32_t _stop) override {
|
||||
etk::Vector<uint32_t> albumMediaIdGet(uint32_t _albumId, uint32_t _start, uint32_t _stop) override {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
for (auto &it : m_listAlbum) {
|
||||
if (it.m_id == _albumId) {
|
||||
std::vector<uint32_t> out;
|
||||
etk::Vector<uint32_t> out;
|
||||
for (size_t iii=_start;
|
||||
iii<it.m_listMedia.size()
|
||||
&& iii<_stop;
|
||||
++iii) {
|
||||
out.push_back(it.m_listMedia[iii]);
|
||||
out.pushBack(it.m_listMedia[iii]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -464,13 +464,13 @@ static void load_db() {
|
||||
for (auto itValue = tmpObj.begin();
|
||||
itValue != tmpObj.end();
|
||||
++itValue) {
|
||||
property.m_metadata.insert(std::make_pair(itValue.getKey(), (*itValue).toString().get()));
|
||||
property.m_metadata.insert(etk::makePair(itValue.getKey(), (*itValue).toString().get()));
|
||||
}
|
||||
}
|
||||
if (property.m_fileName == "") {
|
||||
APPL_ERROR("Can not access on the file : ... No name ");
|
||||
} else {
|
||||
m_listFile.push_back(property);
|
||||
m_listFile.pushBack(property);
|
||||
}
|
||||
}
|
||||
ejson::Array listAlbumArray = database["list-album"].toArray();
|
||||
@ -484,14 +484,14 @@ static void load_db() {
|
||||
ejson::Array listMadiaArray = albumElement["media"].toArray();
|
||||
for (const auto itArrayMedia: listMadiaArray) {
|
||||
uint64_t tmp = itArrayMedia.toNumber().getU64();
|
||||
album.m_listMedia.push_back(tmp);
|
||||
album.m_listMedia.pushBack(tmp);
|
||||
}
|
||||
m_listAlbum.push_back(album);
|
||||
m_listAlbum.pushBack(album);
|
||||
}
|
||||
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<std::mutex> lock(g_mutex);
|
||||
APPL_WARNING("Load USER: " << g_basePath);
|
||||
|
@ -19,18 +19,18 @@
|
||||
#include <zeus/ProxyClientProperty.hpp>
|
||||
|
||||
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<zeus::ClientProperty> _client, const std::string& _userName) :
|
||||
SystemService(ememory::SharedPtr<zeus::ClientProperty> _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<std::string> clientGroupsGet(std::string _clientName) {
|
||||
etk::Vector<etk::String> clientGroupsGet(etk::String _clientName) {
|
||||
APPL_WARNING("call clientGroupsGet : " << _clientName);
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> out;
|
||||
/*
|
||||
if (m_client == nullptr) {
|
||||
return out;
|
||||
@ -55,7 +55,7 @@ namespace appl {
|
||||
/*
|
||||
if (m_client.getName().get() != "") {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> 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<std::mutex> 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<std::mutex> 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<std::string> filterClientServices(std::string _clientName, std::vector<std::string> _currentList) {
|
||||
etk::Vector<etk::String> filterClientServices(etk::String _clientName, etk::Vector<etk::String> _currentList) {
|
||||
std::unique_lock<std::mutex> 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<std::string> out;
|
||||
etk::Vector<etk::String> 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<std::mutex> lock(g_mutex);
|
||||
APPL_WARNING("Load USER: " << g_basePath);
|
||||
|
@ -26,12 +26,12 @@
|
||||
#include <zeus/zeus-Media.impl.hpp>
|
||||
|
||||
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<ememory::SharedPtr<zeus::MediaImpl>> m_listFile;
|
||||
static etk::Vector<ememory::SharedPtr<zeus::MediaImpl>> 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<std::string> splitAction(const std::string& _in) {
|
||||
std::vector<std::string> out;
|
||||
static etk::Vector<etk::String> splitAction(const etk::String& _in) {
|
||||
etk::Vector<etk::String> 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<std::string> 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<std::string> 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<zeus::ClientProperty>& m_client;
|
||||
zeus::ProxyClientProperty m_client;
|
||||
std::string m_userName;
|
||||
etk::String m_userName;
|
||||
public:
|
||||
/*
|
||||
VideoService(ememory::SharedPtr<zeus::ClientProperty>& _client, const std::string& _userName) :
|
||||
VideoService(ememory::SharedPtr<zeus::ClientProperty>& _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<uint32_t> getIds(uint32_t _start, uint32_t _stop) override {
|
||||
etk::Vector<uint32_t> getIds(uint32_t _start, uint32_t _stop) override {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
// TODO : Check right ...
|
||||
std::vector<uint32_t> out;
|
||||
etk::Vector<uint32_t> out;
|
||||
for (size_t iii=_start; iii<m_listFile.size() && iii<_stop; ++iii) {
|
||||
if (m_listFile[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
out.push_back(m_listFile[iii]->getUniqueId());
|
||||
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<std::mutex> 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<std::string>& _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<etk::String>& _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<std::mutex> 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<std::mutex> lock(g_mutex);
|
||||
@ -235,7 +235,7 @@ namespace appl {
|
||||
ememory::SharedPtr<zeus::MediaImpl> property = ememory::makeShared<zeus::MediaImpl>(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<std::vector<std::string>> interpreteSQLRequest(const std::string& _sqlLikeRequest) {
|
||||
std::vector<std::vector<std::string>> out;
|
||||
etk::Vector<etk::Vector<etk::String>> interpreteSQLRequest(const etk::String& _sqlLikeRequest) {
|
||||
etk::Vector<etk::Vector<etk::String>> out;
|
||||
if (_sqlLikeRequest != "*") {
|
||||
std::vector<std::string> listAnd = etk::split(_sqlLikeRequest, "AND");
|
||||
etk::Vector<etk::String> listAnd = etk::split(_sqlLikeRequest, "AND");
|
||||
APPL_INFO("Find list AND : ");
|
||||
for (auto &it : listAnd) {
|
||||
it = removeSpaceOutQuote(it);
|
||||
std::vector<std::string> elements = splitAction(it);
|
||||
etk::Vector<etk::String> 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<std::vector<std::string>>& _listElement,
|
||||
const std::map<std::string, std::string>& _metadata) {
|
||||
bool isValid(const etk::Vector<etk::Vector<etk::String>>& _listElement,
|
||||
const etk::Map<etk::String, etk::String>& _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<std::string, std::string>& _metadata) {
|
||||
std::string out = "{";
|
||||
etk::String mapToString(const etk::Map<etk::String, etk::String>& _metadata) {
|
||||
etk::String out = "{";
|
||||
for (auto &it : _metadata) {
|
||||
out += it.first + ":" + it.second + ",";
|
||||
}
|
||||
@ -347,13 +347,13 @@ namespace appl {
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> getSQL(std::string _sqlLikeRequest) override {
|
||||
std::vector<uint32_t> out;
|
||||
etk::Vector<uint32_t> getSQL(etk::String _sqlLikeRequest) override {
|
||||
etk::Vector<uint32_t> out;
|
||||
if (_sqlLikeRequest == "") {
|
||||
throw std::invalid_argument("empty request");
|
||||
}
|
||||
APPL_DEBUG("check : " << _sqlLikeRequest);
|
||||
std::vector<std::vector<std::string>> listAndParsed = interpreteSQLRequest(_sqlLikeRequest);
|
||||
etk::Vector<etk::Vector<etk::String>> listAndParsed = interpreteSQLRequest(_sqlLikeRequest);
|
||||
std::unique_lock<std::mutex> 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<std::string> getMetadataValuesWhere(std::string _keyName, std::string _sqlLikeRequest) override {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> getMetadataValuesWhere(etk::String _keyName, etk::String _sqlLikeRequest) override {
|
||||
etk::Vector<etk::String> out;
|
||||
if (_sqlLikeRequest == "") {
|
||||
throw std::invalid_argument("empty request");
|
||||
}
|
||||
std::vector<std::vector<std::string>> listAndParsed = interpreteSQLRequest(_sqlLikeRequest);
|
||||
etk::Vector<etk::Vector<etk::String>> listAndParsed = interpreteSQLRequest(_sqlLikeRequest);
|
||||
std::unique_lock<std::mutex> 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<zeus::File> internalGetCover(const std::string& _baseName, const std::string& _mediaString, uint32_t _maxSize) {
|
||||
ememory::SharedPtr<zeus::File> 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<std::string>& _notifs, zeus::ProxyFile _cover, std::string _mediaString) {
|
||||
void internalSetCover(const etk::String& _baseName, zeus::ActionNotification<etk::String>& _notifs, zeus::ProxyFile _cover, etk::String _mediaString) {
|
||||
uint64_t importId = 0;
|
||||
{
|
||||
std::unique_lock<std::mutex> 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<zeus::File> 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<std::string>& _notifs, zeus::ProxyFile _cover, uint32_t _mediaId) override {
|
||||
return internalSetCover(g_basePathCover, _notifs, _cover, etk::to_string(_mediaId));
|
||||
void setCover(zeus::ActionNotification<etk::String>& _notifs, zeus::ProxyFile _cover, uint32_t _mediaId) override {
|
||||
return internalSetCover(g_basePathCover, _notifs, _cover, etk::toString(_mediaId));
|
||||
}
|
||||
|
||||
ememory::SharedPtr<zeus::File> getGroupCover(std::string _groupName, uint32_t _maxSize) override {
|
||||
ememory::SharedPtr<zeus::File> getGroupCover(etk::String _groupName, uint32_t _maxSize) override {
|
||||
return internalGetCover(g_basePathCoverGroup, _groupName, _maxSize);
|
||||
}
|
||||
|
||||
void setGroupCover(zeus::ActionNotification<std::string>& _notifs, zeus::ProxyFile _cover, std::string _groupName) override {
|
||||
void setGroupCover(zeus::ActionNotification<etk::String>& _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/";
|
||||
|
@ -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<std::string> tmp = getPrototypeParam();
|
||||
etk::Vector<etk::String> tmp = getPrototypeParam();
|
||||
for (size_t iii=0; iii<tmp.size(); ++iii) {
|
||||
if (iii != 0) {
|
||||
out += ", ";
|
||||
@ -92,10 +92,10 @@ std::string zeus::AbstractFunction::getPrototype() const {
|
||||
}
|
||||
|
||||
|
||||
std::string zeus::AbstractFunction::getSignature() const {
|
||||
std::string out = getPrototypeReturn();
|
||||
etk::String zeus::AbstractFunction::getSignature() const {
|
||||
etk::String out = getPrototypeReturn();
|
||||
out += "(";
|
||||
std::vector<std::string> tmp = getPrototypeParam();
|
||||
etk::Vector<etk::String> tmp = getPrototypeParam();
|
||||
for (size_t iii=0; iii<tmp.size(); ++iii) {
|
||||
if (iii != 0) {
|
||||
out += ",";
|
||||
@ -106,7 +106,7 @@ std::string zeus::AbstractFunction::getSignature() const {
|
||||
return out;
|
||||
}
|
||||
|
||||
zeus::AbstractFunction::AbstractFunction(const std::string& _name):
|
||||
zeus::AbstractFunction::AbstractFunction(const etk::String& _name):
|
||||
m_type(zeus::AbstractFunction::type::unknow),
|
||||
m_name(_name),
|
||||
m_description("") {
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
|
||||
namespace zeus {
|
||||
extern const std::string g_threadKeyTransactionId;
|
||||
extern const std::string g_threadKeyTransactionSource;
|
||||
extern const std::string g_threadKeyTransactionDestination;
|
||||
extern const etk::String g_threadKeyTransactionId;
|
||||
extern const etk::String g_threadKeyTransactionSource;
|
||||
extern const etk::String g_threadKeyTransactionDestination;
|
||||
/**
|
||||
* @bried check if the compilater order the function element call in order or backOrder
|
||||
*/
|
||||
@ -29,7 +29,7 @@ namespace zeus {
|
||||
* @brief Constructor
|
||||
* @param[in] _name Nmae of the function
|
||||
*/
|
||||
AbstractFunction(const std::string& _name);
|
||||
AbstractFunction(const etk::String& _name);
|
||||
public:
|
||||
/**
|
||||
* @brief generic virtual destructor
|
||||
@ -60,28 +60,28 @@ namespace zeus {
|
||||
*/
|
||||
void setType(enum type _type);
|
||||
protected:
|
||||
std::string m_name; //!< name of the function
|
||||
etk::String m_name; //!< name of the function
|
||||
public:
|
||||
/**
|
||||
* @brief Get the name of the function.
|
||||
* @return Function name
|
||||
*/
|
||||
const std::string& getName() const;
|
||||
const etk::String& getName() const;
|
||||
protected:
|
||||
std::string m_description; //!< description of the function
|
||||
etk::String m_description; //!< description of the function
|
||||
public:
|
||||
/**
|
||||
* @brief Get the description of the function
|
||||
* @return The description string of the function (same as doxygen 'brief')
|
||||
*/
|
||||
const std::string& getDescription() const;
|
||||
const etk::String& getDescription() const;
|
||||
/**
|
||||
* @brief Set a new description of the function
|
||||
* @param[in] _desc Descriptive string
|
||||
*/
|
||||
void setDescription(const std::string& _desc);
|
||||
void setDescription(const etk::String& _desc);
|
||||
protected:
|
||||
std::vector<std::pair<std::string, std::string>> m_paramsDescription; //!< List of the parameter descriptions.
|
||||
etk::Vector<etk::Pair<etk::String, etk::String>> 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<std::string> getPrototypeParam() const = 0;
|
||||
virtual etk::Vector<etk::String> getPrototypeParam() const = 0;
|
||||
/**
|
||||
* @brief Execute the function with all parameter properties
|
||||
* @param[in] _interfaceClient Web interface to anser values
|
||||
|
@ -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<std::string> getPrototypeParam() const override {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> getPrototypeParam() const override {
|
||||
etk::Vector<etk::String> out;
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
out.push_back(m_paramType[iii].getName());
|
||||
out.pushBack(m_paramType[iii].getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -197,10 +197,10 @@ namespace zeus {
|
||||
// check parameter number
|
||||
if (_obj->getNumberParameter() != 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<std::string> getPrototypeParam() const override {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> getPrototypeParam() const override {
|
||||
etk::Vector<etk::String> out;
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
out.push_back(m_paramType[iii].getName());
|
||||
out.pushBack(m_paramType[iii].getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -331,10 +331,10 @@ namespace zeus {
|
||||
// check parameter number
|
||||
if (_obj->getNumberParameter() != 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 <typename ZEUS_RETURN, class ZEUS_EVENT, class ZEUS_CLASS_TYPE, typename... ZEUS_TYPES>
|
||||
AbstractFunction* createAbstractFunctionClass(const std::string& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(zeus::ActionNotification<ZEUS_EVENT>& _notifs, ZEUS_TYPES...)) {
|
||||
AbstractFunction* createAbstractFunctionClass(const etk::String& _name, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(zeus::ActionNotification<ZEUS_EVENT>& _notifs, ZEUS_TYPES...)) {
|
||||
return new AbstractActionTypeClass<ZEUS_RETURN, ZEUS_EVENT, ZEUS_CLASS_TYPE, ZEUS_TYPES...>(_name, _fffp);
|
||||
}
|
||||
/**
|
||||
@ -446,7 +446,7 @@ namespace zeus {
|
||||
* @return Abstract type of the function
|
||||
*/
|
||||
template <typename ZEUS_RETURN, class ZEUS_CLASS_TYPE, typename... ZEUS_TYPES>
|
||||
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<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>(_name, _fffp);
|
||||
}
|
||||
}
|
||||
|
@ -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<std::string> getPrototypeParam() const override {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> getPrototypeParam() const override {
|
||||
etk::Vector<etk::String> out;
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
out.push_back(m_paramType[iii].getName());
|
||||
out.pushBack(m_paramType[iii].getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -116,10 +116,10 @@ namespace zeus {
|
||||
}
|
||||
// check parameter number
|
||||
if (_obj->getNumberParameter() != 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 <typename ZEUS_RETURN, typename... ZEUS_TYPES>
|
||||
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<ZEUS_RETURN, ZEUS_TYPES...>(_name, _fffp);
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <zeus/Client.hpp>
|
||||
#include <zeus/debug.hpp>
|
||||
|
||||
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<zeus::Message> _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<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_value);
|
||||
std::string callFunction = callObj->getCall();
|
||||
etk::String callFunction = callObj->getCall();
|
||||
if (callFunction == "link") {
|
||||
// link with a specific service:
|
||||
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||
etk::String serviceName = callObj->getParameter<etk::String>(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<zeus::Message> _value) {
|
||||
ememory::SharedPtr<zeus::Object> 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<zeus::Message> _value) {
|
||||
return;
|
||||
} else if (callFunction == "removeInterface") {
|
||||
ZEUS_VERBOSE("Remove Object : " << callObj);
|
||||
m_interfaceWeb->interfaceRemoved(callObj->getParameter<std::vector<uint16_t>>(0));
|
||||
m_interfaceWeb->interfaceRemoved(callObj->getParameter<etk::Vector<uint16_t>>(0));
|
||||
return;
|
||||
}
|
||||
answerProtocolError(transactionId, "interact with client, musty only call: link/unlink/movelink/removeInterface");
|
||||
@ -135,7 +135,7 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Message> _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<bool> 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<bool> 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<int32_t> zeus::Client::getServiceCount() {
|
||||
return call(ZEUS_NO_ID_OBJECT, ZEUS_ID_GATEWAY, "getServiceCount");
|
||||
}
|
||||
|
||||
zeus::Future<std::vector<std::string>> zeus::Client::getServiceList() {
|
||||
zeus::Future<etk::Vector<etk::String>> 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<zeus::WebServer>();
|
||||
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<uint16_t> 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) {
|
||||
|
@ -22,19 +22,19 @@ namespace zeus {
|
||||
class Client : public eproperty::Interface {
|
||||
friend class ObjectRemote;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyIp; //!< Ip of WebSocket TCP connection
|
||||
eproperty::Value<etk::String> propertyIp; //!< Ip of WebSocket TCP connection
|
||||
eproperty::Value<uint16_t> 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<zeus::WebServer> m_interfaceWeb; //!< Interface on the Websocket interface
|
||||
std::vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> m_listConnectedService; //!< Connect only one time on each service, not needed more.
|
||||
etk::Vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> 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<void(uint32_t, ememory::SharedPtr<zeus::WebServer>& _iface, uint32_t _destination)>; //!< call this function anser to the caller the requested Object
|
||||
|
||||
std::map<std::string,factoryService> m_listServicesAvaillable; //!< list of all factory availlable (to create new services)
|
||||
etk::Map<etk::String,factoryService> 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<class... _ARGS>
|
||||
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<zeus::message::Answer> 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<std::vector<std::string>> getServiceList();
|
||||
zeus::Future<etk::Vector<etk::String>> 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));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ namespace zeus {
|
||||
return static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<float>();
|
||||
}
|
||||
template<>
|
||||
std::string futureGetValue<std::string>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::String futureGetValue<etk::String>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
if ( _promise == nullptr
|
||||
|| _promise->getRaw() == nullptr) {
|
||||
return "";
|
||||
@ -153,11 +153,11 @@ namespace zeus {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return "";
|
||||
}
|
||||
return static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::string>();
|
||||
return static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::String>();
|
||||
}
|
||||
template<>
|
||||
std::vector<int64_t> futureGetValue<std::vector<int64_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<int64_t> out;
|
||||
etk::Vector<int64_t> futureGetValue<etk::Vector<int64_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<int64_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<int64_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<int64_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<int32_t> futureGetValue<std::vector<int32_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<int32_t> out;
|
||||
etk::Vector<int32_t> futureGetValue<etk::Vector<int32_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<int32_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<int32_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<int32_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<int16_t> futureGetValue<std::vector<int16_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<int16_t> out;
|
||||
etk::Vector<int16_t> futureGetValue<etk::Vector<int16_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<int16_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<int16_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<int16_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<int8_t> futureGetValue<std::vector<int8_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<int8_t> out;
|
||||
etk::Vector<int8_t> futureGetValue<etk::Vector<int8_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<int8_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<int8_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<int8_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint64_t> futureGetValue<std::vector<uint64_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<uint64_t> out;
|
||||
etk::Vector<uint64_t> futureGetValue<etk::Vector<uint64_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<uint64_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<uint64_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<uint64_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint32_t> futureGetValue<std::vector<uint32_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<uint32_t> out;
|
||||
etk::Vector<uint32_t> futureGetValue<etk::Vector<uint32_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<uint32_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<uint32_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<uint32_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint16_t> futureGetValue<std::vector<uint16_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<uint16_t> out;
|
||||
etk::Vector<uint16_t> futureGetValue<etk::Vector<uint16_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<uint16_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<uint16_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<uint16_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint8_t> futureGetValue<std::vector<uint8_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<uint8_t> out;
|
||||
etk::Vector<uint8_t> futureGetValue<etk::Vector<uint8_t>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<uint8_t> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<uint8_t>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<uint8_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<double> futureGetValue<std::vector<double>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<double> out;
|
||||
etk::Vector<double> futureGetValue<etk::Vector<double>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<double> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<double>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<double>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<float> futureGetValue<std::vector<float>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<float> out;
|
||||
etk::Vector<float> futureGetValue<etk::Vector<float>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<float> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<float>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<float>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<std::string> futureGetValue<std::vector<std::string>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> futureGetValue<etk::Vector<etk::String>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<etk::String> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<std::string>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<etk::String>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<bool> futureGetValue<std::vector<bool>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
std::vector<bool> out;
|
||||
etk::Vector<bool> futureGetValue<etk::Vector<bool>>(ememory::SharedPtr<zeus::Promise>& _promise) {
|
||||
etk::Vector<bool> 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<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<std::vector<bool>>();
|
||||
out = static_cast<zeus::message::Answer*>(_promise->getRaw().get())->getAnswer<etk::Vector<bool>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
|
@ -124,7 +124,7 @@ namespace zeus {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andThen(std::function<bool(ZEUS_RETURN)> _callback) {
|
||||
zeus::FutureBase::andThen(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(std::move(zeus::Future<ZEUS_RETURN, ZEUS_EVENT>(_fut).get()));
|
||||
return _callback(etk::move(zeus::Future<ZEUS_RETURN, ZEUS_EVENT>(_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<ZEUS_RETURN, ZEUS_EVENT>& andElse(std::function<bool(const std::string&, const std::string&)> _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andElse(std::function<bool(const etk::String&, const etk::String&)> _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<ZEUS_EVENT>()));
|
||||
_callback(etk::move(_msg->getEvent<ZEUS_EVENT>()));
|
||||
});
|
||||
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<void, ZEUS_EVENT>& andElse(std::function<bool(const std::string&, const std::string&)> _callback) {
|
||||
Future<void, ZEUS_EVENT>& andElse(std::function<bool(const etk::String&, const etk::String&)> _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<ZEUS_EVENT>()));
|
||||
_callback(etk::move(_msg->getEvent<ZEUS_EVENT>()));
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <zeus/debug.hpp>
|
||||
|
||||
void zeus::FutureGroup::add(const zeus::FutureBase& _fut) {
|
||||
m_listFuture.push_back(_fut);
|
||||
m_listFuture.pushBack(_fut);
|
||||
}
|
||||
|
||||
void zeus::FutureGroup::wait() const {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <zeus/FutureBase.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
namespace zeus {
|
||||
/**
|
||||
@ -15,7 +15,7 @@ namespace zeus {
|
||||
// TODO : Add the posiboilities to have a andFinished()
|
||||
class FutureGroup {
|
||||
private:
|
||||
std::vector<zeus::FutureBase> m_listFuture; //!< List of all Future that we need to wait the end.
|
||||
etk::Vector<zeus::FutureBase> m_listFuture; //!< List of all Future that we need to wait the end.
|
||||
public:
|
||||
/**
|
||||
* @brief Add an other Future to wait the end.
|
||||
|
@ -41,7 +41,7 @@ void zeus::Object::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
ememory::SharedPtr<zeus::message::Call> callObj = ememory::staticPointerCast<zeus::message::Call>(_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;
|
||||
|
@ -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<zeus::message::Call> _value) = 0;
|
||||
virtual void callBinary(const etk::String& _call, ememory::SharedPtr<zeus::message::Call> _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<class ZEUS_RETURN_VALUE,
|
||||
class ZEUS_CLASS_TYPE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
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<ZEUS_ACTION_TYPE>& _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<class ZEUS_RETURN_VALUE,
|
||||
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_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<zeus::message::Call> _value) override {
|
||||
void callBinary(const etk::String& _call, ememory::SharedPtr<zeus::message::Call> _value) override {
|
||||
for (auto &it2 : m_listFunction) {
|
||||
if (it2 == nullptr) {
|
||||
continue;
|
||||
|
@ -11,31 +11,31 @@ zeus::ObjectIntrospect::ObjectIntrospect(zeus::ObjectRemote& _obj):
|
||||
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::getDescription() {
|
||||
zeus::Future<etk::String> zeus::ObjectIntrospect::getDescription() {
|
||||
return m_obj.call("sys.getDescription");
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::getVersion() {
|
||||
zeus::Future<etk::String> zeus::ObjectIntrospect::getVersion() {
|
||||
return m_obj.call("sys.getVersion");
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::getType() {
|
||||
zeus::Future<etk::String> zeus::ObjectIntrospect::getType() {
|
||||
return m_obj.call("sys.getType");
|
||||
}
|
||||
|
||||
zeus::Future<std::vector<std::string>> zeus::ObjectIntrospect::getAuthors() {
|
||||
zeus::Future<etk::Vector<etk::String>> zeus::ObjectIntrospect::getAuthors() {
|
||||
return m_obj.call("sys.getAuthors");
|
||||
}
|
||||
|
||||
zeus::Future<std::vector<std::string>> zeus::ObjectIntrospect::getFunctions() {
|
||||
zeus::Future<etk::Vector<etk::String>> zeus::ObjectIntrospect::getFunctions() {
|
||||
return m_obj.call("sys.getFunctions");
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::getFunctionPrototype(std::string _functionName) {
|
||||
zeus::Future<etk::String> zeus::ObjectIntrospect::getFunctionPrototype(etk::String _functionName) {
|
||||
return m_obj.call("sys.getFunctionPrototype", _functionName);
|
||||
}
|
||||
|
||||
zeus::Future<std::string> zeus::ObjectIntrospect::getFunctionDescription(std::string _functionName) {
|
||||
zeus::Future<etk::String> zeus::ObjectIntrospect::getFunctionDescription(etk::String _functionName) {
|
||||
return m_obj.call("sys.getFunctionDescription", _functionName);
|
||||
}
|
||||
|
||||
|
@ -24,38 +24,38 @@ namespace zeus {
|
||||
* @brief Get the service/ object description
|
||||
* @return A future of the description
|
||||
*/
|
||||
zeus::Future<std::string> getDescription();
|
||||
zeus::Future<etk::String> getDescription();
|
||||
/**
|
||||
* @brief Get the version of the service/Object
|
||||
* @return A future of the string version
|
||||
*/
|
||||
zeus::Future<std::string> getVersion();
|
||||
zeus::Future<etk::String> getVersion();
|
||||
/**
|
||||
* @brief Get the Type of the service/object. ex: VIDEO, PICTURE, FILE
|
||||
* @return A future of the string type
|
||||
*/
|
||||
zeus::Future<std::string> getType();
|
||||
zeus::Future<etk::String> getType();
|
||||
/**
|
||||
* @brief get the list of all authors of the objects
|
||||
* @return A future on the list of authors. Format: "NAME surname <email@someware.xxx>"
|
||||
*/
|
||||
zeus::Future<std::vector<std::string>> getAuthors();
|
||||
zeus::Future<etk::Vector<etk::String>> getAuthors();
|
||||
/**
|
||||
* @brief get all the function names
|
||||
* @return Future on a list of function names
|
||||
*/
|
||||
zeus::Future<std::vector<std::string>> getFunctions();
|
||||
zeus::Future<etk::Vector<etk::String>> 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<std::string> getFunctionPrototype(std::string _functionName);
|
||||
zeus::Future<etk::String> 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<std::string> getFunctionDescription(std::string _functionName);
|
||||
zeus::Future<etk::String> getFunctionDescription(etk::String _functionName);
|
||||
};
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
|
||||
zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const std::string& _type):
|
||||
zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const etk::String& _type):
|
||||
zeus::WebObj(_iface, _localId, _localObjectId),
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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<class... _ARGS>
|
||||
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<zeus::message::Answer> 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<class... _ARGS>
|
||||
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;
|
||||
|
@ -142,7 +142,7 @@ bool zeus::Promise::setMessage(ememory::SharedPtr<zeus::Message> _value) {
|
||||
callback(ememory::staticPointerCast<zeus::message::Event>(_value));
|
||||
{
|
||||
std::unique_lock<std::mutex> 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<zeus::Message> _value) {
|
||||
Observer callback;
|
||||
{
|
||||
std::unique_lock<std::mutex> 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<std::mutex> 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<zeus::Message> _value) {
|
||||
bool ret = callback(zeus::FutureBase(sharedFromThis()));
|
||||
{
|
||||
std::unique_lock<std::mutex> 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<const zeus::message::Answer*>(m_message.get())->hasError();
|
||||
}
|
||||
|
||||
std::string zeus::Promise::getErrorType() const {
|
||||
etk::String zeus::Promise::getErrorType() const {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (m_message == nullptr) {
|
||||
return "NULL_PTR";
|
||||
@ -221,7 +221,7 @@ std::string zeus::Promise::getErrorType() const {
|
||||
return static_cast<const zeus::message::Answer*>(m_message.get())->getError();
|
||||
}
|
||||
|
||||
std::string zeus::Promise::getErrorHelp() const {
|
||||
etk::String zeus::Promise::getErrorHelp() const {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (m_message == nullptr) {
|
||||
return "This is a nullptr future";
|
||||
|
@ -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
|
||||
|
@ -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<uint8_t> m_dataInternal; //!< the data is allocated in local.
|
||||
etk::Vector<uint8_t> m_dataInternal; //!< the data is allocated in local.
|
||||
public:
|
||||
/**
|
||||
* @brief generic constructor
|
||||
|
@ -53,47 +53,47 @@ zeus::RemoteProcessCall::RemoteProcessCall(const ememory::SharedPtr<zeus::WebSer
|
||||
}
|
||||
}
|
||||
|
||||
void zeus::RemoteProcessCall::setDescription(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setDescription(const etk::String& _desc) {
|
||||
m_description = _desc;
|
||||
}
|
||||
|
||||
std::string zeus::RemoteProcessCall::getDescription() {
|
||||
etk::String zeus::RemoteProcessCall::getDescription() {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void zeus::RemoteProcessCall::setVersion(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setVersion(const etk::String& _desc) {
|
||||
m_version = _desc;
|
||||
}
|
||||
|
||||
std::string zeus::RemoteProcessCall::getVersion() {
|
||||
etk::String zeus::RemoteProcessCall::getVersion() {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
void zeus::RemoteProcessCall::setVersionImplementation(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setVersionImplementation(const etk::String& _desc) {
|
||||
m_versionImplement = _desc;
|
||||
}
|
||||
|
||||
std::string zeus::RemoteProcessCall::getVersionImplementation() {
|
||||
etk::String zeus::RemoteProcessCall::getVersionImplementation() {
|
||||
return m_versionImplement;
|
||||
}
|
||||
|
||||
void zeus::RemoteProcessCall::addAuthor(const std::string& _name, const std::string& _email) {
|
||||
m_authors.push_back(std::make_pair(_name, _email));
|
||||
void zeus::RemoteProcessCall::addAuthor(const etk::String& _name, const etk::String& _email) {
|
||||
m_authors.pushBack(etk::makePair(_name, _email));
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string,std::string>>& zeus::RemoteProcessCall::getAuthors() const {
|
||||
const etk::Vector<etk::Pair<etk::String,etk::String>>& zeus::RemoteProcessCall::getAuthors() const {
|
||||
return m_authors;
|
||||
}
|
||||
|
||||
std::vector<std::string> zeus::RemoteProcessCall::getAuthors2() {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> zeus::RemoteProcessCall::getAuthors2() {
|
||||
etk::Vector<etk::String> 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<std::string> zeus::RemoteProcessCall::getFunctions() {
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> zeus::RemoteProcessCall::getFunctions() {
|
||||
etk::Vector<etk::String> out;
|
||||
for (auto &it: m_listFunction) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -126,15 +126,15 @@ std::vector<std::string> zeus::RemoteProcessCall::getFunctions() {
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
out.push_back(it->getName());
|
||||
out.pushBack(it->getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<std::string> zeus::RemoteProcessCall::getFunctionSignature(std::string _funcName) {
|
||||
etk::Vector<etk::String> zeus::RemoteProcessCall::getFunctionSignature(etk::String _funcName) {
|
||||
/*
|
||||
if (isFunctionAuthorized(_funcName) == false) {
|
||||
return std::vector<std::string>();
|
||||
return etk::Vector<etk::String>();
|
||||
}
|
||||
*/
|
||||
for (auto &it: m_listFunction) {
|
||||
@ -144,15 +144,15 @@ std::vector<std::string> zeus::RemoteProcessCall::getFunctionSignature(std::stri
|
||||
if (it->getName() != _funcName) {
|
||||
continue;
|
||||
}
|
||||
std::vector<std::string> out;
|
||||
etk::Vector<etk::String> out;
|
||||
out = it->getPrototypeParam();
|
||||
out.insert(out.begin(), it->getPrototypeReturn());
|
||||
return out;
|
||||
}
|
||||
return std::vector<std::string>();
|
||||
return etk::Vector<etk::String>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -25,109 +25,109 @@ namespace zeus {
|
||||
*/
|
||||
RemoteProcessCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId);
|
||||
protected:
|
||||
std::vector<zeus::AbstractFunction*> m_listFunction; //!< List of all functions callable
|
||||
etk::Vector<zeus::AbstractFunction*> 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<std::pair<std::string,std::string>> m_authors;//! List of autors of the module (name, email)
|
||||
etk::Vector<etk::Pair<etk::String,etk::String>> 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<std::pair<std::string,std::string>>& getAuthors() const;
|
||||
const etk::Vector<etk::Pair<etk::String,etk::String>>& getAuthors() const;
|
||||
/**
|
||||
* @brief Get simple list of authors
|
||||
* @return List Of user and email in form: "john WHO <jhon.who@here.net>"
|
||||
*/
|
||||
std::vector<std::string> getAuthors2();
|
||||
etk::Vector<etk::String> 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<std::string> getFunctions();
|
||||
etk::Vector<etk::String> 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<std::string> getFunctionSignature(std::string _funcName);
|
||||
etk::Vector<etk::String> 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<class ZEUS_RETURN_VALUE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
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<class ZEUS_RETURN_VALUE,
|
||||
class ZEUS_CLASS_TYPE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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_TYPE_SIGNAL>(&zeus::RemoteSignal<ZEUS_TYPE_SIGNAL>::countConnection, _name),
|
||||
m_remoteObject(_remoteObject),
|
||||
m_name(_name) {
|
||||
|
@ -42,7 +42,7 @@ void zeus::WebObj::display() {
|
||||
}
|
||||
|
||||
void zeus::WebObj::addRemote(uint32_t _id) {
|
||||
m_listRemoteConnected.push_back(_id);
|
||||
m_listRemoteConnected.pushBack(_id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace zeus {
|
||||
ememory::SharedPtr<zeus::WebServer> m_interfaceWeb; //!< web interface
|
||||
uint16_t m_id; //!< Id Of the local interface
|
||||
uint16_t m_objectId; //!< Local Object Id
|
||||
std::vector<uint32_t> m_listRemoteConnected; //!< Number of service connected
|
||||
etk::Vector<uint32_t> m_listRemoteConnected; //!< Number of service connected
|
||||
public:
|
||||
/**
|
||||
* @brief Contructor
|
||||
|
@ -15,7 +15,7 @@ ememory::SharedPtr<zeus::message::Call> 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<zeus::message::Call> 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<std::string> protocols;
|
||||
protocols.push_back("zeus/0.8");
|
||||
protocols.push_back("zeus/1.0");
|
||||
etk::Vector<etk::String> 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<zeus::WebObj> _obj) {
|
||||
//std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_listObject.push_back(_obj);
|
||||
m_listObject.pushBack(_obj);
|
||||
}
|
||||
|
||||
void zeus::WebServer::addWebObjRemote(ememory::SharedPtr<zeus::ObjectRemoteBase> _obj) {
|
||||
//std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_listRemoteObject.push_back(_obj);
|
||||
m_listRemoteObject.pushBack(_obj);
|
||||
}
|
||||
|
||||
void zeus::WebServer::interfaceRemoved(std::vector<uint16_t> _list) {
|
||||
void zeus::WebServer::interfaceRemoved(etk::Vector<uint16_t> _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<zeus::ActionAsyncClient> m_async;
|
||||
etk::Vector<zeus::ActionAsyncClient> 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<zeus::ActionAsyncClient> _async) :
|
||||
m_async(std::move(_async)),
|
||||
SendAsyncBinary(uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, etk::Vector<zeus::ActionAsyncClient> _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<zeus::Message> _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<std::string>& _protocols) {
|
||||
bool zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols) {
|
||||
ZEUS_INFO("Receive Header uri: " << _uri);
|
||||
bool findProtocol = false;
|
||||
for (auto &it : _protocols) {
|
||||
@ -305,7 +305,7 @@ bool zeus::WebServer::onReceiveUri(const std::string& _uri, const std::vector<st
|
||||
return false;
|
||||
}
|
||||
|
||||
void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary) {
|
||||
void zeus::WebServer::onReceiveData(etk::Vector<uint8_t>& _frame, bool _isBinary) {
|
||||
if (_isBinary == true) {
|
||||
ZEUS_ERROR("Receive non binary frame ...");
|
||||
disconnect(true);
|
||||
@ -351,7 +351,7 @@ void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
|
||||
if ( _buffer->getPartFinish() == false
|
||||
&& _buffer->getType() != zeus::message::type::data) {
|
||||
//std::unique_lock<std::mutex> 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<std::mutex> 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<std::mutex> 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::Message> _
|
||||
zeus::FutureBase tmpFuture(_obj->getTransactionId());
|
||||
{
|
||||
std::unique_lock<std::mutex> 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;
|
||||
|
@ -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<class... _ARGS>
|
||||
@ -78,7 +78,7 @@ namespace zeus {
|
||||
ememory::SharedPtr<zeus::message::Call> _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<zeus::message::Call> 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<ememory::SharedPtr<zeus::WebObj>> m_actifObject; //!< List of all active object created and that remove is in progress ...
|
||||
etk::Vector<ememory::SharedPtr<zeus::WebObj>> 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<ememory::SharedPtr<zeus::Message>> m_listPartialMessage; //!< list of all message that data has not finished to arrive.
|
||||
etk::Vector<ememory::SharedPtr<zeus::Message>> m_listPartialMessage; //!< list of all message that data has not finished to arrive.
|
||||
uint16_t m_localAddress; //!< Local client address.
|
||||
uint16_t m_localIdObjectIncrement; //!< attribute an unique ID for an object.
|
||||
public:
|
||||
@ -142,8 +142,8 @@ namespace zeus {
|
||||
return m_localIdObjectIncrement++;
|
||||
}
|
||||
private:
|
||||
std::vector<ememory::SharedPtr<zeus::WebObj>> m_listObject; //!< List of all local object that is reference in the system.
|
||||
std::vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> m_listRemoteObject; //!< List of all object that we have a reference in the local interface.
|
||||
etk::Vector<ememory::SharedPtr<zeus::WebObj>> m_listObject; //!< List of all local object that is reference in the system.
|
||||
etk::Vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> 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<uint16_t> _list);
|
||||
void interfaceRemoved(etk::Vector<uint16_t> _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<std::pair<uint64_t, zeus::FutureBase>> m_pendingCall; //!< List of pending call interface
|
||||
etk::Vector<etk::Pair<uint64_t, zeus::FutureBase>> m_pendingCall; //!< List of pending call interface
|
||||
public:
|
||||
using Observer = std::function<void(ememory::SharedPtr<zeus::Message>)>; //!< 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<bool(const std::string&)>; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not)
|
||||
using ObserverRequestUri = std::function<bool(const etk::String&)>; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not)
|
||||
protected:
|
||||
ObserverRequestUri m_observerRequestUri; //!< Observer on a requesting URI connection
|
||||
public:
|
||||
@ -198,8 +198,8 @@ namespace zeus {
|
||||
* @param[in] _func Function to call.
|
||||
*/
|
||||
template<class CLASS_TYPE>
|
||||
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<std::string>& _protocols);
|
||||
bool onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols);
|
||||
/**
|
||||
* @brief The Zeus protocol is based on a webSocket, then the connection can send full fragment (it call newMessage when data is parsed
|
||||
* @param[in] _frame A frame that has been just received
|
||||
* @param[in] _isBinary the frame is binary if true, it is a string id false
|
||||
*/
|
||||
void onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary);
|
||||
void onReceiveData(etk::Vector<uint8_t>& _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<ActionAsync> m_threadAsyncList; //!< List of action to send (current)
|
||||
std::vector<ActionAsync> m_threadAsyncList2; //!< list of action to send whenwurrent is sending in progress
|
||||
etk::Vector<ActionAsync> m_threadAsyncList; //!< List of action to send (current)
|
||||
etk::Vector<ActionAsync> 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<class... _ARGS>
|
||||
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<zeus::message::Call> 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
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <zeus/message/Answer.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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<zeus::message::Data> _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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <zeus/message/Call.hpp>
|
||||
|
||||
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<getNumberParameter(); ++iii) {
|
||||
@ -26,11 +26,11 @@ void zeus::message::Call::generateDisplay(std::ostream& _os) const {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& zeus::message::Call::getCall() const {
|
||||
const etk::String& zeus::message::Call::getCall() const {
|
||||
return m_callName;
|
||||
}
|
||||
|
||||
void zeus::message::Call::setCall(const std::string& _value) {
|
||||
void zeus::message::Call::setCall(const etk::String& _value) {
|
||||
m_callName = _value;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace zeus {
|
||||
public message::Parameter {
|
||||
friend class zeus::Message;
|
||||
protected:
|
||||
std::string m_callName;
|
||||
etk::String m_callName;
|
||||
protected:
|
||||
/**
|
||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::message::Call::create
|
||||
@ -27,7 +27,7 @@ namespace zeus {
|
||||
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||
void appendMessageData(ememory::SharedPtr<zeus::message::Data> _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);
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -10,11 +10,11 @@
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <zeus/message/Data.hpp>
|
||||
|
||||
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) {
|
||||
|
@ -17,7 +17,7 @@ namespace zeus {
|
||||
protected:
|
||||
uint32_t m_partId;
|
||||
uint16_t m_parameterId;
|
||||
std::vector<uint8_t> m_data;
|
||||
etk::Vector<uint8_t> 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<zeus::message::Data> _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<uint8_t>& getData() const {
|
||||
const etk::Vector<uint8_t>& getData() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <zeus/message/Event.hpp>
|
||||
|
||||
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) + "'";
|
||||
|
@ -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
|
||||
|
@ -64,7 +64,7 @@ void zeus::Message::clear() {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH;
|
||||
}
|
||||
|
||||
std::ostream& zeus::operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Message> _obj) {
|
||||
etk::Stream& zeus::operator <<(etk::Stream& _os, ememory::SharedPtr<zeus::Message> _obj) {
|
||||
_os << "zeus::Message: ";
|
||||
if (_obj == nullptr) {
|
||||
_os << "nullptr";
|
||||
@ -73,12 +73,12 @@ std::ostream& zeus::operator <<(std::ostream& _os, ememory::SharedPtr<zeus::Mess
|
||||
}
|
||||
return _os;
|
||||
}
|
||||
void zeus::Message::generateDisplay(std::ostream& _os) const {
|
||||
//out += " v=" + etk::to_string(m_header.versionProtocol); // set it in the websocket
|
||||
_os << " if=" << etk::to_string(getInterfaceId());
|
||||
_os << " tr-id=" << etk::to_string(getTransactionId());
|
||||
_os << " src=" << etk::to_string(getSourceId()) << "/" << etk::to_string(getSourceObjectId());
|
||||
_os << " dst=" << etk::to_string(getDestinationId()) << "/" << etk::to_string(getDestinationObjectId());
|
||||
void zeus::Message::generateDisplay(etk::Stream& _os) const {
|
||||
//out += " v=" + etk::toString(m_header.versionProtocol); // set it in the websocket
|
||||
_os << " if=" << etk::toString(getInterfaceId());
|
||||
_os << " tr-id=" << etk::toString(getTransactionId());
|
||||
_os << " src=" << etk::toString(getSourceId()) << "/" << etk::toString(getSourceObjectId());
|
||||
_os << " dst=" << etk::toString(getDestinationId()) << "/" << etk::toString(getDestinationObjectId());
|
||||
if (getPartFinish() == true) {
|
||||
_os << " finish";
|
||||
}
|
||||
@ -191,7 +191,7 @@ ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus:
|
||||
return ememory::SharedPtr<zeus::Message>(new zeus::Message(_iface));
|
||||
}
|
||||
|
||||
ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer) {
|
||||
ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface, const etk::Vector<uint8_t>& _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));
|
||||
|
@ -141,7 +141,7 @@ namespace zeus {
|
||||
* </pre>
|
||||
*/
|
||||
class Message {
|
||||
friend std::ostream& operator<<(std::ostream&, zeus::Message*);
|
||||
friend etk::Stream& operator<<(etk::Stream&, zeus::Message*);
|
||||
protected:
|
||||
ememory::SharedPtr<zeus::WebServer> 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<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer);
|
||||
static ememory::SharedPtr<zeus::Message> create(ememory::SharedPtr<zeus::WebServer> _iface, const etk::Vector<uint8_t>& _buffer);
|
||||
protected:
|
||||
uint32_t m_interfaceID; //!< For debug ==> unterface ID ...
|
||||
message::headerBin m_header; //!< header of the protocol
|
||||
std::vector<zeus::ActionAsyncClient> m_multipleSend; //!< Async element to send data on the webinterface when too big ...
|
||||
etk::Vector<zeus::ActionAsyncClient> 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<zeus::ActionAsyncClient> moveAsync() {
|
||||
return std::move(m_multipleSend);
|
||||
etk::Vector<zeus::ActionAsyncClient> 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<zeus::Message> _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, ememory::SharedPtr<zeus::Message> _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<uint8_t>& _data, zeus::message::ParamType _type);
|
||||
void addType(etk::Vector<uint8_t>& _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<uint8_t>& _data, const std::string _type);
|
||||
void addTypeObject(etk::Vector<uint8_t>& _data, const etk::String _type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<void>, "vector:empty", 0x0102, true, true);
|
||||
generate_basic_type(std::vector<bool>, "vector:bool", 0x0102, false, true);
|
||||
generate_basic_type(std::vector<float>, "vector:float", 0x0103, true, true);
|
||||
generate_basic_type(std::vector<double>, "vector:double", 0x0104, true, true);
|
||||
generate_basic_type(std::vector<int64_t>, "vector:int64", 0x0105, true, true);
|
||||
generate_basic_type(std::vector<int32_t>, "vector:int32", 0x0106, true, true);
|
||||
generate_basic_type(std::vector<int16_t>, "vector:int16", 0x0107, true, true);
|
||||
generate_basic_type(std::vector<int8_t>, "vector:int8", 0x0108, true, true);
|
||||
generate_basic_type(std::vector<uint64_t>, "vector:uint64", 0x0109, true, true);
|
||||
generate_basic_type(std::vector<uint32_t>, "vector:uint32", 0x010A, true, true);
|
||||
generate_basic_type(std::vector<uint16_t>, "vector:uint16", 0x010B, true, true);
|
||||
generate_basic_type(std::vector<uint8_t>, "vector:uint8", 0x010C, true, true);
|
||||
generate_basic_type(std::vector<std::string>, "vector:string", 0x010D, false, true);
|
||||
generate_basic_type(etk::Vector<void>, "vector:empty", 0x0102, true, true);
|
||||
generate_basic_type(etk::Vector<bool>, "vector:bool", 0x0102, false, true);
|
||||
generate_basic_type(etk::Vector<float>, "vector:float", 0x0103, true, true);
|
||||
generate_basic_type(etk::Vector<double>, "vector:double", 0x0104, true, true);
|
||||
generate_basic_type(etk::Vector<int64_t>, "vector:int64", 0x0105, true, true);
|
||||
generate_basic_type(etk::Vector<int32_t>, "vector:int32", 0x0106, true, true);
|
||||
generate_basic_type(etk::Vector<int16_t>, "vector:int16", 0x0107, true, true);
|
||||
generate_basic_type(etk::Vector<int8_t>, "vector:int8", 0x0108, true, true);
|
||||
generate_basic_type(etk::Vector<uint64_t>, "vector:uint64", 0x0109, true, true);
|
||||
generate_basic_type(etk::Vector<uint32_t>, "vector:uint32", 0x010A, true, true);
|
||||
generate_basic_type(etk::Vector<uint16_t>, "vector:uint16", 0x010B, true, true);
|
||||
generate_basic_type(etk::Vector<uint8_t>, "vector:uint8", 0x010C, true, true);
|
||||
generate_basic_type(etk::Vector<etk::String>, "vector:string", 0x010D, false, true);
|
||||
|
||||
const uint16_t zeus::message::paramTypeObject = 0xFFFF;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
|
||||
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
|
||||
|
@ -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<uint8_t>()));
|
||||
m_parameter.resize(nbParameters, etk::makePair(-1, etk::Vector<uint8_t>()));
|
||||
// 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<uint8_t> data;
|
||||
etk::Vector<uint8_t> 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<uint32_t>().getId()) { m_parameter[_id].first = 2; return createType<uint32_t>(); }
|
||||
if (typeId == createType<uint16_t>().getId()) { m_parameter[_id].first = 2; return createType<uint16_t>(); }
|
||||
if (typeId == createType<uint8_t>().getId()) { m_parameter[_id].first = 2; return createType<uint8_t>(); }
|
||||
if (typeId == createType<std::string>().getId()) { m_parameter[_id].first = 2; return createType<std::string>(); }
|
||||
if (typeId == createType<std::vector<void>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<void>>(); }
|
||||
if (typeId == createType<std::vector<bool>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<bool>>(); }
|
||||
if (typeId == createType<std::vector<float>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<float>>(); }
|
||||
if (typeId == createType<std::vector<double>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<double>>(); }
|
||||
if (typeId == createType<std::vector<int64_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<int64_t>>(); }
|
||||
if (typeId == createType<std::vector<int32_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<int32_t>>(); }
|
||||
if (typeId == createType<std::vector<int16_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<int16_t>>(); }
|
||||
if (typeId == createType<std::vector<int8_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<int8_t>>(); }
|
||||
if (typeId == createType<std::vector<uint64_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<uint64_t>>(); }
|
||||
if (typeId == createType<std::vector<uint32_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<uint32_t>>(); }
|
||||
if (typeId == createType<std::vector<uint16_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<uint16_t>>(); }
|
||||
if (typeId == createType<std::vector<uint8_t>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<uint8_t>>(); }
|
||||
if (typeId == createType<std::vector<std::string>>().getId()) { m_parameter[_id].first = 2; return createType<std::vector<std::string>>(); }
|
||||
if (typeId == createType<etk::String>().getId()) { m_parameter[_id].first = 2; return createType<etk::String>(); }
|
||||
if (typeId == createType<etk::Vector<void>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<void>>(); }
|
||||
if (typeId == createType<etk::Vector<bool>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<bool>>(); }
|
||||
if (typeId == createType<etk::Vector<float>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<float>>(); }
|
||||
if (typeId == createType<etk::Vector<double>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<double>>(); }
|
||||
if (typeId == createType<etk::Vector<int64_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<int64_t>>(); }
|
||||
if (typeId == createType<etk::Vector<int32_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<int32_t>>(); }
|
||||
if (typeId == createType<etk::Vector<int16_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<int16_t>>(); }
|
||||
if (typeId == createType<etk::Vector<int8_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<int8_t>>(); }
|
||||
if (typeId == createType<etk::Vector<uint64_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<uint64_t>>(); }
|
||||
if (typeId == createType<etk::Vector<uint32_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<uint32_t>>(); }
|
||||
if (typeId == createType<etk::Vector<uint16_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<uint16_t>>(); }
|
||||
if (typeId == createType<etk::Vector<uint8_t>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<uint8_t>>(); }
|
||||
if (typeId == createType<etk::Vector<etk::String>>().getId()) { m_parameter[_id].first = 2; return createType<etk::Vector<etk::String>>(); }
|
||||
if (typeId == createType<zeus::Raw>().getId()) { m_parameter[_id].first = 2; return createType<zeus::Raw>(); }
|
||||
if (typeId == paramTypeObject) {
|
||||
const char* tmp = reinterpret_cast<const char*>(&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<int64_t>(_id));
|
||||
return etk::toString(getParameter<int64_t>(_id));
|
||||
}
|
||||
}
|
||||
if (paramType == createType<bool>()) {
|
||||
return etk::to_string(getParameter<bool>(_id));
|
||||
return etk::toString(getParameter<bool>(_id));
|
||||
}
|
||||
if (paramType == createType<std::string>()) {
|
||||
return "{" + getParameter<std::string>(_id) + "}";
|
||||
if (paramType == createType<etk::String>()) {
|
||||
return "{" + getParameter<etk::String>(_id) + "}";
|
||||
}
|
||||
if (paramType == createType<std::vector<std::string>>()) {
|
||||
return "[" + etk::to_string(getParameter<std::vector<std::string>>(_id)) + "]";
|
||||
if (paramType == createType<etk::Vector<etk::String>>()) {
|
||||
return "[" + etk::toString(getParameter<etk::Vector<etk::String>>(_id)) + "]";
|
||||
}
|
||||
return paramType.getName();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace zeus {
|
||||
class Parameter:
|
||||
public Message {
|
||||
protected:
|
||||
mutable std::vector<std::pair<int32_t,std::vector<uint8_t>>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...)
|
||||
mutable etk::Vector<etk::Pair<int32_t,etk::Vector<uint8_t>>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...)
|
||||
public:
|
||||
Parameter(ememory::SharedPtr<zeus::WebServer> _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;
|
||||
|
@ -16,47 +16,47 @@
|
||||
#include <zeus/WebServer.hpp>
|
||||
|
||||
|
||||
void zeus::message::addType(std::vector<uint8_t>& _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<uint8_t>& _data, zeus::message::ParamType _type) {
|
||||
_data.pushBack(uint8_t(_type.getId()>>8));
|
||||
_data.pushBack(uint8_t(_type.getId()));
|
||||
}
|
||||
|
||||
void zeus::message::addTypeObject(std::vector<uint8_t>& _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<uint8_t>& _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<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<void>());
|
||||
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<uint8_t> data;
|
||||
addType(data, createType<std::vector<void>>());
|
||||
m_parameter.push_back(std::make_pair(2,data));
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<void>>());
|
||||
m_parameter.pushBack(etk::makePair(2,data));
|
||||
}
|
||||
namespace zeus {
|
||||
namespace message {
|
||||
template<>
|
||||
void Parameter::addParameter<std::string>(uint16_t _paramId, const std::string& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::string>());
|
||||
void Parameter::addParameter<etk::String>(uint16_t _paramId, const etk::String& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::String>());
|
||||
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<std::vector<std::string>>(uint16_t _paramId, const std::vector<std::string>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<std::string>>());
|
||||
void Parameter::addParameter<etk::Vector<etk::String>>(uint16_t _paramId, const etk::Vector<etk::String>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<etk::String>>());
|
||||
// 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<std::vector<bool>>(uint16_t _paramId, const std::vector<bool>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<bool>>());
|
||||
void Parameter::addParameter<etk::Vector<bool>>(uint16_t _paramId, const etk::Vector<bool>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<bool>>());
|
||||
// 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<std::vector<int8_t>>(uint16_t _paramId, const std::vector<int8_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<int8_t>>());
|
||||
void Parameter::addParameter<etk::Vector<int8_t>>(uint16_t _paramId, const etk::Vector<int8_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<int8_t>>());
|
||||
// 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<std::vector<int16_t>>(uint16_t _paramId, const std::vector<int16_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<int16_t>>());
|
||||
void Parameter::addParameter<etk::Vector<int16_t>>(uint16_t _paramId, const etk::Vector<int16_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<int16_t>>());
|
||||
// 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<std::vector<int32_t>>(uint16_t _paramId, const std::vector<int32_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<int32_t>>());
|
||||
void Parameter::addParameter<etk::Vector<int32_t>>(uint16_t _paramId, const etk::Vector<int32_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<int32_t>>());
|
||||
// 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<std::vector<int64_t>>(uint16_t _paramId, const std::vector<int64_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<int64_t>>());
|
||||
void Parameter::addParameter<etk::Vector<int64_t>>(uint16_t _paramId, const etk::Vector<int64_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<int64_t>>());
|
||||
// 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<std::vector<uint8_t>>(uint16_t _paramId, const std::vector<uint8_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<uint8_t>>());
|
||||
void Parameter::addParameter<etk::Vector<uint8_t>>(uint16_t _paramId, const etk::Vector<uint8_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<uint8_t>>());
|
||||
// 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<std::vector<uint16_t>>(uint16_t _paramId, const std::vector<uint16_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<uint16_t>>());
|
||||
void Parameter::addParameter<etk::Vector<uint16_t>>(uint16_t _paramId, const etk::Vector<uint16_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<uint16_t>>());
|
||||
// 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<std::vector<uint32_t>>(uint16_t _paramId, const std::vector<uint32_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<uint32_t>>());
|
||||
void Parameter::addParameter<etk::Vector<uint32_t>>(uint16_t _paramId, const etk::Vector<uint32_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<uint32_t>>());
|
||||
// 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<std::vector<uint64_t>>(uint16_t _paramId, const std::vector<uint64_t>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<uint64_t>>());
|
||||
void Parameter::addParameter<etk::Vector<uint64_t>>(uint16_t _paramId, const etk::Vector<uint64_t>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<uint64_t>>());
|
||||
// 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<std::vector<float>>(uint16_t _paramId, const std::vector<float>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<float>>());
|
||||
void Parameter::addParameter<etk::Vector<float>>(uint16_t _paramId, const etk::Vector<float>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<float>>());
|
||||
// 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<std::vector<double>>(uint16_t _paramId, const std::vector<double>& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
addType(data, createType<std::vector<double>>());
|
||||
void Parameter::addParameter<etk::Vector<double>>(uint16_t _paramId, const etk::Vector<double>& _value) {
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<etk::Vector<double>>());
|
||||
// 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<int8_t>(uint16_t _paramId, const int8_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<int8_t>());
|
||||
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<uint8_t>(uint16_t _paramId, const uint8_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<uint8_t>());
|
||||
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<int16_t>(uint16_t _paramId, const int16_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<int16_t>());
|
||||
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>(uint16_t _paramId, const uint16_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<uint16_t>());
|
||||
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<int32_t>(uint16_t _paramId, const int32_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<int32_t>());
|
||||
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<uint32_t>(uint16_t _paramId, const uint32_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<uint32_t>());
|
||||
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<int64_t>(uint16_t _paramId, const int64_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<int64_t>());
|
||||
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<uint64_t>(uint16_t _paramId, const uint64_t& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<uint64_t>());
|
||||
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<float>(uint16_t _paramId, const float& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<float>());
|
||||
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<double>(uint16_t _paramId, const double& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<double>());
|
||||
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<bool>(uint16_t _paramId, const bool& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<bool>());
|
||||
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<zeus::Raw>(uint16_t _paramId, const zeus::Raw& _value) {
|
||||
std::vector<uint8_t> data;
|
||||
etk::Vector<uint8_t> data;
|
||||
addType(data, createType<zeus::Raw>());
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user