• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
16 #ifndef ECMASCRIPT_TOOLING_CLIENT_MANAGER_DOMAIN_MANAGER_H
17 #define ECMASCRIPT_TOOLING_CLIENT_MANAGER_DOMAIN_MANAGER_H
18 
19 #include <iostream>
20 
21 #include "tooling/client/domain/debugger_client.h"
22 #include "tooling/client/domain/heapprofiler_client.h"
23 #include "tooling/client/domain/profiler_client.h"
24 #include "tooling/client/domain/runtime_client.h"
25 #include "tooling/client/domain/test_client.h"
26 
27 namespace OHOS::ArkCompiler::Toolchain {
28 class DomainManager {
29 public:
30     explicit DomainManager(uint32_t sessionId);
31     ~DomainManager() = default;
32 
33     void DispatcherReply(char* msg);
34 
GetDomainById(uint32_t id)35     std::string GetDomainById(uint32_t id)
36     {
37         auto iter = idDomainMap_.find(id);
38         if (iter == idDomainMap_.end()) {
39             return "";
40         }
41         return iter->second;
42     }
43 
SetDomainById(uint32_t id,std::string domain)44     void SetDomainById(uint32_t id, std::string domain)
45     {
46         idDomainMap_.emplace(id, domain);
47     }
48 
RemoveDomainById(uint32_t id)49     void RemoveDomainById(uint32_t id)
50     {
51         auto it = idDomainMap_.find(id);
52         if (it != idDomainMap_.end()) {
53             idDomainMap_.erase(it);
54         }
55     }
56 
GetHeapProfilerClient()57     HeapProfilerClient &GetHeapProfilerClient()
58     {
59         return heapProfilerClient_;
60     }
61 
GetProfilerClient()62     ProfilerClient &GetProfilerClient()
63     {
64         return profilerClient_;
65     }
66 
GetDebuggerClient()67     DebuggerClient &GetDebuggerClient()
68     {
69         return debuggerClient_;
70     }
71 
GetRuntimeClient()72     RuntimeClient &GetRuntimeClient()
73     {
74         return runtimeClient_;
75     }
76 
GetTestClient()77     TestClient &GetTestClient()
78     {
79         return testClient_;
80     }
81 
82 private:
83     [[maybe_unused]] uint32_t sessionId_;
84     HeapProfilerClient heapProfilerClient_;
85     ProfilerClient profilerClient_;
86     DebuggerClient debuggerClient_;
87     RuntimeClient runtimeClient_;
88     TestClient testClient_;
89     std::map<uint32_t, std::string> idDomainMap_ {};
90 };
91 } // OHOS::ArkCompiler::Toolchain
92 #endif