2 * Copyright (c) 2014, Ford Motor Company
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
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
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.
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.
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_
36 #include "transport_manager/transport_adapter/device.h"
37 #include "transport_manager/transport_adapter/connection.h"
39 namespace transport_manager {
41 namespace transport_adapter {
44 class TransportAdapterController {
47 virtual ~TransportAdapterController() {
51 * @brief Add device to the container(map), if container doesn't hold it yet.
53 * @param device Smart pointer to the device.
55 * @return Smart pointer to the device.
57 virtual DeviceSptr AddDevice(DeviceSptr device) = 0;
60 * @brief Search for device in container of devices, if it is not there - adds it.
62 * @param devices Container(vector) of smart pointers to devices.
64 virtual void SearchDeviceDone(const DeviceVector& devices) = 0;
67 * @brief Launch OnSearchDeviceFailed event in device adapter listener.
69 * @param error Error class that contains details of this error situation.
71 virtual void SearchDeviceFailed(const SearchDeviceError& error) = 0;
74 * @brief Find device in the internal container(map).
76 * @param device_handle Device unique identifier.
78 * @return Smart pointer to the device.
80 virtual DeviceSptr FindDevice(const DeviceUID& device_handle) const = 0;
83 * @brief Create connection and fill its parameters.
85 * @param connection Smart pointer to the connection.
86 * @param device_handle Device unique identifier.
87 * @param app_handle Handle of application.
89 virtual void ConnectionCreated(ConnectionSptr connection,
90 const DeviceUID& device_handle,
91 const ApplicationHandle& app_handle) = 0;
94 * @brief Make state of specified connection - ESTABLISHED and launch OnConnectDone event in device adapter listener.
96 * @param devcie_handle Device unique identifier.
97 * @param app_handle Handle of application.
99 virtual void ConnectDone(const DeviceUID& device_handle,
100 const ApplicationHandle& app_handle) = 0;
103 * @brief Delete connection from the container of connections and launch OnConnectFailed event in the device adapter listener.
105 * @param device_handle Device unique identifier.
106 * @param app_handle Handle of application.
108 virtual void ConnectFailed(const DeviceUID& device_handle,
109 const ApplicationHandle& app_handle,
110 const ConnectError& error) = 0;
113 * @brief Make state of specified connection - FINILIZING.
115 * @param device_handle Device unique identifier.
116 * @param app_handle Handle of application.
118 virtual void ConnectionFinished(const DeviceUID& device_handle,
119 const ApplicationHandle& app_handle) = 0;
122 * @brief Set specified connection state to FINALISING and launch OnUnexpectedDisconnect event in the device adapter listener.
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.
128 virtual void ConnectionAborted(const DeviceUID& device_handle,
129 const ApplicationHandle& app_handle,
130 const CommunicationError& error) = 0;
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.
137 virtual void DeviceDisconnected(const DeviceUID& device_handle,
138 const DisconnectDeviceError& error) = 0;
141 * @brief Delete specified connection from the container(map) of connections and launch event in the device adapter listener.
143 * @param device_handle Device unique identifier.
144 * @param app_handle Handle of application.
146 virtual void DisconnectDone(const DeviceUID& device_handle,
147 const ApplicationHandle& app_handle) = 0;
150 * @brief Launch OnDataReceiveDone event in the device adapter listener.
152 * @param device_handle Device unique identifier.
153 * @param app_handle Handle of application.
154 * @param message Smart pointer to the raw message.
156 virtual void DataReceiveDone(const DeviceUID& device_handle,
157 const ApplicationHandle& app_handle,
158 RawMessageSptr message) = 0;
161 * @brief Launch OnDataReceiveFailed event in the device adapter listener.
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.
167 virtual void DataReceiveFailed(const DeviceUID& device_handle,
168 const ApplicationHandle& app_handle,
169 const DataReceiveError&) = 0;
172 * @brief Launch OnDataSendDone event in the device adapter listener.
174 * @param device_handle Device unique identifier.
175 * @param app_handle Handle of application.
176 * @param message Smart pointer to raw message.
178 virtual void DataSendDone(const DeviceUID& device_handle,
179 const ApplicationHandle& app_handle,
180 RawMessageSptr message) = 0;
183 * @brief Launch OnDataSendFailed event in the device adapter listener.
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.
190 virtual void DataSendFailed(const DeviceUID& device_handle,
191 const ApplicationHandle& app_handle,
192 RawMessageSptr message, const DataSendError&) = 0;
195 } // namespace transport_adapter
196 } // namespace transport_manager
198 #endif /* transport_adapter_CONTROLLER_H_ */