• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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::set<std::string> &nameList);
42 
43     void AddFileNameMapping(const std::string &name);
44 
45     void AddFileNameMapping(const std::set<std::string> &nameList);
46 
47 private:
48     std::unique_ptr<NameGenerator> fileNameGenerator_;
49 
50     std::unique_ptr<NameGenerator> nameGenerator_;
51 
52     std::map<std::string, std::string> fileNameMapping_ {};
53 
54     std::map<std::string, std::string> nameMapping_ {};
55 
56     std::shared_ptr<GuardOptions> options_;
57 };
58 
59 }  // namespace panda::guard
60 
61 #endif  // PANDA_GUARD_GENERATOR_NAME_MAPPING_H
62