diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-23 15:47:59 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-23 15:47:59 +0100 |
commit | 18d3637ca02ab69f1ee744fa94c43c243de0f571 (patch) | |
tree | 42c859f014ab7dbb7d31a747e0ef3839c77c60fa /src/core/common/Rtti.cpp | |
parent | 85d72823ef18711fe7a29f5b23cc37b318766332 (diff) | |
parent | aa817d3bfd90aa39b6fd8a915bc78a8bb210cd3d (diff) |
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/common/Rtti.cpp')
-rw-r--r-- | src/core/common/Rtti.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/core/common/Rtti.cpp b/src/core/common/Rtti.cpp index 17b8880..6849a0e 100644 --- a/src/core/common/Rtti.cpp +++ b/src/core/common/Rtti.cpp @@ -47,8 +47,8 @@ const Rtti &RttiStore::lookup(const std::type_info &native) /* Class RttiBuilderBase */ -RttiBuilderBase &RttiBuilderBase::genericMethod(const std::string &name, - std::shared_ptr<Function> function) +RttiBuilderBase &RttiBuilderBase::genericMethod( + const std::string &name, std::shared_ptr<Function> function) { if (!methods.emplace(name, function).second) { throw OusiaException(std::string("Method with name \"") + name + @@ -80,10 +80,11 @@ void Rtti::initialize() const // Register the parent properties and methods { - for (const Rtti *parent: parents) { + for (const Rtti *parent : parents) { parent->initialize(); methods.insert(parent->methods.begin(), parent->methods.end()); - properties.insert(parent->properties.begin(), parent->properties.end()); + properties.insert(parent->properties.begin(), + parent->properties.end()); } } @@ -125,18 +126,41 @@ bool Rtti::isa(const Rtti &other) const return parents.count(&other) > 0; } +bool Rtti::isOneOf(const RttiSet &others) const +{ + initialize(); + for (const Rtti *other : others) { + if (parents.count(other) > 0) { + return true; + } + } + return false; +} + +bool Rtti::setIsOneOf(const RttiSet &s1, const RttiSet &s2) +{ + for (const Rtti *t1 : s1) { + if (t1->isOneOf(s2)) { + return true; + } + } + return false; +} + bool Rtti::composedOf(const Rtti &other) const { initialize(); return compositeTypes.count(&other) > 0; } -const RttiMethodMap &Rtti::getMethods() const { +const RttiMethodMap &Rtti::getMethods() const +{ initialize(); return methods; } -const RttiPropertyMap &Rtti::getProperties() const { +const RttiPropertyMap &Rtti::getProperties() const +{ initialize(); return properties; } @@ -151,7 +175,8 @@ std::shared_ptr<Function> Rtti::getMethod(const std::string &name) const return it->second; } -std::shared_ptr<PropertyDescriptor> Rtti::getProperty(const std::string &name) const +std::shared_ptr<PropertyDescriptor> Rtti::getProperty( + const std::string &name) const { initialize(); auto it = properties.find(name); |