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 const char* name() const 00080 { return m_name; } 00081 const char* basename() const; 00082 00083 virtual void print(::std::ostream& os=::std::cout ) const; 00084 00085 // dump() is more detailed than print() 00086 virtual void dump(::std::ostream& os=::std::cout ) const; 00087 00088 virtual void trace( sc_trace_file* tf ) const; 00089 00090 virtual const char* kind() const { return "sc_object"; } 00091 00092 sc_simcontext* simcontext() const 00093 { return m_simc; } 00094 00095 // add attribute 00096 bool add_attribute( sc_attr_base& ); 00097 00098 // get attribute by name 00099 sc_attr_base* get_attribute( const std::string& name_ ); 00100 const sc_attr_base* get_attribute( const std::string& name_ ) const; 00101 00102 // remove attribute by name 00103 sc_attr_base* remove_attribute( const std::string& name_ ); 00104 00105 // remove all attributes 00106 void remove_all_attributes(); 00107 00108 // get the number of attributes 00109 int num_attributes() const; 00110 00111 // get the attribute collection 00112 sc_attr_cltn& attr_cltn(); 00113 const sc_attr_cltn& attr_cltn() const; 00114 00115 virtual const std::vector<sc_object*>& get_child_objects() const 00116 { return *(new std::vector<sc_object*>); } 00117 00118 sc_object* get_parent() const { return m_parent; } 00119 sc_object* get_parent_object() const { return m_parent; } 00120 00121 protected: 00122 00123 sc_object(); 00124 sc_object(const char* nm); 00125 virtual ~sc_object(); 00126 00127 private: 00128 00129 void sc_object_init(const char* nm); 00130 00131 private: 00132 00133 /* Each simulation object is associated with a simulation context */ 00134 sc_simcontext* m_simc; 00135 char* m_name; 00136 mutable sc_attr_cltn* m_attr_cltn_p; 00137 sc_object* m_parent; 00138 }; 00139 00140 00141 // ---------------------------------------------------------------------------- 00142 00143 extern const char SC_HIERARCHY_CHAR; 00144 extern bool sc_enable_name_checking; 00145 00146 00147 inline 00148 sc_object* sc_get_parent( const sc_object* obj_p ) 00149 { 00150 return obj_p->get_parent_object(); 00151 } 00152 00153 } // namespace sc_core 00154 00155 #endif // SC_OBJECT_H