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                     DO NOT EXPORT THIS INCLUDE FILE.
24
25  Original Author: Philipp A. Hartmann, OFFIS, 2013-02-10
26
27 *****************************************************************************/
28
29#ifndef SC_OBJECT_INT_H_INCLUDED_
30#define SC_OBJECT_INT_H_INCLUDED_
31
32#include "sysc/kernel/sc_object.h"
33#include "sysc/kernel/sc_module.h"
34#include "sysc/kernel/sc_simcontext_int.h"
35#include "sysc/kernel/sc_phase_callback_registry.h"
36
37namespace sc_core {
38
39class sc_object::hierarchy_scope
40{
41public:
42    explicit hierarchy_scope(sc_object* obj);
43    explicit hierarchy_scope(sc_module* mod);
44    ~hierarchy_scope();
45
46private:
47    sc_module * scope_;
48
49private:
50    hierarchy_scope( hierarchy_scope const & other ) /* = delete */;
51    hierarchy_scope& operator=(hierarchy_scope const&) /* = delete */;
52};
53
54
55inline
56sc_object::hierarchy_scope::hierarchy_scope( sc_object* obj )
57  : scope_(0)
58{
59    if( !obj ) return;
60
61    scope_ = dynamic_cast<sc_module*>(obj);
62    if( !scope_ )
63        scope_ = dynamic_cast<sc_module*>(obj->get_parent_object());
64    if( scope_ )
65        scope_->simcontext()->hierarchy_push(scope_);
66}
67
68
69inline
70sc_object::hierarchy_scope::hierarchy_scope( sc_module* mod )
71  : scope_(mod)
72{
73    if( scope_ )
74        scope_->simcontext()->hierarchy_push(scope_);
75}
76
77
78inline
79sc_object::hierarchy_scope::~hierarchy_scope()
80{
81    if( scope_ )
82        scope_->simcontext()->hierarchy_pop();
83}
84
85
86// -----------------------------------------------------------------------
87
88inline void
89sc_object::do_simulation_phase_callback()
90{
91    simulation_phase_callback();
92}
93
94// -----------------------------------------------------------------------
95
96} // namespace sc_core
97
98#endif // SC_OBJECT_INT_H_INCLUDED_
99// Taf!
100