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 PANDA_GUARD_CONFIGS_GUARD_CONTEXT_H 17 #define PANDA_GUARD_CONFIGS_GUARD_CONTEXT_H 18 19 #include <memory> 20 21 #include "generator/name_mapping.h" 22 #include "guard_graph_context.h" 23 #include "guard_name_cache.h" 24 #include "guard_options.h" 25 26 namespace panda::guard { 27 28 class GuardContext { 29 public: 30 static std::shared_ptr<GuardContext> GetInstance(); 31 32 void Init(int argc, const char **argv); 33 34 void Finalize(); 35 36 [[nodiscard]] const std::shared_ptr<GuardOptions> &GetGuardOptions() const; 37 38 [[nodiscard]] const std::shared_ptr<NameCache> &GetNameCache() const; 39 40 [[nodiscard]] const std::shared_ptr<NameMapping> &GetNameMapping() const; 41 42 void CreateGraphContext(const panda_file::File &file); 43 44 [[nodiscard]] const std::shared_ptr<GraphContext> &GetGraphContext() const; 45 46 [[nodiscard]] bool IsDebugMode() const; 47 48 private: 49 std::shared_ptr<GuardOptions> options_; 50 51 std::shared_ptr<NameCache> nameCache_; 52 53 std::shared_ptr<NameMapping> nameMapping_; 54 55 std::shared_ptr<GraphContext> graphContext_; 56 57 bool debugMode_ = false; 58 }; 59 60 } // namespace panda::guard 61 62 #endif // PANDA_GUARD_CONFIGS_GUARD_CONTEXT_H 63