20e9123043bc6ccb064d12e5237143ec1448cb72
[profile/ivi/smartdevicelink.git] / src / components / transport_manager / include / transport_manager / transport_adapter / transport_adapter_controller.h
1 /*
2  * Copyright (c) 2014, Ford Motor Company
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of the Ford Motor Company nor the names of its contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_CONTROLLER_H_
34 #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_CONTROLLER_H_
35
36 #include "transport_manager/transport_adapter/device.h"
37 #include "transport_manager/transport_adapter/connection.h"
38
39 namespace transport_manager {
40
41 namespace transport_adapter {
42
43
44 class TransportAdapterController {
45  public:
46
47   virtual ~TransportAdapterController() {
48   }
49
50   /**
51    * @brief Add device to the container(map), if container doesn't hold it yet.
52    *
53    * @param device Smart pointer to the device.
54    *
55    * @return Smart pointer to the device.
56    */
57   virtual DeviceSptr AddDevice(DeviceSptr device) = 0;
58
59   /**
60    * @brief Search for device in container of devices, if it is not there - adds it.
61    *
62    * @param devices Container(vector) of smart pointers to devices.
63    */
64   virtual void SearchDeviceDone(const DeviceVector& devices) = 0;
65
66   /**
67    * @brief Launch OnSearchDeviceFailed event in device adapter listener.
68    *
69    * @param error Error class that contains details of this error situation.
70    */
71   virtual void SearchDeviceFailed(const SearchDeviceError& error) = 0;
72
73   /**
74    * @brief Find device in the internal container(map).
75    *
76    * @param device_handle Device unique identifier.
77    *
78    * @return Smart pointer to the device.
79    */
80   virtual DeviceSptr FindDevice(const DeviceUID& device_handle) const = 0;
81
82   /**
83    * @brief Create connection and fill its parameters.
84    *
85    * @param connection  Smart pointer to the connection.
86    * @param device_handle Device unique identifier.
87    * @param app_handle Handle of application.
88    */
89   virtual void ConnectionCreated(ConnectionSptr connection,
90                                  const DeviceUID& device_handle,
91                                  const ApplicationHandle& app_handle) = 0;
92
93   /**
94    * @brief Make state of specified connection - ESTABLISHED and launch OnConnectDone event in device adapter listener.
95    *
96    * @param devcie_handle Device unique identifier.
97    * @param app_handle Handle of application.
98    */
99   virtual void ConnectDone(const DeviceUID& device_handle,
100                            const ApplicationHandle& app_handle) = 0;
101
102   /**
103    * @brief Delete connection from the container of connections and launch OnConnectFailed event in the device adapter listener.
104    *
105    * @param device_handle Device unique identifier.
106    * @param app_handle Handle of application.
107    */
108   virtual void ConnectFailed(const DeviceUID& device_handle,
109                              const ApplicationHandle& app_handle,
110                              const ConnectError& error) = 0;
111
112   /**
113    * @brief Make state of specified connection - FINILIZING.
114    *
115    * @param device_handle Device unique identifier.
116    * @param app_handle Handle of application.
117    */
118   virtual void ConnectionFinished(const DeviceUID& device_handle,
119                                   const ApplicationHandle& app_handle) = 0;
120
121   /**
122    * @brief Set specified connection state to FINALISING and launch OnUnexpectedDisconnect event in the device adapter listener.
123    *
124    * @param device_handle Device unique identifier.
125    * @param app_handle Handle of application.
126    * @param error Error class that contains details of this error situation.
127    */
128   virtual void ConnectionAborted(const DeviceUID& device_handle,
129                                  const ApplicationHandle& app_handle,
130                                  const CommunicationError& error) = 0;
131
132   /**
133    * @brief Remove specified device and all its connections
134    * @param device_handle Device unique identifier.
135    * @param error Error class that contains details of this error situation.
136    */
137   virtual void DeviceDisconnected(const DeviceUID& device_handle,
138                                   const DisconnectDeviceError& error) = 0;
139
140   /**
141    * @brief Delete specified connection from the container(map) of connections and launch event in the device adapter listener.
142    *
143    * @param device_handle Device unique identifier.
144    * @param app_handle Handle of application.
145    */
146   virtual void DisconnectDone(const DeviceUID& device_handle,
147                               const ApplicationHandle& app_handle) = 0;
148
149    /**
150    * @brief Launch OnDataReceiveDone event in the device adapter listener.
151    *
152    * @param device_handle Device unique identifier.
153    * @param app_handle Handle of application.
154    * @param message Smart pointer to the raw message.
155    */
156   virtual void DataReceiveDone(const DeviceUID& device_handle,
157                                const ApplicationHandle& app_handle,
158                                RawMessageSptr message) = 0;
159
160   /**
161    * @brief Launch OnDataReceiveFailed event in the device adapter listener.
162    *
163    * @param device_handle Device unique identifier.
164    * @param app_handle Handle of application.
165    * @param error Class that contains details of this error situation.
166    */
167   virtual void DataReceiveFailed(const DeviceUID& device_handle,
168                                  const ApplicationHandle& app_handle,
169                                  const DataReceiveError&) = 0;
170
171   /**
172    * @brief Launch OnDataSendDone event in the device adapter listener.
173    *
174    * @param device_handle Device unique identifier.
175    * @param app_handle Handle of application.
176    * @param message Smart pointer to raw message.
177    */
178   virtual void DataSendDone(const DeviceUID& device_handle,
179                             const ApplicationHandle& app_handle,
180                             RawMessageSptr message) = 0;
181
182   /**
183    * @brief Launch OnDataSendFailed event in the device adapter listener.
184    *
185    * @param device_handle Device unique identifier.
186    * @param app_handle Handle of application.
187    * @param message Smart pointer to raw message.
188    * @param error Class that contains details of this error situation.
189    */
190   virtual void DataSendFailed(const DeviceUID& device_handle,
191                               const ApplicationHandle& app_handle,
192                               RawMessageSptr message, const DataSendError&) = 0;
193 };
194
195 }  // namespace transport_adapter
196 }  // namespace transport_manager
197
198 #endif /* transport_adapter_CONTROLLER_H_ */