11# wsjcpp-employees
22
3- [ ![ Build Status ] ( https://api.travis-ci.org/wsjcpp/wsjcpp-employees.svg?branch=master )] ( https://travis-ci.org/wsjcpp/wsjcpp-employees ) [ ![ Github Stars] ( https://img.shields.io/github/stars/wsjcpp/wsjcpp-employees.svg?label=github%20%E2%98%85 )] ( https://github.com/wsjcpp/wsjcpp-employees/stargazers ) [ ![ Github Stars] ( https://img.shields.io/github/contributors/wsjcpp/wsjcpp-employees.svg )] ( https://github.com/wsjcpp/wsjcpp-employees/ ) [ ![ Github Forks] ( https://img.shields.io/github/forks/wsjcpp/wsjcpp-employees.svg?label=github%20forks )] ( https://github.com/wsjcpp/wsjcpp-employees/network/members ) [ ![ Total alerts] ( https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18 )] ( https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/alerts/ ) [ ![ Language grade: C/C++] ( https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18 )] ( https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/context:cpp )
3+ [ ![ Github Stars] ( https://img.shields.io/github/stars/wsjcpp/wsjcpp-employees.svg?label=github%20%E2%98%85 )] ( https://github.com/wsjcpp/wsjcpp-employees ) [ ![ Github Stars] ( https://img.shields.io/github/contributors/wsjcpp/wsjcpp-employees.svg )] ( https://github.com/wsjcpp/wsjcpp-employees/ ) [ ![ Github Forks] ( https://img.shields.io/github/forks/wsjcpp/wsjcpp-employees.svg?label=github%20forks )] ( https://github.com/wsjcpp/wsjcpp-employees/network/members ) [ ![ Total alerts] ( https://img.shields.io/lgtm/alerts/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18 )] ( https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/alerts/ ) [ ![ Language grade: C/C++] ( https://img.shields.io/lgtm/grade/cpp/g/wsjcpp/wsjcpp-employees.svg?logo=lgtm&logoWidth=18 )] ( https://lgtm.com/projects/g/wsjcpp/wsjcpp-employees/context:cpp )
44
55C++ classes for service-architecture
66
@@ -13,8 +13,6 @@ $ wsjcpp install https://github.com/wsjcpp/wsjcpp-employees:master
1313
1414or include this files:
1515
16- - src.wsjcpp/wsjcpp_core/wsjcpp_core.h
17- - src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp
1816- src/wsjcpp_employees.h
1917- src/wsjcpp_employees.cpp
2018
@@ -27,6 +25,30 @@ Example main func:
2725#include <wsjcpp_core.h>
2826#include <wsjcpp_employees.h>
2927
28+ // logger
29+ class EmployeesLogger : public IWsjcppEmployeesLogger {
30+ public:
31+ virtual void info(const std::string &tag, const std::string &message) override {
32+ WsjcppLog::info(tag, message);
33+ }
34+
35+ virtual void ok(const std::string &tag, const std::string &message) override {
36+ WsjcppLog::ok(tag, message);
37+ }
38+
39+ virtual void warn(const std::string &tag, const std::string &message) override {
40+ WsjcppLog::warn(tag, message);
41+ }
42+
43+ virtual void err(const std::string &tag, const std::string &message) override {
44+ WsjcppLog::err(tag, message);
45+ }
46+
47+ virtual void throw_err(const std::string &tag, const std::string &message) override {
48+ WsjcppLog::throw_err(tag, message);
49+ }
50+ };
51+
3052int main(int argc, const char* argv[]) {
3153 std::string TAG = "MAIN";
3254 std::string appName = std::string(WSJCPP_NAME);
@@ -36,11 +58,12 @@ int main(int argc, const char* argv[]) {
3658 }
3759 WsjcppLog::setPrefixLogFile("wsjcpp-employees");
3860 WsjcppLog::setLogDirectory(".logs");
61+ WsjcppEmployees::setLogger(new EmployeesLogger());
3962
4063 // init employees
4164 bool bSilent = false;
42- WsjcppEmployeesInit empls ({}, bSilent);
43- if (!empls.inited ) {
65+ WsjcppEmployeesInit employees ({}, bSilent);
66+ if (!employees.initialized ) {
4467 WsjcppLog::err(TAG, "Could not init employees");
4568 return -1;
4669 }
@@ -53,6 +76,8 @@ Example output:
5376% ./wsjcpp-employees
54772020-03-22 11:32:31.750, 0x0x110c21dc0 [INFO] WJSCppEmployRuntimeGlobalCache: init
55782020-03-22 11:32:31.750, 0x0x110c21dc0 [OK] Employees_init: Init WJSCppEmployRuntimeGlobalCache ... OK
79+ 2026-03-05 16:49:45.106, 0x00007139fa6fb740 [INFO] WsjcppEmployRuntimeGlobalCache: deinit
80+ 2026-03-05 16:49:45.106, 0x00007139fa6fb740 [OK] WsjcppEmployees::deinit: WsjcppEmployRuntimeGlobalCache ... DEINIT_OK
5681```
5782
5883Now you can call from any place:
@@ -120,7 +145,7 @@ Example source-code `src/employ_my_impl.cpp`:
120145// ---------------------------------------------------------------------
121146// EmployMyImpl
122147
123- REGISTRY_WJSCPP_SERVICE_LOCATOR (EmployMyImpl)
148+ REGISTRY_WSJCPP_EMPLOY (EmployMyImpl)
124149
125150EmployMyImpl::EmployMyImpl()
126151: WsjcppEmployBase({IMyImpl::name()}, {}) {
@@ -158,6 +183,13 @@ void someFunc() {
158183 pYourEmploy->doSomething();
159184}
160185
186+ void someFunc2() {
187+ // if not found then no call throw exception
188+ YourEmploy *pYourEmploy2 = findWsjcppEmploy<YourEmploy2>(false);
189+ if (pYourEmploy2)
190+ pYourEmploy2->doSomething();
191+ }
192+
161193void main() {
162194 ...
163195 WsjcppEmployeesInit empls({});
0 commit comments