Convert the ServiceLoader class to static 49/113949/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 9 Feb 2017 10:29:18 +0000 (19:29 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 9 Feb 2017 10:29:18 +0000 (19:29 +0900)
Change-Id: I98c7546f1158acf9fc9c9b5f61bb14f47710cdd3
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/Main.cpp
src/ServiceLoader.cpp
src/ServiceLoader.h

index 10b5451..dcb7477 100644 (file)
@@ -67,14 +67,13 @@ void ::Server::stop()
 }
 
 static ::Server __server;
-static ServiceLoader __loader;
 static AlarmInitializer __alarmInit;
 
 static void __signalHandler(int signum)
 {
        _I(YELLOW("SIGNAL-%d: '%s'"), signum, strsignal(signum));
        _I("Unloading services");
-       __loader.unload();
+       ServiceLoader::unload();
        __server.stop();
 }
 
@@ -83,7 +82,7 @@ static void __busAcquired(GDBusConnection* conn)
        Timer::setDBusConnection(conn);
 
        _I("Loading services");
-       if (__loader.load(conn)) {
+       if (ServiceLoader::load(conn)) {
                _I("Service loading successful");
                return;
        }
@@ -95,7 +94,7 @@ static void __busAcquired(GDBusConnection* conn)
 static void __busLost(GDBusConnection* conn)
 {
        _I("Unloading services");
-       __loader.unload();
+       ServiceLoader::unload();
        __server.stop();
 }
 
index d461a5d..6cd65d1 100644 (file)
 
 using namespace ctx;
 
-ServiceLoader::ServiceLoader()
-{
-}
-
-ServiceLoader::~ServiceLoader()
-{
-       unload();
-}
+std::vector<DBusService*> ServiceLoader::__services;
 
 bool ServiceLoader::load(GDBusConnection* conn)
 {
index 4a8e59b..b230fa7 100644 (file)
@@ -25,16 +25,13 @@ namespace ctx {
 
        class ServiceLoader {
        public:
-               ServiceLoader();
-               ~ServiceLoader();
-
-               bool load(GDBusConnection* conn);
-               void unload();
+               static bool load(GDBusConnection* conn);
+               static void unload();
 
        private:
-               std::vector<DBusService*> __services;
+               static std::vector<DBusService*> __services;
 
-               template<typename ServiceType> void __load(GDBusConnection* conn)
+               template<typename ServiceType> static void __load(GDBusConnection* conn)
                {
                        DBusService *svc = NULL;
                        try {