00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 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 (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.accellera.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_manager.h -- Manager of objects (naming, &c.) 00021 00022 Original Author: Stan Y. Liao, Synopsys, Inc. 00023 00024 CHANGE LOG AT THE END OF THE FILE 00025 *****************************************************************************/ 00026 00027 00028 #ifndef SC_OBJECT_MANAGER_H 00029 #define SC_OBJECT_MANAGER_H 00030 00031 #include <map> 00032 #include <vector> 00033 00034 namespace sc_core { 00035 00036 class sc_event; 00037 class sc_object; 00038 class sc_module_name; 00039 00040 00041 // ---------------------------------------------------------------------------- 00042 // CLASS : sc_object_manager 00043 // 00044 // Manager of objects. 00045 // ---------------------------------------------------------------------------- 00046 00047 class sc_object_manager 00048 { 00049 friend class sc_event; 00050 friend class sc_object; 00051 friend class sc_simcontext; 00052 00053 protected: 00054 struct table_entry 00055 { 00056 table_entry() : m_event_p(NULL), m_object_p(NULL) {} 00057 00058 sc_event* m_event_p; // if non-null this is an sc_event. 00059 sc_object* m_object_p; // if non-null this is an sc_object. 00060 }; 00061 00062 public: 00063 typedef std::map<std::string,table_entry> instance_table_t; 00064 typedef std::vector<sc_object*> object_vector_t; 00065 00066 sc_object_manager(); 00067 ~sc_object_manager(); 00068 00069 sc_event* find_event(const char* name); 00070 00071 sc_object* find_object(const char* name); 00072 sc_object* first_object(); 00073 sc_object* next_object(); 00074 00075 void hierarchy_push(sc_object* mdl); 00076 sc_object* hierarchy_pop(); 00077 sc_object* hierarchy_curr(); 00078 int hierarchy_size(); 00079 00080 void push_module_name(sc_module_name* mod_name); 00081 sc_module_name* pop_module_name(); 00082 sc_module_name* top_of_module_name_stack(); 00083 00084 00085 private: 00086 std::string create_name( const char* leaf_name ); 00087 void insert_event(const std::string& name, sc_event* obj); 00088 void insert_object(const std::string& name, sc_object* obj); 00089 void remove_event(const std::string& name); 00090 void remove_object(const std::string& name); 00091 00092 private: 00093 00094 instance_table_t::iterator m_event_it; // event instance iterator. 00095 bool m_event_walk_ok; // true if can walk events. 00096 instance_table_t m_instance_table; // table of instances. 00097 sc_module_name* m_module_name_stack; // sc_module_name stack. 00098 instance_table_t::iterator m_object_it; // object instance iterator. 00099 object_vector_t m_object_stack; // sc_object stack. 00100 bool m_object_walk_ok; // true if can walk objects. 00101 }; 00102 00103 } // namespace sc_core 00104 00105 // $Log: sc_object_manager.h,v $ 00106 // Revision 1.9 2011/08/26 20:46:10 acg 00107 // Andy Goodrich: moved the modification log to the end of the file to 00108 // eliminate source line number skew when check-ins are done. 00109 // 00110 // Revision 1.8 2011/03/06 15:55:11 acg 00111 // Andy Goodrich: Changes for named events. 00112 // 00113 // Revision 1.7 2011/03/05 19:44:20 acg 00114 // Andy Goodrich: changes for object and event naming and structures. 00115 // 00116 // Revision 1.6 2011/03/05 01:39:21 acg 00117 // Andy Goodrich: changes for named events. 00118 // 00119 // Revision 1.5 2011/02/18 20:27:14 acg 00120 // Andy Goodrich: Updated Copyrights. 00121 // 00122 // Revision 1.4 2011/02/13 21:47:37 acg 00123 // Andy Goodrich: update copyright notice. 00124 // 00125 // Revision 1.3 2010/07/22 20:02:33 acg 00126 // Andy Goodrich: bug fixes. 00127 // 00128 // Revision 1.2 2008/05/22 17:06:26 acg 00129 // Andy Goodrich: updated copyright notice to include 2008. 00130 // 00131 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00132 // SystemC 2.3 00133 // 00134 // Revision 1.3 2006/01/13 18:44:30 acg 00135 // Added $Log to record CVS changes into the source. 00136 00137 #endif