summaryrefslogtreecommitdiff
path: root/src/systemc/core/sc_attr.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-06-22 14:14:47 -0700
committerGabe Black <gabeblack@google.com>2018-09-05 06:00:06 +0000
commit642fa515b822aca10839e0382e3a5d94eca20dd2 (patch)
treefa9adb998dc7aca23c88fbeda8bad48b0a329b0c /src/systemc/core/sc_attr.cc
parentd86151e70ff6046fd1cfadf675d686309271fcf1 (diff)
downloadgem5-642fa515b822aca10839e0382e3a5d94eca20dd2.tar.xz
systemc: Implement the sc_attr classes.
Change-Id: Ibbe6da957b1b36687178f226e80718adc0f4ab81 Reviewed-on: https://gem5-review.googlesource.com/11609 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/sc_attr.cc')
-rw-r--r--src/systemc/core/sc_attr.cc95
1 files changed, 36 insertions, 59 deletions
diff --git a/src/systemc/core/sc_attr.cc b/src/systemc/core/sc_attr.cc
index ca9e0af66..37a6575de 100644
--- a/src/systemc/core/sc_attr.cc
+++ b/src/systemc/core/sc_attr.cc
@@ -27,115 +27,92 @@
* Authors: Gabe Black
*/
+#include <utility>
+
#include "base/logging.hh"
#include "systemc/ext/core/sc_attr.hh"
namespace sc_core
{
-sc_attr_base::sc_attr_base(const std::string &)
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
+sc_attr_base::sc_attr_base(const std::string &_name) : _name(_name) {}
+sc_attr_base::sc_attr_base(const sc_attr_base &other) : _name(other._name) {}
+sc_attr_base::~sc_attr_base() {}
-sc_attr_base::sc_attr_base(const sc_attr_base &)
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-sc_attr_base::~sc_attr_base()
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-const std::string &
-sc_attr_base::name() const
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return *(const std::string *)nullptr;
-}
-
-void
-sc_attr_base::warn_unimpl(const char *func)
-{
- warn("%s not implemented.\n", func);
-}
+const std::string &sc_attr_base::name() const { return _name; }
sc_attr_cltn::iterator
sc_attr_cltn::begin()
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return (iterator)nullptr;
+ return cltn.begin();
}
sc_attr_cltn::const_iterator
sc_attr_cltn::begin() const
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return (const_iterator)nullptr;
+ return cltn.begin();
}
sc_attr_cltn::iterator
sc_attr_cltn::end()
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return (iterator)nullptr;
+ return cltn.end();
}
sc_attr_cltn::const_iterator
sc_attr_cltn::end() const
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return (const_iterator)nullptr;
+ return cltn.end();
}
-sc_attr_cltn::sc_attr_cltn()
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-sc_attr_cltn::sc_attr_cltn(const sc_attr_cltn &)
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
-
-sc_attr_cltn::~sc_attr_cltn()
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
+sc_attr_cltn::sc_attr_cltn() {}
+sc_attr_cltn::sc_attr_cltn(const sc_attr_cltn &other) : cltn(other.cltn) {}
+sc_attr_cltn::~sc_attr_cltn() {}
bool
-sc_attr_cltn::push_back(sc_attr_base *)
+sc_attr_cltn::push_back(sc_attr_base *attr)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return false;
+ if (!attr || (*this)[attr->name()])
+ return false;
+
+ cltn.push_back(attr);
+ return true;
}
sc_attr_base *
sc_attr_cltn::operator [] (const std::string &name)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ for (auto &attr: cltn)
+ if (attr->name() == name)
+ return attr;
return nullptr;
}
const sc_attr_base *
sc_attr_cltn::operator [] (const std::string &name) const
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ for (auto &attr: cltn)
+ if (attr->name() == name)
+ return attr;
return nullptr;
}
sc_attr_base *
sc_attr_cltn::remove(const std::string &name)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ for (auto &attr: cltn) {
+ if (attr->name() == name) {
+ sc_attr_base *ret = attr;
+ std::swap(attr, cltn.back());
+ cltn.pop_back();
+ return ret;
+ }
+ }
return nullptr;
}
-void
-sc_attr_cltn::remove_all()
-{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-}
+void sc_attr_cltn::remove_all() { cltn.clear(); }
+
+int sc_attr_cltn::size() const { return cltn.size(); }
} // namespace sc_core