APPLINK-6593:
[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 "utils/singleton.h"
52
53 #ifdef WEB_HMI
54 #  include "CMessageBroker.hpp"
55 #  include "mb_tcpserver.hpp"
56 #  include "networking.h"  // cpplint: Include the directory when naming .h files
57 #endif  // WEB_HMI
58 #include "system.h"      // cpplint: Include the directory when naming .h files
59
60 namespace main_namespace {
61 class LifeCycle : public utils::Singleton<LifeCycle> {
62   public:
63     bool StartComponents();
64
65     /**
66     * Initialize MessageBroker component
67     * @return true if success otherwise false.
68     */
69     bool InitMessageSystem();
70     void StopComponents();
71     static void StopComponentsOnSignal(int32_t params);
72
73   private:
74     LifeCycle();
75     transport_manager::TransportManager* transport_manager_;
76     protocol_handler::ProtocolHandlerImpl* protocol_handler_;
77     connection_handler::ConnectionHandlerImpl* connection_handler_;
78     application_manager::ApplicationManagerImpl* app_manager_;
79     hmi_message_handler::HMIMessageHandlerImpl* hmi_handler_;
80 #ifdef QT_HMI
81     hmi_message_handler::DBusMessageAdapter* dbus_adapter_;
82 #endif  // QT_HMI
83 #ifdef WEB_HMI
84     hmi_message_handler::MessageBrokerAdapter* mb_adapter_;
85 #endif  // WEB_HMI
86     media_manager::MediaManagerImpl* media_manager_;
87
88 #ifdef WEB_HMI
89     NsMessageBroker::CMessageBroker* message_broker_;
90     NsMessageBroker::TcpServer* message_broker_server_;
91     System::Thread* mb_thread_;
92     System::Thread* mb_server_thread_;
93     System::Thread* mb_adapter_thread_;
94 #endif  // WEB_HMI
95 #ifdef QT_HMI
96     System::Thread* dbus_adapter_thread_;
97 #endif  // QT_HMI
98
99 #   ifdef ENABLE_LOG
100     static log4cxx::LoggerPtr logger_;
101 #   endif // ENABLE_LOG
102
103     DISALLOW_COPY_AND_ASSIGN(LifeCycle);
104
105     FRIEND_BASE_SINGLETON_CLASS(LifeCycle);
106 };
107 }  //  namespace main_namespace
108
109 #endif  //  SRC_APPMAIN_LIFE_CYCLE_H_