gem5 v24.0.0.0
Loading...
Searching...
No Matches
sc_attr.cc
Go to the documentation of this file.
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
28#include <utility>
29
31
32namespace sc_core
33{
34
35sc_attr_base::sc_attr_base(const std::string &_name) : _name(_name) {}
36sc_attr_base::sc_attr_base(const sc_attr_base &other) : _name(other._name) {}
38
39const std::string &sc_attr_base::name() const { return _name; }
40
43{
44 return cltn.begin();
45}
46
49{
50 return cltn.begin();
51}
52
55{
56 return cltn.end();
57}
58
61{
62 return cltn.end();
63}
64
66sc_attr_cltn::sc_attr_cltn(const sc_attr_cltn &other) : cltn(other.cltn) {}
68
69bool
71{
72 if (!attr || (*this)[attr->name()])
73 return false;
74
75 cltn.push_back(attr);
76 return true;
77}
78
81{
82 for (auto &attr: cltn)
83 if (attr->name() == name)
84 return attr;
85 return nullptr;
86}
87
88const sc_attr_base *
89sc_attr_cltn::operator [] (const std::string &name) const
90{
91 for (auto &attr: cltn)
92 if (attr->name() == name)
93 return attr;
94 return nullptr;
95}
96
98sc_attr_cltn::remove(const std::string &name)
99{
100 for (auto &attr: cltn) {
101 if (attr->name() == name) {
102 sc_attr_base *ret = attr;
103 std::swap(attr, cltn.back());
104 cltn.pop_back();
105 return ret;
106 }
107 }
108 return nullptr;
109}
110
112
113int sc_attr_cltn::size() const { return cltn.size(); }
114
115} // namespace sc_core
const std::string _name
Definition sc_attr.hh:51
virtual ~sc_attr_base()
Definition sc_attr.cc:37
const std::string & name() const
Definition sc_attr.cc:39
std::vector< elem_type >::iterator iterator
Definition sc_attr.hh:78
std::vector< elem_type >::const_iterator const_iterator
Definition sc_attr.hh:79
sc_attr_base * operator[](const std::string &name)
Definition sc_attr.cc:80
bool push_back(sc_attr_base *)
Definition sc_attr.cc:70
std::vector< sc_attr_base * > cltn
Definition sc_attr.hh:110
sc_attr_base * remove(const std::string &name)
Definition sc_attr.cc:98
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0