1 // Copyright 2015 The Weave Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LIBWEAVE_SRC_BASE_API_HANDLER_H_ 6 #define LIBWEAVE_SRC_BASE_API_HANDLER_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include <base/memory/weak_ptr.h> 12 13 namespace weave { 14 15 class Command; 16 class Device; 17 class DeviceRegistrationInfo; 18 struct Settings; 19 20 // Handles commands from 'base' package. 21 // Objects of the class subscribe for notification from CommandManager and 22 // execute incoming commands. 23 // Handled commands: 24 // base.updateDeviceInfo 25 // base.updateBaseConfiguration 26 class BaseApiHandler final { 27 public: 28 BaseApiHandler(DeviceRegistrationInfo* device_info, Device* device); 29 30 private: 31 void UpdateBaseConfiguration(const std::weak_ptr<Command>& command); 32 void UpdateDeviceInfo(const std::weak_ptr<Command>& command); 33 void OnConfigChanged(const Settings& settings); 34 35 DeviceRegistrationInfo* device_info_; 36 Device* device_{nullptr}; 37 38 base::WeakPtrFactory<BaseApiHandler> weak_ptr_factory_{this}; 39 DISALLOW_COPY_AND_ASSIGN(BaseApiHandler); 40 }; 41 42 } // namespace weave 43 44 #endif // LIBWEAVE_SRC_BASE_API_HANDLER_H_ 45