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_GENERATOR_NAME_MAPPING_H 17 #define PANDA_GUARD_GENERATOR_NAME_MAPPING_H 18 19 #include <memory> 20 21 #include "configs/guard_name_cache.h" 22 #include "configs/guard_options.h" 23 #include "name_generator.h" 24 25 namespace panda::guard { 26 27 class NameMapping { 28 public: 29 explicit NameMapping(const std::shared_ptr<NameCache> &nameCache, std::shared_ptr<GuardOptions> options = nullptr); 30 31 std::string GetName(const std::string &origin, bool generateNew = true); 32 33 std::string GetFileName(const std::string &origin, bool generateNew = true); 34 35 std::string GetFilePath(const std::string &origin, bool generateNew = true); 36 37 void AddReservedNames(const std::set<std::string> &nameList) const; 38 39 void AddNameMapping(const std::string &name); 40 41 void AddNameMapping(const std::string &origin, const std::string &name); 42 43 void AddNameMapping(const std::set<std::string> &nameList); 44 45 void AddFileNameMapping(const std::string &name); 46 47 void AddFileNameMapping(const std::set<std::string> &nameList); 48 49 private: 50 std::unique_ptr<NameGenerator> fileNameGenerator_; 51 52 std::unique_ptr<NameGenerator> nameGenerator_; 53 54 std::map<std::string, std::string> fileNameMapping_ {}; 55 56 std::map<std::string, std::string> nameMapping_ {}; 57 58 std::shared_ptr<GuardOptions> options_; 59 }; 60 61 } // namespace panda::guard 62 63 #endif // PANDA_GUARD_GENERATOR_NAME_MAPPING_H 64