1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include <vector>
31
32#include "systemc/core/object.hh"
33#include "systemc/ext/core/sc_object.hh"
34
35namespace sc_core
36{
37
38namespace
39{
40
41std::vector<sc_object *> top_level_objects;
42
43} // anonymous namespace
44
45const char *
46sc_object::name() const
47{
48    return _gem5_object->name();
49}
50
51const char *
52sc_object::basename() const
53{
54    return _gem5_object->basename();
55}
56
57void
58sc_object::print(std::ostream &out) const
59{
60    _gem5_object->print(out);
61}
62
63void
64sc_object::dump(std::ostream &out) const
65{
66    _gem5_object->dump(out);
67}
68
69const std::vector<sc_object *> &
70sc_object::get_child_objects() const
71{
72    return _gem5_object->get_child_objects();
73}
74
75const std::vector<sc_event *> &
76sc_object::get_child_events() const
77{
78    return _gem5_object->get_child_events();
79}
80
81sc_object *
82sc_object::get_parent_object() const
83{
84    return _gem5_object->get_parent_object();
85}
86
87bool
88sc_object::add_attribute(sc_attr_base &attr)
89{
90    return _gem5_object->add_attribute(attr);
91}
92
93sc_attr_base *
94sc_object::get_attribute(const std::string &name)
95{
96    return _gem5_object->get_attribute(name);
97}
98
99sc_attr_base *
100sc_object::remove_attribute(const std::string &name)
101{
102    return _gem5_object->remove_attribute(name);
103}
104
105void
106sc_object::remove_all_attributes()
107{
108    return _gem5_object->remove_all_attributes();
109}
110
111int
112sc_object::num_attributes() const
113{
114    return _gem5_object->num_attributes();
115}
116
117sc_attr_cltn &
118sc_object::attr_cltn()
119{
120    return _gem5_object->attr_cltn();
121}
122
123const sc_attr_cltn &
124sc_object::attr_cltn() const
125{
126    return _gem5_object->attr_cltn();
127}
128
129sc_simcontext *
130sc_object::simcontext() const
131{
132    return _gem5_object->simcontext();
133}
134
135sc_object::sc_object()
136{
137    _gem5_object = new sc_gem5::Object(this);
138}
139
140sc_object::sc_object(const char *name)
141{
142    _gem5_object = new sc_gem5::Object(this, name);
143}
144
145sc_object::sc_object(const sc_object &other)
146{
147    _gem5_object = new sc_gem5::Object(this, *other._gem5_object);
148}
149
150sc_object &
151sc_object::operator = (const sc_object &other)
152{
153    *_gem5_object = *other._gem5_object;
154    return *this;
155}
156
157sc_object::~sc_object()
158{
159    delete _gem5_object;
160}
161
162const std::vector<sc_object *> &
163sc_get_top_level_objects()
164{
165    return sc_gem5::topLevelObjects;
166}
167
168sc_object *
169sc_find_object(const char *name)
170{
171    return sc_gem5::findObject(name);
172}
173
174} // namespace sc_core
175