#include "common/appcontrol_manager.h"
#include "common/capability.h"
#include "common/capability_manager.h"
+#include "common/remote_device_manager.h"
#include "common/utils/glist_range.h"
#include "common/utils/logging.h"
mdgmgr->capmgr_->UnpackCapabilities(caps_str);
LOG(INFO) << "Received " << caps.size() << " capabilities from device "
<< device_id;
+ RemoteDeviceManager::RegisterRemoteDevice(device_id, caps);
} else if (cmd == Command::SEND_CAP) {
std::string cap_str = std::string(reinterpret_cast<char*>(p));
Capability cap(cap_str);
class RemoteDevice {
public:
- explicit RemoteDevice(const std::string& name, const std::string& profile_,
- const std::string& address, const std::string& uuid_)
+ explicit RemoteDevice(const std::string& name, const std::string& profile,
+ const std::string& address, const std::string& uuid)
: name_(std::move(name)), profile_(std::move(profile)),
address_(std::move(address)), uuid_(std::move(uuid)) {}
--- /dev/null
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/remote_device_manager.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "common/capability.h"
+#include "common/remote_device.h"
+#include "common/utils/logging.h"
+
+namespace capmgr {
+
+void RemoteDeviceManager::RegisterRemoteDevice(const std::string& device,
+ const std::vector<Capability>& capabilities) {
+ auto it = Instance().remote_device_info_.emplace(device, capabilities);
+ if (!it.second) {
+ auto p = it.first;
+ // replace capabilities (update)
+ p->second = capabilities;
+ }
+}
+
+RemoteDeviceManager& RemoteDeviceManager::Instance() {
+ static RemoteDeviceManager instance;
+ return instance;
+}
+
+} // namespace capmgr
#ifndef COMMON_REMOTE_DEVICE_MANAGER_H_
#define COMMON_REMOTE_DEVICE_MANAGER_H_
+#include <map>
#include <string>
+#include <vector>
+
+#include "common/capability.h"
+#include "common/remote_device.h"
namespace capmgr {
class RemoteDeviceManager {
public:
+ static void RegisterRemoteDevice(const std::string& device_id,
+ const std::vector<Capability>& capabilities);
+
+ static RemoteDeviceManager& Instance();
+
private:
+ RemoteDeviceManager() {}
+ ~RemoteDeviceManager() {}
+
+ std::map<std::string, std::vector<Capability>> remote_device_info_;
};
} // namespace capmgr