1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef INTERNALAPI_H_
22 #define INTERNALAPI_H_
24 // ============================================================================
26 // ============================================================================
32 #include "Description.hpp"
33 #include "Characteristic.hpp"
34 #include "Protocol.hpp"
37 // ============================================================================
39 // ============================================================================
45 // ============================================================================
47 // ============================================================================
50 // ============================================================================
52 // ============================================================================
53 class DeviceIdsGetResult {
54 // ============================================================
56 // ============================================================
58 virtual ~DeviceIdsGetResult() {}
60 // ============================================================
62 // ============================================================
64 virtual QueryResultType getResult() const = 0;
65 virtual const std::set<UUID_t>& getDeviceIds() const = 0;
68 typedef std::function<void (const DeviceIdsGetResult&)> DeviceIdsGetFunction;
70 // ============================================================================
72 // ============================================================================
73 class DeviceGetInfoResult {
74 // ============================================================
76 // ============================================================
78 virtual ~DeviceGetInfoResult() {}
80 // ============================================================
82 // ============================================================
84 virtual QueryResultType getResult() const = 0;
85 virtual const std::string& getName() const = 0;
86 virtual const Description::SharedPtr& getDescription() const = 0;
87 virtual bool isLocal() = 0;
90 typedef std::function<void (const DeviceGetInfoResult&)> DeviceGetInfoFunction;
93 // ============================================================================
95 // ============================================================================
96 class GetDevicesResult {
97 // ============================================================
99 // ============================================================
101 virtual ~GetDevicesResult() {}
103 // ============================================================
105 // ============================================================
107 virtual QueryResultType getResult() const = 0;
108 virtual const std::list<Device::SharedPtr>& getDeviceList() const = 0;
111 typedef std::function<void (const GetDevicesResult&)> GetDevicesFunction;
114 // ============================================================================
116 // ============================================================================
117 typedef uint32_t DeviceObserverHandle;
118 const DeviceObserverHandle INVALID_DEVICE_OBSERVER_HANDLE = (DeviceObserverHandle)0;
123 DEVICE_CURRENT_COLLECTION,
128 struct DeviceEventInfo {
130 DeviceChange deviceChange;
132 // ============================================================
134 // ============================================================
136 virtual ~DeviceEvent() {}
138 // ============================================================
140 // ============================================================
142 virtual QueryResultType getResult() const = 0;
143 virtual DeviceObserverHandle getObserverHandle() const = 0;
144 virtual const std::list<DeviceEventInfo>& getDeviceIdList() const = 0;
147 typedef std::function<void (const DeviceEvent&)> DeviceEventFunction;
150 // ============================================================================
152 // ============================================================================
153 class Model : public std::enable_shared_from_this<Model> {
154 // ============================================================
155 // Type Definition(s)
156 // ============================================================
158 typedef std::shared_ptr<Model> SharedPtr;
159 typedef std::weak_ptr<Model> WeakPtr;
161 // ============================================================
163 // ============================================================
165 static SharedPtr createModel();
167 // ============================================================
169 // ============================================================
173 // ============================================================
175 // ============================================================
177 virtual void getDevices(GetDevicesFunction& asyncReturnFunc) = 0;
179 // Add/remove device observer
180 virtual void removeDeviceObserver(DeviceObserverHandle observerHandle) = 0;
181 virtual void setDeviceObserver(DeviceEventFunction& asyncEventFunction) = 0;
183 // Register/unregister a protocol
184 virtual const Protocols::Protocol::Handle registerProtocol(const Protocols::Protocol::SharedPtr& protocol) = 0;
185 virtual bool unregisterProtocol(const Protocols::Protocol::Handle protocolHandle) = 0;
186 virtual Device::SharedPtr getDevice(const UUID_t& deviceId) = 0;
187 virtual void signalDeviceChange(const UUID_t& deviceId, DeviceEvent::DeviceChange deviceEvent) = 0;
196 #endif /* INTERNALAPI_H_ */