diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-23 15:28:22 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2015-01-23 15:28:22 +0100 |
commit | 1131b68bdf2949f56422a2c53617a5f7d2d9be47 (patch) | |
tree | 771310108656fd4820cc780a523c888a3ac81c8a /src | |
parent | 9e084e8e7f657112436c3e07f12a2319373b1909 (diff) |
Fixed typos, autoformat and setIsOneOf method
Diffstat (limited to 'src')
-rw-r--r-- | src/core/common/Rtti.cpp | 32 | ||||
-rw-r--r-- | src/core/common/Rtti.hpp | 10 |
2 files changed, 33 insertions, 9 deletions
diff --git a/src/core/common/Rtti.cpp b/src/core/common/Rtti.cpp index 668e418..a913d76 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,10 +126,10 @@ bool Rtti::isa(const Rtti &other) const return parents.count(&other) > 0; } -bool Rtii::isOneOf(const RttiSet &others) const +bool Rtti::isOneOf(const RttiSet &others) const { initialize(); - for (const Rtti *other: others) { + for (const Rtti *other : others) { if (parents.count(other) > 0) { return true; } @@ -136,18 +137,30 @@ bool Rtii::isOneOf(const RttiSet &others) const 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; } @@ -162,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); diff --git a/src/core/common/Rtti.hpp b/src/core/common/Rtti.hpp index 53043e2..e2f1fa2 100644 --- a/src/core/common/Rtti.hpp +++ b/src/core/common/Rtti.hpp @@ -393,6 +393,16 @@ public: bool isOneOf(const RttiSet &others) const; /** + * Checks whether any type in the first set is one type in the second set. + * + * @param s1 is the first set. For each type in this set we check whether + * it is one of the types in s2. + * @param s2 is the second set. + * @return true if the above condition is fulfilled, false otherwise. + */ + static bool setIsOneOf(const RttiSet &s1, const RttiSet &s2); + + /** * Returns true if an instance of this type may have references to the other * given type. This mechanism is used to prune impossible paths when * resolving objects of a certain type by name in an object graph. |