SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_object_int.h
Go to the documentation of this file.
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_int.h -- For inline definitions of some utility functions.
23 */
33 #ifndef SC_OBJECT_INT_H_INCLUDED_
34 #define SC_OBJECT_INT_H_INCLUDED_
35 
36 #include "sysc/kernel/sc_object.h"
37 #include "sysc/kernel/sc_module.h"
40 
41 namespace sc_core {
42 
44 {
45 public:
46  explicit hierarchy_scope(sc_object* obj);
47  explicit hierarchy_scope(sc_module* mod);
49 
50 private:
51  sc_module * scope_;
52 
53 private:
54  hierarchy_scope( hierarchy_scope const & other ) /* = delete */;
55  hierarchy_scope& operator=(hierarchy_scope const&) /* = delete */;
56 };
57 
58 
59 inline
61  : scope_(0)
62 {
63  if( !obj ) return;
64 
65  scope_ = dynamic_cast<sc_module*>(obj);
66  if( !scope_ )
67  scope_ = dynamic_cast<sc_module*>(obj->get_parent_object());
68  if( scope_ )
69  scope_->simcontext()->hierarchy_push(scope_);
70 }
71 
72 
73 inline
75  : scope_(mod)
76 {
77  if( scope_ )
78  scope_->simcontext()->hierarchy_push(scope_);
79 }
80 
81 
82 inline
84 {
85  if( scope_ )
86  scope_->simcontext()->hierarchy_pop();
87 }
88 
89 
90 inline void
91 sc_object::do_simulation_phase_callback()
92 {
93  simulation_phase_callback();
94 }
95 
96 } // namespace sc_core
97 
98 #endif // SC_OBJECT_INT_H_INCLUDED_
99 // Taf!
Abstract base class of all SystemC `simulation&#39; objects.
Definition: sc_object.h:61
sc_module * hierarchy_pop()
Base class for all structural entities.
Definition: sc_module.h:83
Definition of the simulation phase callbacks.
For inline definitions of some utility functions.
Abstract base class of all SystemC `simulation&#39; objects.
sc_object * get_parent_object() const
Definition: sc_object.h:121
Base class of all hierarchical modules and channels.
void hierarchy_push(sc_module *)
sc_simcontext * simcontext() const
Definition: sc_object.h:91