torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Config.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the Config class.
18 
19 #ifndef TORC_PHYSICAL_CONFIG_HPP
20 #define TORC_PHYSICAL_CONFIG_HPP
21 
23 #include "torc/physical/Named.hpp"
24 
25 namespace torc {
26 namespace physical {
27 
28 // forward declaration of our unit test class within its namespace
29 namespace physical { class ConfigUnitTest; }
30 
31  /// \brief Configuration. A {name:value} pair.
32  /// \details Config elements typically live in a ConfigMap, and by inheritance, in Design,
33  /// Module, Instance, and Net objects. Within a ConfigMap, a setting name acts as a key
34  /// that points to a Config, together forming the standard {setting:name:value} triplet.
35  /// \note The name mentioned here is a user-specified name stemming from the design. It is not
36  /// the configuration setting name. For example, in configuration "DFF:blink:#FF", "DFF"
37  /// is the specified setting, "blink" is the name that the design assigns to the
38  /// corresponding resource, and "#FF" is the value to which "DFF" is set.
39  class Config : public Named {
40  // friends
41  /// \brief The ConfigMap class has direct access to our internals.
42  friend class ConfigMap;
43  /// \brief Our unit test has direct access to our internals.
45  protected:
46  // types
47  /// \brief Imported type name.
49  // static variables
50  /// \brief Default configuration name.
51  static const char* sConfigDefaultName;
52  /// \brief Default configuration value.
53  static const char* sConfigDefaultValue;
54  // members
55  /// \brief The configuration setting value.
56  /// \todo Consider typing mValue to something like SettingValueString.
57  string mValue;
58  /// \brief The sequence in which the configuration was created.
59  /// \details This is used by the XDL exporter to preserve the original order in cases where
60  /// multiple configurations exist for the same setting name.
62  // accessors
63  /// \brief Set the sequence index for this configuration.
64  /// \param inOrder The new sequence index.
65  void setOrder(SequenceIndex inOrder) { mOrder = inOrder; }
66  // constructors
67  /// \brief Protected copy constructor. This constructor allows the caller to specify the
68  /// sequence index.
69  /// \param inName The configuration name. The is a user-specified name, not a setting name.
70  /// \param inValue The configuration value.
71  /// \param inOrder The sequence index.
72  Config(const string& inName, const string& inValue, SequenceIndex inOrder)
73  : Named(inName), mValue(inValue), mOrder(inOrder) {}
74  public:
75  // constructors
76  /// \brief Null constructor required by collections.
77  Config(void)
79  /// \brief Standard constructor.
80  /// \param inName The configuration name. The is a user-specified name, not a setting name.
81  /// \param inValue The configuration value.
82  Config(const string& inName, const string& inValue)
83  : Named(inName), mValue(inValue), mOrder(eSequenceIndexNone) {}
84  // accessors
85  /// \brief Return the configuration value.
86  const string& getValue(void) const { return mValue; }
87  /// \brief Return the configuration sequence index.
88  SequenceIndex getOrder(void) const { return mOrder; }
89  /// \brief Set the configuration value.
90  void setValue(const string& inValue) { mValue = inValue; }
91  /// \brief Sets the object name.
92  /// \details Config names can be changed arbitrarily, but other Named subclasses require
93  /// more complex semantics to prevent name collisions.
94  void setName(const string& inName) { mName = inName; }
95  // operators
96  /// \brief Comparison operator.
97  /// \returns true if specified configuration matches this one in both name and value, or
98  /// false otherwise.
99  bool operator ==(const Config& rhs) const
100  { return mName == rhs.mName && mValue == rhs.mValue; }
101  };
102 
103 } // namespace physical
104 } // namespace torc
105 
106 #endif // TORC_PHYSICAL_CONFIG_HPP
boost::uint64_t SequenceIndex
Typedef for generic sequences.
void setOrder(SequenceIndex inOrder)
Set the sequence index for this configuration.
Definition: Config.hpp:65
string mName
The name of the object.
Definition: Named.hpp:43
std::string string
Imported type name.
Definition: Config.hpp:48
bool operator==(const Config &rhs) const
Comparison operator.
Definition: Config.hpp:99
Concept for any object that can be named.
Definition: Named.hpp:36
friend class torc::physical::physical::ConfigUnitTest
Our unit test has direct access to our internals.
Definition: Config.hpp:44
std::string string
SequenceIndex mOrder
The sequence in which the configuration was created.
Definition: Config.hpp:61
Header for Xilinx physical types.
string mValue
The configuration setting value.
Definition: Config.hpp:57
Config(const string &inName, const string &inValue)
Standard constructor.
Definition: Config.hpp:82
Configuration. A {name:value} pair.
Definition: Config.hpp:39
Config(void)
Null constructor required by collections.
Definition: Config.hpp:77
Header for the Named class.
const string & getValue(void) const
Return the configuration value.
Definition: Config.hpp:86
static const char * sConfigDefaultValue
Default configuration value.
Definition: Config.hpp:53
Configuration setting map.
Definition: ConfigMap.hpp:39
void setValue(const string &inValue)
Set the configuration value.
Definition: Config.hpp:90
Config(const string &inName, const string &inValue, SequenceIndex inOrder)
Protected copy constructor. This constructor allows the caller to specify the sequence index...
Definition: Config.hpp:72
void setName(const string &inName)
Sets the object name.
Definition: Config.hpp:94
SequenceIndex getOrder(void) const
Return the configuration sequence index.
Definition: Config.hpp:88
static const char * sConfigDefaultName
Default configuration name.
Definition: Config.hpp:51