PFPConfig.h
1 /*
2  * PFPSim: Library for the Programmable Forwarding Plane Simulation Framework
3  *
4  * Copyright (C) 2016 Concordia Univ., Montreal
5  * Samar Abdi
6  * Umair Aftab
7  * Gordon Bailey
8  * Faras Dewal
9  * Shafigh Parsazad
10  * Eric Tremblay
11  *
12  * Copyright (C) 2016 Ericsson
13  * Bochra Boughzala
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28  * 02110-1301, USA.
29  */
30 
43 #ifndef CORE_PFPCONFIG_H_
44 #define CORE_PFPCONFIG_H_
45 
46 #include <fstream>
47 #include <vector>
48 #include <string>
49 #include <map>
50 #include "systemc.h"
51 
52 #define INPUT_FILE_ERROR -7
53 #define USER_ERROR_FATAL -10
54 #define SPCONFIG(param) \
55 pfp::core::GetParameter(param);
56 #define SPSETCONFIGPATH(path) \
57 pfp::core::PFPConfig::get().SetConfigFilePath(path);
58 #define SPSETOUTPUTDIRPATH(path) \
59 pfp::core::PFPConfig::get().SetOutputDirPath(path);
60 #define SPSETARGS(args) \
61 pfp::core::PFPConfig::get().set_command_line_arg_vector(args);
62 #define SPARG(key) \
63 pfp::core::PFPConfig::get().get_command_line_arg(key)
64 #define CONFIGROOT \
65 pfp::core::PFPConfig::get().getConfigFilePath()
66 #define OUTPUTDIR \
67 pfp::core::PFPConfig::get().getOutputDirPath()
68 #define ISVERBOSITY(level) \
69 pfp::core::PFPConfig::get().get_verbose_level() \
70  == pfp::core::PFPConfig::get().verbosity::level
71 #define SET_PFP_DEBUGGER_FLAG(debugger_enabled) \
72 pfp::core::PFPConfig::get().set_debugger_flag(debugger_enabled)
73 #define PFP_DEBUGGER_ENABLED \
74 pfp::core::PFPConfig::get().debugger_flag_status()
75 
76 namespace pfp {
77 namespace core {
78 
79 class PFPConfig {
80  public:
85  static PFPConfig& get();
86 
87  void SetConfigFilePath(std::string path);
88  std::string getConfigFilePath() const;
89  void SetOutputDirPath(std::string path);
90  std::string getOutputDirPath() const;
91 
92  #define VERBOSITY_LEVELS_LINE_MARKER __LINE__
93  #define VERBOSITY_LEVELS_FILE_MARKER __FILE__
94  enum verbosity {
95  normal,
96  minimal,
97  p4profile,
98  profile,
99  debugger,
100  debug,
101  PROFILE_LEVELS = debug + 1 /*returns the number of enums in verbosity*/
102  };
103  /*
104  * Warning:
105  * enum is implicitly tied to vector, index positions of levels in both containers should be same
106  * so that it returns the same enum value from the map
107  */
108  std::vector<std::string> verbositylevels {
109  "normal", "minimal", "p4profile", "profile", "debugger", "debug"};
110 
116  const verbosity get_verbose_level();
117  void set_verbose_level(PFPConfig::verbosity);
118  void set_verbose_level(std::string verbosity_level);
119 
120  void set_command_line_arg_vector(std::vector<std::string> & v);
121  std::string & get_command_line_arg(std::string key);
122  void set_debugger_flag(bool flag_value);
123  bool debugger_flag_status();
124 
125 
126  private:
130  PFPConfig();
131 
132  PFPConfig(const PFPConfig &) = delete;
133  PFPConfig& operator=(const PFPConfig &) = delete;
134  PFPConfig(PFPConfig &&) = delete;
135  PFPConfig& operator=(PFPConfig &&) = delete;
136 
137  private:
138  std::string verbose;
139  verbosity verbo;
140  sc_mutex pop_guard;
141  std::string ConfigFilePath;
142  std::string OutputDirPath;
143  std::map<std::string, std::string> configMap;
144  std::map<std::string, std::string> argMap;
145  /* Map that returns the enum from the string*/
146  std::map<std::string, uint64_t> verbosity_levels_map;
147  bool debugger_flag;
148 };
149 }; // namespace core
150 }; // namespace pfp
151 #endif // CORE_PFPCONFIG_H_
const verbosity get_verbose_level()
Pop the currently running parameter values PFPConfig only allows the NPU to call simulation complete ...
Definition: PFPConfig.cpp:70
Definition: PFPConfig.h:79
PacketBase.h.
Definition: ConfigurationParameters.cpp:36