2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file security_daemon.h
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
20 * @brief This is header file of Security Daemon
23 #ifndef WRT_SRC_SECURITY_DAEMON_SECURITY_DAEMON_H
24 #define WRT_SRC_SECURITY_DAEMON_SECURITY_DAEMON_H
29 #include <dpl/noncopyable.h>
30 #include <dpl/singleton.h>
31 #include <dpl/assert.h>
33 namespace SecurityDaemon {
35 class DaemonService : DPL::Noncopyable {
37 virtual void initialize() = 0;
38 virtual void start() = 0;
39 virtual void stop() = 0;
40 virtual void deinitialize() = 0;
43 class SecurityDaemon : DPL::Noncopyable
48 void initialize(int& argc, char** argv);
50 void terminate(int returnValue = 0);
52 template<typename ServiceType, typename ...Args>
53 void registerService(Args&&... args)
55 Assert(!m_initialized && "Too late for registration");
57 m_servicesList.push_back(
58 std::make_shared<ServiceType>(std::forward<Args>(args)...));
67 typedef std::list<std::shared_ptr<DaemonService>> DaemonServiceList;
68 DaemonServiceList m_servicesList;
71 namespace DatabaseService {
76 } //namespace SecurityDaemon
78 typedef DPL::Singleton<SecurityDaemon::SecurityDaemon> SecurityDaemonSingleton;
80 #define DAEMON_REGISTER_SERVICE_MODULE(Type) \
82 static int initializeModule(); \
83 static int initializeModuleHelper = initializeModule(); \
84 int initializeModule() \
86 (void)initializeModuleHelper; \
87 SecurityDaemonSingleton::Instance().registerService<Type>(); \
93 #endif /* WRT_SRC_SECURITY_DAEMON_SECURITY_DAEMON_H */