• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 "defines.h"
23 #include "plugin.h"
24 
25 namespace OHOS {
26 namespace HiviewDFX {
27 class DllExport HiviewGlobal {
28 public:
HiviewGlobal(HiviewContext & context)29     explicit HiviewGlobal(HiviewContext& context) : context_(context) {}
~HiviewGlobal()30     ~HiviewGlobal() {};
31     static void CreateInstance(HiviewContext& context);
32     static void ReleaseInstance();
33     // maybe null reference, check before use
34     static std::unique_ptr<HiviewGlobal>& GetInstance();
35     std::string GetHiViewDirectory(HiviewContext::DirectoryType type) const;
36     std::string GetHiviewProperty(const std::string& key, const std::string& defaultValue);
37     bool SetHiviewProperty(const std::string& key, const std::string& value, bool forceUpdate);
38     void PostAsyncEventToTarget(const std::string& targetPlugin, std::shared_ptr<Event> event);
39     bool PostSyncEventToTarget(const std::string& targetPlugin, std::shared_ptr<Event> event);
40     void PostUnorderedEvent(std::shared_ptr<Event> event);
41     void AddListenerInfo(uint32_t type, const std::string& name, const std::set<std::string>& eventNames,
42         const std::map<std::string, DomainRule>& domainRulesMap);
43     void AddListenerInfo(uint32_t type, const std::string& name);
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