1 /* 2 * Copyright (c) 2024 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 UDMF_GETTER_SYSTEM_H 17 #define UDMF_GETTER_SYSTEM_H 18 19 #include "concurrent_map.h" 20 #include "unified_meta.h" 21 #include "visibility.h" 22 23 namespace OHOS { 24 namespace UDMF { 25 class API_EXPORT GetterSystem { 26 public: 27 class API_EXPORT GeneralGetter { 28 public: 29 virtual ~GeneralGetter(); 30 virtual ValueType GetValueByType(uint32_t dataId, uint32_t recordId, const std::string &utdId); 31 }; 32 using Creator = std::function<std::shared_ptr<GeneralGetter>()>; 33 using Getter = std::shared_ptr<GeneralGetter>; 34 static GetterSystem &GetInstance(); 35 void RegisterCreator(const std::string& name, Creator creator); 36 Getter GetGetter(const std::string& name); 37 private: 38 GetterSystem() = default; 39 GetterSystem(const GetterSystem &) = delete; 40 GetterSystem(GetterSystem &&) noexcept = delete; 41 GetterSystem &operator=(const GetterSystem &) = delete; 42 GetterSystem &operator=(GetterSystem &&) = delete; 43 ConcurrentMap<std::string, Creator> creators_; 44 }; 45 } // namespace UDMF 46 } // namespace OHOS 47 #endif // UDMF_GETTER_SYSTEM_H