gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxx_config.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Andrew Bardsley
38  */
39 
53 #ifndef __SIM_CXX_CONFIG_HH__
54 #define __SIM_CXX_CONFIG_HH__
55 
56 #include <map>
57 #include <string>
58 #include <vector>
59 
60 #include "sim/sim_object.hh"
61 
62 class CxxConfigParams;
63 
69 {
70  public:
71  /* Class to represent parameters and SimObject references within
72  * SimObjects */
73  class ParamDesc
74  {
75  public:
76  const std::string name;
77 
78  /* Is this a vector or singleton parameters/SimObject */
79  const bool isVector;
80 
83  const bool isSimObject;
84 
85  ParamDesc(const std::string &name_,
86  bool isVector_, bool isSimObject_) :
87  name(name_), isVector(isVector_), isSimObject(isSimObject_)
88  { }
89  };
90 
92  class PortDesc
93  {
94  public:
95  const std::string name;
96 
97  /* Is this a vector or singleton parameters/SimObject */
98  const bool isVector;
99 
101  const bool isMaster;
102 
103  PortDesc(const std::string &name_,
104  bool isVector_, bool isMaster_) :
105  name(name_), isVector(isVector_), isMaster(isMaster_)
106  { }
107  };
108 
110  std::map<std::string, ParamDesc *> parameters;
111 
113  std::map<std::string, PortDesc *> ports;
114 
116  virtual CxxConfigParams *makeParamsObject() const { return NULL; }
117 
119 };
120 
126 {
127  private:
128  static const std::string invalidName;
129 
130  public:
133  typedef uint32_t FlagsType;
134  typedef ::Flags<FlagsType> Flags;
135 
137  /* static const FlagsType MY_NEW_FLAG = 0x00000001; */
138 
139  public:
141  virtual void setName(const std::string &name_) { }
142 
144  virtual const std::string &getName() { return invalidName; }
145 
149  virtual bool setSimObject(const std::string &name,
150  SimObject *simObject)
151  { return false; }
152 
154  virtual bool setSimObjectVector(const std::string &name,
155  const std::vector<SimObject *> &simObjects)
156  { return false; }
157 
162  virtual bool setParam(const std::string &name,
163  const std::string &value, const Flags flags)
164  { return false; }
165 
168  virtual bool setParamVector(const std::string &name,
169  const std::vector<std::string> &values, const Flags flags)
170  { return false; }
171 
174  virtual bool setPortConnectionCount(const std::string &name,
175  unsigned int count)
176  { return false; }
177 
179  virtual SimObject *simObjectCreate() { return NULL; }
180 
182 
183  virtual ~CxxConfigParams() { }
184 };
185 
188 {
189  public:
191  virtual ~CxxConfigFileBase() { }
192 
196  virtual bool getParam(const std::string &object_name,
197  const std::string &param_name,
198  std::string &value) const = 0;
199 
201  virtual bool getParamVector(const std::string &object_name,
202  const std::string &param_name,
203  std::vector<std::string> &values) const = 0;
204 
206  virtual bool getPortPeers(const std::string &object_name,
207  const std::string &port_name,
208  std::vector<std::string> &peers) const = 0;
209 
211  virtual bool objectExists(const std::string &object_name) const = 0;
212 
214  virtual void getAllObjectNames(std::vector<std::string> &list) const = 0;
215 
219  virtual void getObjectChildren(const std::string &object_name,
220  std::vector<std::string> &children,
221  bool return_paths = false) const = 0;
222 
224  virtual bool load(const std::string &filename) = 0;
225 
228  virtual CxxConfigParams::Flags getFlags() const { return 0; }
229 };
230 
232 extern std::map<std::string, CxxConfigDirectoryEntry *>
234 
237 void cxxConfigInit();
238 
239 #endif // __SIM_CXX_CONFIG_HH__
count
Definition: misc.hh:704
virtual const std::string & getName()
Get full path name string.
Definition: cxx_config.hh:144
const std::string & name()
Definition: trace.cc:49
virtual bool getPortPeers(const std::string &object_name, const std::string &port_name, std::vector< std::string > &peers) const =0
Get the peer (connected) ports of the named ports.
virtual bool setSimObjectVector(const std::string &name, const std::vector< SimObject * > &simObjects)
As setSimObjectVector but set a whole vector of references.
Definition: cxx_config.hh:154
uint32_t FlagsType
Flags passable to setParam...
Definition: cxx_config.hh:133
virtual ~CxxConfigParams()
Definition: cxx_config.hh:183
Base for peer classes of SimObjectParams derived classes with parameter modifying member functions...
Definition: cxx_config.hh:125
const bool isSimObject
Is this a SimObject, and so is to be set with setSimObject...
Definition: cxx_config.hh:83
ParamDesc(const std::string &name_, bool isVector_, bool isSimObject_)
Definition: cxx_config.hh:85
virtual void getObjectChildren(const std::string &object_name, std::vector< std::string > &children, bool return_paths=false) const =0
Get the names or paths of all the children SimObjects of this SimObject.
std::map< std::string, PortDesc * > ports
Ports.
Definition: cxx_config.hh:113
::Flags< FlagsType > Flags
Definition: cxx_config.hh:134
std::map< std::string, CxxConfigDirectoryEntry * > cxx_config_directory
Directory of all SimObject classes config details.
Definition: cxx_config.cc:45
STL vector class.
Definition: stl.hh:40
Similar to ParamDesc to describe ports.
Definition: cxx_config.hh:92
void cxxConfigInit()
Initialise cxx_config_directory.
virtual ~CxxConfigFileBase()
Definition: cxx_config.hh:191
virtual bool setParamVector(const std::string &name, const std::vector< std::string > &values, const Flags flags)
As setParamVector but for parameters given as vectors pre-separated into elements.
Definition: cxx_config.hh:168
virtual void setName(const std::string &name_)
Example flag.
Definition: cxx_config.hh:141
virtual bool getParamVector(const std::string &object_name, const std::string &param_name, std::vector< std::string > &values) const =0
Get a list/vector parameter.
virtual CxxConfigParams * makeParamsObject() const
Make a ...Param structure for the SimObject class of this entry.
Definition: cxx_config.hh:116
Config file wrapper providing a common interface to CxxConfigManager.
Definition: cxx_config.hh:187
static const std::string invalidName
Definition: cxx_config.hh:128
std::map< std::string, ParamDesc * > parameters
All parameters (including SimObjects) in order.
Definition: cxx_config.hh:110
virtual ~CxxConfigDirectoryEntry()
Definition: cxx_config.hh:118
const bool isMaster
Is this a master or slave port.
Definition: cxx_config.hh:101
virtual bool setParam(const std::string &name, const std::string &value, const Flags flags)
Set a parameter with a value parsed from the given string.
Definition: cxx_config.hh:162
virtual bool objectExists(const std::string &object_name) const =0
Does an object with this path exist?
virtual SimObject * simObjectCreate()
Create the associated SimObject.
Definition: cxx_config.hh:179
virtual bool setPortConnectionCount(const std::string &name, unsigned int count)
Set the number of connections expected for the named port.
Definition: cxx_config.hh:174
virtual bool getParam(const std::string &object_name, const std::string &param_name, std::string &value) const =0
Get a single parameter value as a string returned in value.
virtual CxxConfigParams::Flags getFlags() const
Get the flags which should be used to modify parameter parsing behaviour.
Definition: cxx_config.hh:228
virtual bool load(const std::string &filename)=0
Load config file.
Config details entry for a SimObject.
Definition: cxx_config.hh:68
virtual void getAllObjectNames(std::vector< std::string > &list) const =0
Get all SimObjects in the config.
PortDesc(const std::string &name_, bool isVector_, bool isMaster_)
Definition: cxx_config.hh:103
virtual bool setSimObject(const std::string &name, SimObject *simObject)
Set a SimObject valued parameter with a reference to the given SimObject.
Definition: cxx_config.hh:149
Abstract superclass for simulation objects.
Definition: sim_object.hh:94

Generated on Fri Jun 9 2017 13:03:51 for gem5 by doxygen 1.8.6