gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
object.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * Authors: Gabe Black
28  */
29 
30 #ifndef __SYSTEMC_CORE_OBJECT_HH__
31 #define __SYSTEMC_CORE_OBJECT_HH__
32 
33 #include <string>
34 #include <vector>
35 
38 
39 namespace sc_gem5
40 {
41 
42 class Object;
43 
46 typedef Objects::iterator ObjectsIt;
47 typedef Events::iterator EventsIt;
48 
49 class Object
50 {
51  public:
53  Object(sc_core::sc_object *_sc_obj, const char *);
54  Object(sc_core::sc_object *_sc_obj, const Object &);
55  Object &operator = (const Object &);
56 
57  virtual ~Object();
58 
59  /*
60  * sc_object methods.
61  */
62  const char *name() const;
63  const char *basename() const;
64 
65  void print(std::ostream & =std::cout) const;
66  void dump(std::ostream & =std::cout) const;
67 
71 
73  sc_core::sc_attr_base *get_attribute(const std::string &);
74  sc_core::sc_attr_base *remove_attribute(const std::string &);
75  void remove_all_attributes();
76  int num_attributes() const;
78  const sc_core::sc_attr_cltn &attr_cltn() const;
79 
81 
82  static Object *
84  {
85  return sc_obj->_gem5_object;
86  }
87 
89 
92 
93  std::string pickUniqueName(std::string name);
94 
95  private:
97 
98  std::string _basename;
99  std::string _name;
100 
101  Objects children;
102  Events events;
104 
106 };
107 
108 std::string pickUniqueName(::sc_core::sc_object *parent, std::string name);
109 
110 extern Objects topLevelObjects;
111 extern Objects allObjects;
112 
114  const char *name, const Objects &objects=topLevelObjects);
115 
118 void popParentObj();
119 
120 } // namespace sc_gem5
121 
122 #endif //__SYSTEMC_CORE_OBJECT_HH__
void popParentObj()
Definition: object.cc:325
sc_core::sc_simcontext * simcontext() const
Definition: object.cc:244
virtual ~Object()
Definition: object.cc:140
int num_attributes() const
Definition: object.cc:226
sc_core::sc_object * get_parent_object() const
Definition: object.cc:196
sc_core::sc_object * parent
Definition: object.hh:103
sc_core::sc_attr_cltn & attr_cltn()
Definition: object.cc:232
void print(std::ostream &=std::cout) const
Definition: object.cc:172
const std::vector< sc_core::sc_object * > & get_child_objects() const
Definition: object.cc:185
sc_core::sc_attr_base * get_attribute(const std::string &)
Definition: object.cc:208
sc_core::sc_object * findObject(const char *name, const Objects &objects)
Definition: object.cc:298
std::string pickUniqueName(std::string name)
Definition: object.cc:265
Object(sc_core::sc_object *_sc_obj)
Definition: object.cc:88
sc_core::sc_attr_base * remove_attribute(const std::string &)
Definition: object.cc:214
std::vector< sc_core::sc_object * > Objects
Definition: object.hh:42
Objects children
Definition: object.hh:101
std::string _basename
Definition: object.hh:98
sc_core::sc_object * _sc_obj
Definition: object.hh:96
Object & operator=(const Object &)
Definition: object.cc:135
Events events
Definition: object.hh:102
std::vector< sc_core::sc_event * > Events
Definition: event.hh:56
std::string _name
Definition: object.hh:99
Objects allObjects
Definition: object.cc:289
sc_gem5::Object * _gem5_object
Definition: sc_object.hh:87
sc_core::sc_object * pickParentObj()
Definition: object.cc:312
void pushParentObj(sc_core::sc_object *obj)
Definition: object.cc:324
void delChildEvent(sc_core::sc_event *e)
Definition: object.cc:256
sc_core::sc_object * sc_obj()
Definition: object.hh:88
sc_core::sc_attr_cltn cltn
Definition: object.hh:105
Objects topLevelObjects
Definition: object.cc:288
Objects::iterator ObjectsIt
Definition: object.hh:46
const std::vector< sc_core::sc_event * > & get_child_events() const
Definition: object.cc:191
const char * basename() const
Definition: object.cc:166
Bitfield< 9 > e
void dump(std::ostream &=std::cout) const
Definition: object.cc:178
void remove_all_attributes()
Definition: object.cc:220
EventsIt addChildEvent(sc_core::sc_event *e)
Definition: object.cc:250
Events::iterator EventsIt
Definition: object.hh:47
const char * name() const
Definition: object.cc:160
static Object * getFromScObject(sc_core::sc_object *sc_obj)
Definition: object.hh:83
bool add_attribute(sc_core::sc_attr_base &)
Definition: object.cc:202

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13