From c6a592592a9b29be2f29e028613665fa92138980 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 7 Oct 2016 23:22:57 +0200 Subject: [PATCH] [DEV] add an init needed for enet --- lutin_zeus.py | 2 ++ test/client/appl/main.cpp | 2 ++ test/service1/appl/main.cpp | 2 ++ tools/picture/appl/main.cpp | 2 ++ tools/system-gateway/appl/main.cpp | 2 ++ tools/system-user/appl/main.cpp | 2 ++ zeus/zeus.cpp | 41 ++++++++++++++++++++++++++++++ zeus/zeus.hpp | 24 +++++++++++++++++ 8 files changed, 77 insertions(+) create mode 100644 zeus/zeus.cpp create mode 100644 zeus/zeus.hpp diff --git a/lutin_zeus.py b/lutin_zeus.py index 646e7ea..7c87214 100644 --- a/lutin_zeus.py +++ b/lutin_zeus.py @@ -35,6 +35,7 @@ def configure(target, my_module): ]) my_module.add_path(".") my_module.add_src_file([ + 'zeus/zeus.cpp', 'zeus/AbstractFunction.cpp', 'zeus/FutureBase.cpp', 'zeus/Future.cpp', @@ -57,6 +58,7 @@ def configure(target, my_module): 'zeus/mineType.cpp', ]) my_module.add_header_file([ + 'zeus/zeus.hpp', 'zeus/AbstractFunction.hpp', 'zeus/AbstractFunctionTypeDirect.hpp', 'zeus/AbstractFunctionTypeClass.hpp', diff --git a/test/client/appl/main.cpp b/test/client/appl/main.cpp index 50760d7..d3cdca0 100644 --- a/test/client/appl/main.cpp +++ b/test/client/appl/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -16,6 +17,7 @@ int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); + zeus::init(_argc, _argv); zeus::Client client1; for (int32_t iii=0; iii<_argc ; ++iii) { std::string data = _argv[iii]; diff --git a/test/service1/appl/main.cpp b/test/service1/appl/main.cpp index 4e86dd5..ca40c9d 100644 --- a/test/service1/appl/main.cpp +++ b/test/service1/appl/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,7 @@ namespace appl { int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); + zeus::init(_argc, _argv); ememory::SharedPtr userMng = ememory::makeShared(); zeus::ServiceType serviceInterface(userMng); serviceInterface.setDescription("Calculator interface"); diff --git a/tools/picture/appl/main.cpp b/tools/picture/appl/main.cpp index bb4ba0c..ceb17b1 100644 --- a/tools/picture/appl/main.cpp +++ b/tools/picture/appl/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -373,6 +374,7 @@ namespace appl { int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); + zeus::init(_argc, _argv); std::string ip; uint16_t port = 0; for (int32_t iii=0; iii<_argc ; ++iii) { diff --git a/tools/system-gateway/appl/main.cpp b/tools/system-gateway/appl/main.cpp index ad891c2..8384d2a 100644 --- a/tools/system-gateway/appl/main.cpp +++ b/tools/system-gateway/appl/main.cpp @@ -7,12 +7,14 @@ #include #include #include +#include #include #include int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); + zeus::init(_argc, _argv); appl::GateWay basicGateway; for (int32_t iii=0; iii<_argc ; ++iii) { std::string data = _argv[iii]; diff --git a/tools/system-user/appl/main.cpp b/tools/system-user/appl/main.cpp index b94409c..deed1c6 100644 --- a/tools/system-user/appl/main.cpp +++ b/tools/system-user/appl/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,7 @@ namespace appl { int main(int _argc, const char *_argv[]) { etk::init(_argc, _argv); + zeus::init(_argc, _argv); std::string ip; uint16_t port = 0; for (int32_t iii=0; iii<_argc ; ++iii) { diff --git a/zeus/zeus.cpp b/zeus/zeus.cpp new file mode 100644 index 0000000..0ff1302 --- /dev/null +++ b/zeus/zeus.cpp @@ -0,0 +1,41 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ +#include +#include +#include + +static bool& getInitSatatus() { + static bool isInit = false; + return isInit; +} + +void zeus::init(int _argc, const char** _argv) { + for (int32_t iii=0; iii<_argc; ++iii) { + std::string value = _argv[iii]; + if (etk::start_with(value, "--zeus") == true) { + ZEUS_ERROR("Unknow parameter type: '" << value << "'"); + } + } + if (getInitSatatus() == false) { + enet::init(_argc, _argv); + getInitSatatus() = true; + } +} + +void zeus::unInit() { + if (getInitSatatus() == false) { + ZEUS_ERROR("Request UnInit of enent already done ..."); + } else { + enet::unInit(); + } + getInitSatatus() = false; +} + + +bool zeus::isInit() { + return getInitSatatus(); +} + diff --git a/zeus/zeus.hpp b/zeus/zeus.hpp new file mode 100644 index 0000000..9d7b69a --- /dev/null +++ b/zeus/zeus.hpp @@ -0,0 +1,24 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ +#pragma once + +namespace zeus { + /** + * @brief Initialize zeus + * @param[in] _argc Number of argument list + * @param[in] _argv List of arguments + */ + void init(int _argc, const char** _argv); + /** + * @brief un-Initialize zeus + */ + void unInit(); + /** + * @brief Check if the library zeus is initialized + * @return bool value to chek if initialize ot not + */ + bool isInit(); +}