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>
34 namespace SecurityDaemon {
36 class DaemonService : DPL::Noncopyable {
38 virtual void initialize() = 0;
39 virtual void start() = 0;
40 virtual void stop() = 0;
41 virtual void deinitialize() = 0;
44 class SecurityDaemon : DPL::Noncopyable
49 void initialize(int& argc, char** argv);
51 void terminate(int returnValue = 0);
53 template<typename ServiceType, typename ...Args>
54 void registerService(Args&&... args)
56 Assert(!m_initialized && "Too late for registration");
58 m_servicesList.push_back(
59 std::make_shared<ServiceType>(std::forward<Args>(args)...));
68 typedef std::list<std::shared_ptr<DaemonService>> DaemonServiceList;
69 DaemonServiceList m_servicesList;
72 namespace DatabaseService {
77 } //namespace SecurityDaemon
79 typedef DPL::Singleton<SecurityDaemon::SecurityDaemon> SecurityDaemonSingleton;
81 #define DAEMON_REGISTER_SERVICE_MODULE(Type) \
83 static int initializeModule(); \
84 static int initializeModuleHelper = initializeModule(); \
85 int initializeModule() \
87 (void)initializeModuleHelper; \
88 SecurityDaemonSingleton::Instance().registerService<Type>(); \
94 #endif /* WRT_SRC_SECURITY_DAEMON_SECURITY_DAEMON_H */