1 //******************************************************************
3 // Copyright 2015 Samsung Electronics 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 DISCOVERRESOURCEUNIT_H_
22 #define DISCOVERRESOURCEUNIT_H_
31 #include "RCSDiscoveryManager.h"
32 #include "RCSRemoteResourceObject.h"
33 #include "RCSResourceAttributes.h"
34 #include "RemoteResourceUnit.h"
40 class DiscoverResourceUnit
43 struct DiscoverResourceInfo
45 DiscoverResourceInfo()
46 : resourceUri(), resourceType(), attributeName() {}
47 DiscoverResourceInfo(std::string uri, std::string type, std::string name)
48 : resourceUri(uri), resourceType(type), attributeName(name) {}
49 std::string resourceUri;
50 std::string resourceType;
51 std::string attributeName;
54 typedef std::shared_ptr<DiscoverResourceUnit> Ptr;
55 typedef std::function<void(RemoteResourceUnit::UPDATE_MSG,
56 RCSRemoteResourceObject::Ptr)> UpdatedCBFromServer;
57 typedef std::function<void(const std::string attributeName,
58 std::vector<RCSResourceAttributes::Value> values)>
60 typedef RemoteResourceUnit::UPDATE_MSG REMOTE_MSG;
62 DiscoverResourceUnit(const std::string &bundleId);
63 DiscoverResourceUnit(const DiscoverResourceUnit &other)=delete;
64 DiscoverResourceUnit& operator=( const DiscoverResourceUnit& rhs )=delete;
65 ~DiscoverResourceUnit();
67 void startDiscover(DiscoverResourceInfo info, UpdatedCB updatedCB);
70 std::string m_bundleId;
72 std::string m_ResourceType;
73 std::string m_AttrubuteName;
74 std::atomic_bool isStartedDiscovery;
75 std::unique_ptr<RCSDiscoveryManager::DiscoveryTask> discoveryTask;
77 std::vector<RemoteResourceUnit::Ptr> m_vecRemoteResource;
78 RCSDiscoveryManager::ResourceDiscoveredCallback pDiscoveredCB;
79 UpdatedCBFromServer pUpdatedCBFromServer;
82 bool isAlreadyDiscoveredResource(RCSRemoteResourceObject::Ptr discoveredResource);
83 void discoverdCB(RCSRemoteResourceObject::Ptr remoteObject, std::string uri);
84 void onUpdate(REMOTE_MSG msg, RCSRemoteResourceObject::Ptr updatedResource);
86 std::vector<RCSResourceAttributes::Value>
87 buildInputResourceData(RCSRemoteResourceObject::Ptr updatedResource);
92 #endif // DISCOVERRESOURCEUNIT_H_