1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_object_manager.h -- Manager of objects (naming, &c.) 23 24 Original Author: Stan Y. Liao, Synopsys, Inc. 25 26 CHANGE LOG AT THE END OF THE FILE 27 *****************************************************************************/ 28 29 30#ifndef SC_OBJECT_MANAGER_H 31#define SC_OBJECT_MANAGER_H 32 33#include <map> 34#include <vector> 35 36namespace sc_core { 37 38class sc_event; 39class sc_object; 40class sc_module_name; 41 42 43// ---------------------------------------------------------------------------- 44// CLASS : sc_object_manager 45// 46// Manager of objects. 47// ---------------------------------------------------------------------------- 48 49class sc_object_manager 50{ 51 friend class sc_event; 52 friend class sc_object; 53 friend class sc_simcontext; 54 55protected: 56 struct table_entry 57 { 58 table_entry() : m_event_p(NULL), m_object_p(NULL) {} 59 60 sc_event* m_event_p; // if non-null this is an sc_event. 61 sc_object* m_object_p; // if non-null this is an sc_object. 62 }; 63 64public: 65 typedef std::map<std::string,table_entry> instance_table_t; 66 typedef std::vector<sc_object*> object_vector_t; 67 68 sc_object_manager(); 69 ~sc_object_manager(); 70 71 sc_event* find_event(const char* name); 72 73 sc_object* find_object(const char* name); 74 sc_object* first_object(); 75 sc_object* next_object(); 76 77 void hierarchy_push(sc_object* mdl); 78 sc_object* hierarchy_pop(); 79 sc_object* hierarchy_curr(); 80 int hierarchy_size(); 81 82 void push_module_name(sc_module_name* mod_name); 83 sc_module_name* pop_module_name(); 84 sc_module_name* top_of_module_name_stack(); 85 86 87private: 88 std::string create_name( const char* leaf_name ); 89 void insert_event(const std::string& name, sc_event* obj); 90 void insert_object(const std::string& name, sc_object* obj); 91 void remove_event(const std::string& name); 92 void remove_object(const std::string& name); 93 94private: 95 96 instance_table_t::iterator m_event_it; // event instance iterator. 97 bool m_event_walk_ok; // true if can walk events. 98 instance_table_t m_instance_table; // table of instances. 99 sc_module_name* m_module_name_stack; // sc_module_name stack. 100 instance_table_t::iterator m_object_it; // object instance iterator. 101 object_vector_t m_object_stack; // sc_object stack. 102 bool m_object_walk_ok; // true if can walk objects. 103}; 104 105} // namespace sc_core 106 107// $Log: sc_object_manager.h,v $ 108// Revision 1.9 2011/08/26 20:46:10 acg 109// Andy Goodrich: moved the modification log to the end of the file to 110// eliminate source line number skew when check-ins are done. 111// 112// Revision 1.8 2011/03/06 15:55:11 acg 113// Andy Goodrich: Changes for named events. 114// 115// Revision 1.7 2011/03/05 19:44:20 acg 116// Andy Goodrich: changes for object and event naming and structures. 117// 118// Revision 1.6 2011/03/05 01:39:21 acg 119// Andy Goodrich: changes for named events. 120// 121// Revision 1.5 2011/02/18 20:27:14 acg 122// Andy Goodrich: Updated Copyrights. 123// 124// Revision 1.4 2011/02/13 21:47:37 acg 125// Andy Goodrich: update copyright notice. 126// 127// Revision 1.3 2010/07/22 20:02:33 acg 128// Andy Goodrich: bug fixes. 129// 130// Revision 1.2 2008/05/22 17:06:26 acg 131// Andy Goodrich: updated copyright notice to include 2008. 132// 133// Revision 1.1.1.1 2006/12/15 20:20:05 acg 134// SystemC 2.3 135// 136// Revision 1.3 2006/01/13 18:44:30 acg 137// Added $Log to record CVS changes into the source. 138 139#endif 140