gem5  v22.1.0.0
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 
28 #ifndef __SYSTEMC_CORE_OBJECT_HH__
29 #define __SYSTEMC_CORE_OBJECT_HH__
30 
31 #include <string>
32 #include <vector>
33 
36 
37 namespace sc_gem5
38 {
39 
40 class Object;
41 
44 typedef Objects::iterator ObjectsIt;
45 typedef Events::iterator EventsIt;
46 
47 class Object
48 {
49  public:
51  Object(sc_core::sc_object *_sc_obj, const char *);
53  Object &operator = (const Object &);
54 
55  virtual ~Object();
56 
57  /*
58  * sc_object methods.
59  */
60  const char *name() const;
61  const char *basename() const;
62 
63  void print(std::ostream & =std::cout) const;
64  void dump(std::ostream & =std::cout) const;
65 
69 
71  sc_core::sc_attr_base *get_attribute(const std::string &);
72  sc_core::sc_attr_base *remove_attribute(const std::string &);
73  void remove_all_attributes();
74  int num_attributes() const;
76  const sc_core::sc_attr_cltn &attr_cltn() const;
77 
79 
80  static Object *
82  {
83  return sc_obj->_gem5_object;
84  }
85 
87 
90 
91  std::string pickUniqueName(std::string name);
92 
93  private:
95 
96  std::string _basename;
97  std::string _name;
98 
102 
104 };
105 
106 std::string pickUniqueName(::sc_core::sc_object *parent, std::string name);
107 
108 extern Objects topLevelObjects;
109 extern Objects allObjects;
110 
112  const char *name, const Objects &objects=topLevelObjects);
113 
116 void popParentObj();
117 
118 } // namespace sc_gem5
119 
120 #endif //__SYSTEMC_CORE_OBJECT_HH__
sc_gem5::Object * _gem5_object
Definition: sc_object.hh:85
sc_core::sc_attr_base * remove_attribute(const std::string &)
Definition: object.cc:212
const char * name() const
Definition: object.cc:158
EventsIt addChildEvent(sc_core::sc_event *e)
Definition: object.cc:248
const std::vector< sc_core::sc_event * > & get_child_events() const
Definition: object.cc:189
sc_core::sc_simcontext * simcontext() const
Definition: object.cc:242
int num_attributes() const
Definition: object.cc:224
Object & operator=(const Object &)
Definition: object.cc:133
Objects children
Definition: object.hh:99
std::string _name
Definition: object.hh:97
void delChildEvent(sc_core::sc_event *e)
Definition: object.cc:254
const char * basename() const
Definition: object.cc:164
sc_core::sc_object * get_parent_object() const
Definition: object.cc:194
static Object * getFromScObject(sc_core::sc_object *sc_obj)
Definition: object.hh:81
sc_core::sc_attr_cltn cltn
Definition: object.hh:103
bool add_attribute(sc_core::sc_attr_base &)
Definition: object.cc:200
sc_core::sc_object * _sc_obj
Definition: object.hh:94
Events events
Definition: object.hh:100
std::string pickUniqueName(std::string name)
Definition: object.cc:263
void remove_all_attributes()
Definition: object.cc:218
void dump(std::ostream &=std::cout) const
Definition: object.cc:176
virtual ~Object()
Definition: object.cc:138
void print(std::ostream &=std::cout) const
Definition: object.cc:170
sc_core::sc_object * parent
Definition: object.hh:101
Object(sc_core::sc_object *_sc_obj)
Definition: object.cc:86
std::string _basename
Definition: object.hh:96
const std::vector< sc_core::sc_object * > & get_child_objects() const
Definition: object.cc:183
sc_core::sc_attr_cltn & attr_cltn()
Definition: object.cc:230
sc_core::sc_object * sc_obj()
Definition: object.hh:86
sc_core::sc_attr_base * get_attribute(const std::string &)
Definition: object.cc:206
Bitfield< 9 > e
Definition: misc_types.hh:65
void popParentObj()
Definition: object.cc:323
std::vector< sc_core::sc_event * > Events
Definition: event.hh:54
Objects allObjects
Definition: object.cc:287
std::string pickUniqueName(::sc_core::sc_object *parent, std::string base)
Definition: object.cc:273
Events::iterator EventsIt
Definition: object.hh:45
sc_core::sc_object * pickParentObj()
Definition: object.cc:310
sc_core::sc_object * findObject(const char *name, const Objects &objects)
Definition: object.cc:296
std::vector< sc_core::sc_object * > Objects
Definition: object.hh:40
Objects::iterator ObjectsIt
Definition: object.hh:44
void pushParentObj(sc_core::sc_object *obj)
Definition: object.cc:322
Objects topLevelObjects
Definition: object.cc:286
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:40 for gem5 by doxygen 1.9.1