SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_object_int.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_object_int.h -- For inline definitions of some utility functions.
21  DO NOT EXPORT THIS INCLUDE FILE.
22 
23  Original Author: Philipp A. Hartmann, OFFIS, 2013-02-10
24 
25  *****************************************************************************/
26 
27 #ifndef SC_OBJECT_INT_H_INCLUDED_
28 #define SC_OBJECT_INT_H_INCLUDED_
29 
30 #include "sysc/kernel/sc_object.h"
31 #include "sysc/kernel/sc_module.h"
34 
35 namespace sc_core {
36 
38 {
39 public:
40  explicit hierarchy_scope(sc_object* obj);
41  explicit hierarchy_scope(sc_module* mod);
43 
44 private:
45  sc_module * scope_;
46 
47 private:
48  hierarchy_scope( hierarchy_scope const & other ) /* = delete */;
49  hierarchy_scope& operator=(hierarchy_scope const&) /* = delete */;
50 };
51 
52 
53 inline
55  : scope_(0)
56 {
57  if( !obj ) return;
58 
59  scope_ = dynamic_cast<sc_module*>(obj);
60  if( !scope_ )
61  scope_ = dynamic_cast<sc_module*>(obj->get_parent_object());
62  if( scope_ )
63  scope_->simcontext()->hierarchy_push(scope_);
64 }
65 
66 
67 inline
69  : scope_(mod)
70 {
71  if( scope_ )
72  scope_->simcontext()->hierarchy_push(scope_);
73 }
74 
75 
76 inline
78 {
79  if( scope_ )
80  scope_->simcontext()->hierarchy_pop();
81 }
82 
83 
84 // -----------------------------------------------------------------------
85 
86 inline void
87 sc_object::do_simulation_phase_callback()
88 {
89  simulation_phase_callback();
90 }
91 
92 // -----------------------------------------------------------------------
93 
94 } // namespace sc_core
95 
96 #endif // SC_OBJECT_INT_H_INCLUDED_
97 // Taf!
sc_object * get_parent_object() const
Definition: sc_object.h:111
void hierarchy_push(sc_module *)
sc_simcontext * simcontext() const
Definition: sc_object.h:81