SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_attribute.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  sc_attribute.h -- Attribute classes.
23 */
34 #ifndef SC_ATTRIBUTE_H
35 #define SC_ATTRIBUTE_H
36 
37 #include <string>
38 #include <vector>
39 
40 #include "sysc/kernel/sc_cmnhdr.h"
41 
42 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
43 #pragma warning(push)
44 #pragma warning(disable: 4251) // DLL import for std::string,vector
45 #endif
46 
47 namespace sc_core {
48 
56 {
57 public:
58 
59  // constructors
60  sc_attr_base( const std::string& name_ );
61  sc_attr_base( const sc_attr_base& );
62 
63  // destructor (does nothing)
64  virtual ~sc_attr_base();
65 
66  // get the name
67  const std::string& name() const;
68 
69 private:
70 
71  std::string m_name;
72 
73 private:
74 
75  // disabled
76  sc_attr_base();
77  sc_attr_base& operator = ( const sc_attr_base& );
78 };
79 
80 
90 {
91 public:
92 
93  // typedefs
95  typedef std::vector<elem_type>::iterator iterator;
96  typedef std::vector<elem_type>::const_iterator const_iterator;
97 
98  // constructors
99  sc_attr_cltn();
100  sc_attr_cltn( const sc_attr_cltn& );
101 
102  // destructor
103  ~sc_attr_cltn();
104 
105  // add attribute to the collection.
106  // returns 'true' if the name of the attribute is unique,
107  // returns 'false' otherwise (attribute is not added).
108  bool push_back( sc_attr_base* );
109 
110  // get attribute by name.
111  // returns pointer to attribute, or 0 if name does not exist.
112  sc_attr_base* operator [] ( const std::string& name_ );
113  const sc_attr_base* operator [] ( const std::string& name_ ) const;
114 
115  // remove attribute by name.
116  // returns pointer to attribute, or 0 if name does not exist.
117  sc_attr_base* remove( const std::string& name_ );
118 
119  // remove all attributes
120  void remove_all();
121 
122  // get the size of the collection
123  int size() const
124  { return static_cast<int>(m_cltn.size()); }
125 
126  // get the begin iterator
127  iterator begin()
128  { return m_cltn.begin(); }
129  const_iterator begin() const
130  { return m_cltn.begin(); }
131 
132  // get the end iterator
133  iterator end()
134  { return m_cltn.end(); }
135  const_iterator end() const
136  { return m_cltn.end(); }
137 
138 private:
139  std::vector<sc_attr_base*> m_cltn;
140 
141 private:
142 
143  // disabled
144  sc_attr_cltn& operator = ( const sc_attr_cltn& );
145 };
146 
147 
155 template <class T>
157 : public sc_attr_base
158 {
159 public:
160 
161  // constructors
162 
163  sc_attribute( const std::string& name_ )
164  : sc_attr_base( name_ ), value()
165  {}
166 
167  sc_attribute( const std::string& name_, const T& value_ )
168  : sc_attr_base( name_ ), value( value_ )
169  {}
170 
172  : sc_attr_base( a.name() ), value( a.value )
173  {}
174 
175 
176  // destructor (does nothing)
177 
178  virtual ~sc_attribute()
179  {}
180 
181 public:
182 
183  // public data member; for easy access
184  T value;
185 
186 private:
187 
188  // disabled
189  sc_attribute();
190  sc_attribute<T>& operator = ( const sc_attribute<T>& );
191 };
192 
193 } // namespace sc_core
194 
195 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
196 #pragma warning(pop)
197 #endif
198 
199 // $Log: sc_attribute.h,v $
200 // Revision 1.6 2011/08/26 20:46:08 acg
201 // Andy Goodrich: moved the modification log to the end of the file to
202 // eliminate source line number skew when check-ins are done.
203 //
204 // Revision 1.5 2011/02/18 20:27:14 acg
205 // Andy Goodrich: Updated Copyrights.
206 //
207 // Revision 1.4 2011/02/13 21:47:37 acg
208 // Andy Goodrich: update copyright notice.
209 //
210 // Revision 1.3 2010/07/22 20:02:33 acg
211 // Andy Goodrich: bug fixes.
212 //
213 // Revision 1.2 2008/05/22 17:06:24 acg
214 // Andy Goodrich: updated copyright notice to include 2008.
215 //
216 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
217 // SystemC 2.3
218 //
219 // Revision 1.3 2006/01/13 18:44:29 acg
220 // Added $Log to record CVS changes into the source.
221 //
222 
223 #endif
224 
225 // Taf!
sc_attr_base * elem_type
Definition: sc_attribute.h:94
Attribute class.
Attribute collection class.
Definition: sc_attribute.h:89
std::vector< elem_type >::iterator iterator
Definition: sc_attribute.h:95
std::vector< elem_type >::const_iterator const_iterator
Definition: sc_attribute.h:96
Attribute base class.
Definition: sc_attribute.h:55
sc_clock period is zero sc_clock low time is zero sc_fifo< T > cannot have more than one writer bind interface to port failed complete binding failed remove port failed insert primitive channel failed sc_signal< T > cannot have more than one driver resolved port not bound to resolved signal sc_semaphore requires an initial value
sc_attribute(const std::string &name_, const T &value_)
Definition: sc_attribute.h:167
const_iterator begin() const
Definition: sc_attribute.h:129
sc_attribute(const std::string &name_)
Definition: sc_attribute.h:163
const_iterator end() const
Definition: sc_attribute.h:135
#define SC_API
Definition: sc_cmnhdr.h:168
sc_attribute(const sc_attribute< T > &a)
Definition: sc_attribute.h:171