ENABLE_LOG option added to turn logger completely off
[profile/ivi/smartdevicelink.git] / src / appMain / life_cycle.h
1 /**
2 * \file signals.cc
3 * \brief Signal (i.e. SIGINT) handling.
4 * Copyright (c) 2013, Ford Motor Company
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of the Ford Motor Company nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef SRC_APPMAIN_LIFE_CYCLE_H_
36 #define SRC_APPMAIN_LIFE_CYCLE_H_
37
38 #include "hmi_message_handler/hmi_message_handler_impl.h"
39 #ifdef QT_HMI
40 #  include "hmi_message_handler/dbus_message_adapter.h"
41 #endif  // QT_HMI
42 #ifdef WEB_HMI
43 #  include "hmi_message_handler/messagebroker_adapter.h"
44 #endif  // WEB_HMI
45 #include "application_manager/application_manager_impl.h"
46 #include "connection_handler/connection_handler_impl.h"
47 #include "protocol_handler/protocol_handler_impl.h"
48 #include "transport_manager/transport_manager.h"
49 #include "transport_manager/transport_manager_default.h"
50 #include "media_manager/media_manager_impl.h"
51 #include "policies/policy_manager_impl.h"
52 #include "utils/singleton.h"
53
54 #ifdef WEB_HMI
55 #  include "CMessageBroker.hpp"
56 #  include "mb_tcpserver.hpp"
57 #  include "networking.h"  // cpplint: Include the directory when naming .h files
58 #endif  // WEB_HMI
59 #include "system.h"      // cpplint: Include the directory when naming .h files
60
61 namespace main_namespace {
62 class LifeCycle : public utils::Singleton<LifeCycle> {
63   public:
64     bool StartComponents();
65
66     /**
67     * Initialize MessageBroker component
68     * @return true if success otherwise false.
69     */
70     bool InitMessageSystem();
71     void StopComponents();
72     static void StopComponentsOnSignal(int32_t params);
73
74   private:
75     LifeCycle();
76     transport_manager::TransportManager* transport_manager_;
77     protocol_handler::ProtocolHandlerImpl* protocol_handler_;
78     connection_handler::ConnectionHandlerImpl* connection_handler_;
79     application_manager::ApplicationManagerImpl* app_manager_;
80     hmi_message_handler::HMIMessageHandlerImpl* hmi_handler_;
81 #ifdef QT_HMI
82     hmi_message_handler::DBusMessageAdapter* dbus_adapter_;
83 #endif  // QT_HMI
84 #ifdef WEB_HMI
85     hmi_message_handler::MessageBrokerAdapter* mb_adapter_;
86 #endif  // WEB_HMI
87     media_manager::MediaManagerImpl* media_manager_;
88     policies::PolicyManagerImpl* policy_manager_;
89
90 #ifdef WEB_HMI
91     NsMessageBroker::CMessageBroker* message_broker_;
92     NsMessageBroker::TcpServer* message_broker_server_;
93     System::Thread* mb_thread_;
94     System::Thread* mb_server_thread_;
95     System::Thread* mb_adapter_thread_;
96 #endif  // WEB_HMI
97 #ifdef QT_HMI
98     System::Thread* dbus_adapter_thread_;
99 #endif  // QT_HMI
100
101 #   ifdef ENABLE_LOG
102     static log4cxx::LoggerPtr logger_;
103 #   endif // ENABLE_LOG
104
105     DISALLOW_COPY_AND_ASSIGN(LifeCycle);
106
107     FRIEND_BASE_SINGLETON_CLASS(LifeCycle);
108 };
109 }  //  namespace main_namespace
110
111 #endif  //  SRC_APPMAIN_LIFE_CYCLE_H_