00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2005 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 #ifndef SC_OBJECT_H 00040 #define SC_OBJECT_H 00041 00042 00043 #include "sysc/utils/sc_iostream.h" 00044 #include "sysc/kernel/sc_attribute.h" 00045 00046 namespace sc_core { 00047 00048 class sc_trace_file; 00049 class sc_simcontext; 00050 00051 00052 // ---------------------------------------------------------------------------- 00053 // CLASS : sc_object 00054 // 00055 // Abstract base class of all SystemC `simulation' objects. 00056 // ---------------------------------------------------------------------------- 00057 00058 class sc_object 00059 { 00060 friend class sc_object_manager; 00061 friend class sc_module_dynalloc_list; 00062 friend class sc_process_b; 00063 00064 public: 00065 00066 const char* name() const 00067 { return m_name; } 00068 const char* basename() const; 00069 00070 virtual void print(::std::ostream& os=::std::cout ) const; 00071 00072 // dump() is more detailed than print() 00073 virtual void dump(::std::ostream& os=::std::cout ) const; 00074 00075 virtual void trace( sc_trace_file* tf ) const; 00076 00077 virtual const char* kind() const { return "sc_object"; } 00078 00079 sc_simcontext* simcontext() const 00080 { return m_simc; } 00081 00082 // add attribute 00083 bool add_attribute( sc_attr_base& ); 00084 00085 // get attribute by name 00086 sc_attr_base* get_attribute( const std::string& name_ ); 00087 const sc_attr_base* get_attribute( const std::string& name_ ) const; 00088 00089 // remove attribute by name 00090 sc_attr_base* remove_attribute( const std::string& name_ ); 00091 00092 // remove all attributes 00093 void remove_all_attributes(); 00094 00095 // get the number of attributes 00096 int num_attributes() const; 00097 00098 // get the attribute collection 00099 sc_attr_cltn& attr_cltn(); 00100 const sc_attr_cltn& attr_cltn() const; 00101 00102 sc_object* get_parent() const { return m_parent; } 00103 00104 protected: 00105 00106 sc_object(); 00107 sc_object(const char* nm); 00108 virtual ~sc_object(); 00109 00110 private: 00111 00112 void sc_object_init(const char* nm); 00113 00114 private: 00115 00116 /* Each simulation object is associated with a simulation context */ 00117 sc_simcontext* m_simc; 00118 char* m_name; 00119 mutable sc_attr_cltn* m_attr_cltn_p; 00120 sc_object* m_parent; 00121 }; 00122 00123 00124 // ---------------------------------------------------------------------------- 00125 00126 extern const char SC_HIERARCHY_CHAR; 00127 extern bool sc_enable_name_checking; 00128 00129 } // namespace sc_core 00130 00131 #endif // SC_OBJECT_H
1.5.1