1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DISTRIBUTED_OBJECT_H 17 #define DISTRIBUTED_OBJECT_H 18 #include <map> 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS::ObjectStore { 24 enum Type : uint8_t { 25 TYPE_STRING = 0, 26 TYPE_BOOLEAN, 27 TYPE_DOUBLE, 28 TYPE_COMPLEX, 29 }; 30 class DistributedObject { 31 public: ~DistributedObject()32 virtual ~DistributedObject(){}; 33 virtual uint32_t PutDouble(const std::string &key, double value) = 0; 34 virtual uint32_t PutBoolean(const std::string &key, bool value) = 0; 35 virtual uint32_t PutString(const std::string &key, const std::string &value) = 0; 36 virtual uint32_t PutComplex(const std::string &key, const std::vector<uint8_t> &value) = 0; 37 virtual uint32_t GetDouble(const std::string &key, double &value) = 0; 38 virtual uint32_t GetBoolean(const std::string &key, bool &value) = 0; 39 virtual uint32_t GetString(const std::string &key, std::string &value) = 0; 40 virtual uint32_t GetComplex(const std::string &key, std::vector<uint8_t> &value) = 0; 41 virtual uint32_t GetType(const std::string &key, Type &type) = 0; 42 virtual std::string &GetSessionId() = 0; 43 }; 44 45 class ObjectWatcher { 46 public: 47 virtual void OnChanged(const std::string &sessionid, const std::vector<std::string> &changedData) = 0; 48 }; 49 } // namespace OHOS::ObjectStore 50 #endif // DISTRIBUTED_OBJECT_H 51