diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-23 00:30:44 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-23 00:30:44 +0100 |
commit | ef59091033b3f69dd01df009f21927b8ad81f5a9 (patch) | |
tree | 94bcc065d5ef4a1438a985f715a341ccc66acb53 /src | |
parent | 887244db14f00063ebd429a8535fb204a96bee4e (diff) |
Improved documentation and added "isOneOf" function to Rtti class.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/common/Rtti.cpp | 11 | ||||
-rw-r--r-- | src/core/common/Rtti.hpp | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/common/Rtti.cpp b/src/core/common/Rtti.cpp index 1213669..668e418 100644 --- a/src/core/common/Rtti.cpp +++ b/src/core/common/Rtti.cpp @@ -125,6 +125,17 @@ bool Rtti::isa(const Rtti &other) const return parents.count(&other) > 0; } +bool Rtii::isOneOf(const RttiSet &others) const +{ + initialize(); + for (const Rtti *other: others) { + if (parents.count(other) > 0) { + return true; + } + } + return false; +} + bool Rtti::composedOf(const Rtti &other) const { initialize(); diff --git a/src/core/common/Rtti.hpp b/src/core/common/Rtti.hpp index fa2692f..53043e2 100644 --- a/src/core/common/Rtti.hpp +++ b/src/core/common/Rtti.hpp @@ -378,10 +378,21 @@ public: * * @param other is the other type for which the relation to this type * should be checked. + * @return true if this type (directly or indirectly) has the given other + * type as parent or equals the other type. */ bool isa(const Rtti &other) const; /** + * Returns true if this Rtti instance is one of the given types. + * + * @param others is a set of other types to be checked. + * @return true if this type (directly or indirectly) has once of the given + * other types as parent or equals one of the other types. + */ + bool isOneOf(const RttiSet &others) const; + + /** * 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. |