00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2006 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License Version 2.4 (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.systemc.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_object.h -- Abstract base class of all SystemC `simulation' objects. 00021 00022 Original Author: Stan Y. Liao, Synopsys, Inc. 00023 00024 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 00032 5 September 2003 00033 Description of Modification: - Made creation of attributes structure 00034 conditional on its being used. This eliminates 00035 100 bytes of storage for each normal sc_object. 00036 00037 *****************************************************************************/ 00038 00039 // $Log: sc_object.h,v $ 00040 // Revision 1.1.1.1 2006/12/15 20:31:37 acg 00041 // SystemC 2.2 00042 // 00043 // Revision 1.4 2006/04/11 23:13:21 acg 00044 // Andy Goodrich: Changes for reduced reset support that only includes 00045 // sc_cthread, but has preliminary hooks for expanding to method and thread 00046 // processes also. 00047 // 00048 // Revision 1.3 2006/01/13 18:44:30 acg 00049 // Added $Log to record CVS changes into the source. 00050 // 00051 00052 #ifndef SC_OBJECT_H 00053 #define SC_OBJECT_H 00054 00055 00056 #include "sysc/utils/sc_iostream.h" 00057 #include "sysc/kernel/sc_attribute.h" 00058 00059 namespace sc_core { 00060 00061 class sc_trace_file; 00062 class sc_simcontext; 00063 00064 00065 // ---------------------------------------------------------------------------- 00066 // CLASS : sc_object 00067 // 00068 // Abstract base class of all SystemC `simulation' objects. 00069 // ---------------------------------------------------------------------------- 00070 00071 class sc_object 00072 { 00073 friend class sc_object_manager; 00074 friend class sc_module_dynalloc_list; 00075 friend class sc_process_b; 00076 00077 public: 00078 00079 /// return full name of sc_object 00080 const char* name() const 00081 { return m_name; } 00082 /// return base name of sc_object (last part) 00083 const char* basename() const; 00084 00085 /// print object 00086 virtual void print(::std::ostream& os=::std::cout ) const; 00087 00088 /// dump() is more detailed than print() 00089 virtual void dump(::std::ostream& os=::std::cout ) const; 00090 00091 virtual void trace( sc_trace_file* tf ) const; 00092 00093 virtual const char* kind() const { return "sc_object"; } 00094 00095 sc_simcontext* simcontext() const 00096 { return m_simc; } 00097 00098 /// add attribute 00099 bool add_attribute( sc_attr_base& ); 00100 00101 /// get attribute by name 00102 sc_attr_base* get_attribute( const std::string& name_ ); 00103 /// get attribute by name 00104 const sc_attr_base* get_attribute( const std::string& name_ ) const; 00105 00106 /// remove attribute by name 00107 sc_attr_base* remove_attribute( const std::string& name_ ); 00108 00109 /// remove all attributes 00110 void remove_all_attributes(); 00111 00112 /// get the number of attributes 00113 int num_attributes() const; 00114 00115 /// get the attribute collection 00116 sc_attr_cltn& attr_cltn(); 00117 /// get the attribute collection 00118 const sc_attr_cltn& attr_cltn() const; 00119 00120 /// return child objects 00121 virtual const std::vector<sc_object*>& get_child_objects() const 00122 { return *(new std::vector<sc_object*>); } // AGB memory leak 00123 00124 /// return parent object 00125 sc_object* get_parent() const { return m_parent; } 00126 /// return parent object 00127 sc_object* get_parent_object() const { return m_parent; } 00128 00129 protected: 00130 00131 sc_object(); 00132 sc_object(const char* nm); 00133 virtual ~sc_object(); 00134 00135 private: 00136 00137 void sc_object_init(const char* nm); 00138 00139 private: 00140 00141 /* Each simulation object is associated with a simulation context */ 00142 sc_simcontext* m_simc; 00143 char* m_name; 00144 mutable sc_attr_cltn* m_attr_cltn_p; 00145 sc_object* m_parent; 00146 }; 00147 00148 00149 // ---------------------------------------------------------------------------- 00150 00151 extern const char SC_HIERARCHY_CHAR; 00152 extern bool sc_enable_name_checking; 00153 00154 00155 /// return parent object of current module 00156 inline 00157 sc_object* sc_get_parent( const sc_object* obj_p ) 00158 { 00159 return obj_p->get_parent_object(); 00160 } 00161 00162 } // namespace sc_core 00163 00164 #endif // SC_OBJECT_H
1.5.5