1 /* 2 * Copyright (c) 2021 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 #ifndef PROFILER_CAPABILITY_MANAGER_H 16 #define PROFILER_CAPABILITY_MANAGER_H 17 18 #include <memory> 19 #include <mutex> 20 #include <string> 21 #include <vector> 22 23 #include "nocopyable.h" 24 #include "profiler_service_types.pb.h" 25 26 class ProfilerCapabilityManager { 27 public: 28 static ProfilerCapabilityManager& GetInstance(); 29 30 bool AddCapability(const ProfilerPluginCapability& capability); 31 32 std::vector<ProfilerPluginCapability> GetCapabilities() const; 33 34 const ProfilerPluginCapability* GetCapability(const std::string& name) const; 35 36 bool UpdateCapability(const std::string& name, const ProfilerPluginCapability& capability); 37 38 bool RemoveCapability(const std::string& name); 39 40 private: 41 ProfilerCapabilityManager() = default; 42 ~ProfilerCapabilityManager(); 43 44 private: 45 mutable std::mutex mutex_; 46 std::vector<ProfilerPluginCapability> pluginCapabilities_; 47 48 DISALLOW_COPY_AND_MOVE(ProfilerCapabilityManager); 49 }; 50 51 #endif 52