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_int.h -- For inline definitions of some utility functions. 00021 DO NOT EXPORT THIS INCLUDE FILE. 00022 00023 Original Author: Philipp A. Hartmann, OFFIS, 2013-02-10 00024 00025 *****************************************************************************/ 00026 00027 #ifndef SC_OBJECT_INT_H_INCLUDED_ 00028 #define SC_OBJECT_INT_H_INCLUDED_ 00029 00030 #include "sysc/kernel/sc_object.h" 00031 #include "sysc/kernel/sc_module.h" 00032 #include "sysc/kernel/sc_simcontext_int.h" 00033 #include "sysc/kernel/sc_phase_callback_registry.h" 00034 00035 namespace sc_core { 00036 00037 class sc_object::hierarchy_scope 00038 { 00039 public: 00040 explicit hierarchy_scope(sc_object* obj); 00041 explicit hierarchy_scope(sc_module* mod); 00042 ~hierarchy_scope(); 00043 00044 private: 00045 sc_module * scope_; 00046 00047 private: 00048 hierarchy_scope( hierarchy_scope const & other ) /* = delete */; 00049 hierarchy_scope& operator=(hierarchy_scope const&) /* = delete */; 00050 }; 00051 00052 00053 inline 00054 sc_object::hierarchy_scope::hierarchy_scope( sc_object* obj ) 00055 : scope_(0) 00056 { 00057 if( !obj ) return; 00058 00059 scope_ = dynamic_cast<sc_module*>(obj); 00060 if( !scope_ ) 00061 scope_ = dynamic_cast<sc_module*>(obj->get_parent_object()); 00062 if( scope_ ) 00063 scope_->simcontext()->hierarchy_push(scope_); 00064 } 00065 00066 00067 inline 00068 sc_object::hierarchy_scope::hierarchy_scope( sc_module* mod ) 00069 : scope_(mod) 00070 { 00071 if( scope_ ) 00072 scope_->simcontext()->hierarchy_push(scope_); 00073 } 00074 00075 00076 inline 00077 sc_object::hierarchy_scope::~hierarchy_scope() 00078 { 00079 if( scope_ ) 00080 scope_->simcontext()->hierarchy_pop(); 00081 } 00082 00083 00084 // ----------------------------------------------------------------------- 00085 00086 inline void 00087 sc_object::do_simulation_phase_callback() 00088 { 00089 simulation_phase_callback(); 00090 } 00091 00092 // ----------------------------------------------------------------------- 00093 00094 } // namespace sc_core 00095 00096 #endif // SC_OBJECT_INT_H_INCLUDED_ 00097 // Taf!