• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HIVIEW_UTILITY_PLATFORM_GLOBAL_H
16 #define HIVIEW_UTILITY_PLATFORM_GLOBAL_H
17 
18 #include <list>
19 #include <memory>
20 #include <set>
21 
22 #include "plugin.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 class DllExport HiviewGlobal {
27 public:
HiviewGlobal(HiviewContext & context)28     explicit HiviewGlobal(HiviewContext& context) : context_(context) {}
~HiviewGlobal()29     ~HiviewGlobal() {};
30     static void CreateInstance(HiviewContext& context);
31     static void ReleaseInstance();
32     // maybe null reference, check before use
33     static std::unique_ptr<HiviewGlobal>& GetInstance();
34     std::string GetHiViewDirectory(HiviewContext::DirectoryType type) const;
35     std::string GetHiviewProperty(const std::string& key, const std::string& defaultValue);
36     bool SetHiviewProperty(const std::string& key, const std::string& value, bool forceUpdate);
37     void PostAsyncEventToTarget(const std::string& targetPlugin, std::shared_ptr<Event> event);
38     bool PostSyncEventToTarget(const std::string& targetPlugin, std::shared_ptr<Event> event);
39     void PostUnorderedEvent(std::shared_ptr<Event> event);
40     void AddListenerInfo(uint32_t type, const std::string& name,
41     const std::set<std::string>& eventNames, const std::set<EventListener::EventIdRange>& listenerInfo);
42     bool GetListenerInfo(uint32_t type, const std::string& name, std::set<EventListener::EventIdRange> &listenerInfo);
43     bool GetListenerInfo(uint32_t type, const std::string& name, std::set<std::string> &eventNames);
44     std::list<std::weak_ptr<Plugin>> GetPipelineSequenceByName(const std::string& name);
45 private:
46     HiviewContext& context_;
47 };
48 } // namespace HiviewDFX
49 } // namespace OHOS
50 #endif // HIVIEW_UTILITY_PLATFORM_GLOBAL_H