From: Marcin Masternak Date: Thu, 9 Jun 2016 15:29:02 +0000 (+0200) Subject: [my-place] Dynamic loading of VisitCateger library. X-Git-Tag: submit/tizen/20160622.045445^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=acf4e1bc3f23a9642a8da38290fa2e154708d54c;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git [my-place] Dynamic loading of VisitCateger library. Change-Id: Ie3ea00d76a36aa1bedebfb130365aee10b886997 Signed-off-by: Marcin Masternak --- diff --git a/src/my-place/CMakeLists.txt b/src/my-place/CMakeLists.txt index 662895b..c336024 100644 --- a/src/my-place/CMakeLists.txt +++ b/src/my-place/CMakeLists.txt @@ -1,11 +1,12 @@ SET(target "${target_prefix}-my-place") SET(DEPS ${DEPS} + gmodule-2.0 capi-location-manager capi-network-wifi ) -FILE(GLOB_RECURSE SRCS *.cpp) +FILE(GLOB SRCS *.cpp facade/*.cpp place/*.cpp utils/*.cpp visit-detector/*.cpp) INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(PKG_MYPLACE REQUIRED ${DEPS}) @@ -18,3 +19,5 @@ ADD_LIBRARY(${target} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${target} ${PKG_MYPLACE_LDFLAGS} ${target_shared}) INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) + +ADD_SUBDIRECTORY(visit-categer) \ No newline at end of file diff --git a/src/my-place/visit-categer/CMakeLists.txt b/src/my-place/visit-categer/CMakeLists.txt new file mode 100644 index 0000000..93fb055 --- /dev/null +++ b/src/my-place/visit-categer/CMakeLists.txt @@ -0,0 +1,7 @@ +SET(target "${target_prefix}-my-place-visit-categer") + +FILE(GLOB SRCS *.cpp) + +ADD_LIBRARY(${target} SHARED ${SRCS}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir}) \ No newline at end of file diff --git a/src/my-place/visit-categer/VisitCateger.cpp b/src/my-place/visit-categer/VisitCateger.cpp index 613dc70..1274bbc 100644 --- a/src/my-place/visit-categer/VisitCateger.cpp +++ b/src/my-place/visit-categer/VisitCateger.cpp @@ -416,3 +416,9 @@ void ctx::VisitCateger::categorize(ctx::Visit &visit) visit.categs[categId] = probability; } } + +extern "C" SO_EXPORT void categorize(ctx::Visit &visit) +{ + _D(""); + ctx::VisitCateger::categorize(visit); +} diff --git a/src/my-place/visit-detector/VisitDetector.cpp b/src/my-place/visit-detector/VisitDetector.cpp index c991e75..1e4823e 100644 --- a/src/my-place/visit-detector/VisitDetector.cpp +++ b/src/my-place/visit-detector/VisitDetector.cpp @@ -23,10 +23,14 @@ #include "../facade/UserPlacesTypes.h" #include "VisitDetector.h" #include "../facade/UserPlacesParams.h" -#include "../visit-categer/VisitCateger.h" #include "../utils/Similarity.h" #include "../utils/Median.h" #include "../utils/DebugUtils.h" +#include + +#define SO_PATH "/usr/lib/context-service/libctx-prvd-my-place-visit-categer.so" + +typedef void (*visit_categer_t)(ctx::Visit &visit); #ifdef TIZEN_ENGINEER_MODE #define __VISIT_TABLE_COLUMNS \ @@ -224,7 +228,7 @@ void ctx::VisitDetector::__visitEndDetected() Interval interval(__entranceTime, __departureTime); Visit visit(interval, __representativesMacs); - VisitCateger::categorize(visit); + __categorize(visit); __putLocationToVisit(visit); @@ -486,5 +490,21 @@ void ctx::VisitDetector::setMode(PlaceRecogMode energyMode) __wifiLogger->setMode(energyMode); } +void ctx::VisitDetector::__categorize(ctx::Visit &visit) +{ + _D("mmastern try to categorize from visit detector"); + GModule *soHandle = g_module_open(SO_PATH, G_MODULE_BIND_LAZY); + IF_FAIL_VOID_TAG(soHandle, _E, "%s", g_module_error()); + + gpointer symbol; + if (!g_module_symbol(soHandle, "categorize", &symbol) || symbol == NULL) { + _E("mmastern %s", g_module_error()); + g_module_close(soHandle); + return; + } + visit_categer_t categorize = reinterpret_cast(symbol); + categorize(visit); + g_module_close(soHandle); +} diff --git a/src/my-place/visit-detector/VisitDetector.h b/src/my-place/visit-detector/VisitDetector.h index 31e4812..a35ebc5 100644 --- a/src/my-place/visit-detector/VisitDetector.h +++ b/src/my-place/visit-detector/VisitDetector.h @@ -92,6 +92,8 @@ namespace ctx { void onWifiScan(MacEvent event); void onNewLocation(LocationEvent location); + void __categorize(Visit &visit); + public: VisitDetector(time_t startScan, PlaceRecogMode energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE, bool testMode = false); ~VisitDetector();