diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-04-15 20:40:25 +0200 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2016-04-25 22:24:19 +0200 |
commit | 8810fc675a07e0ed62bcc391bb0464bc04dd3e37 (patch) | |
tree | 16a8cace91fc65bc7d1df2802d2e456f60786c52 /src/core/model/Ontology.hpp | |
parent | 2a5b3632fb49452adb6ecedb9c678909341ef662 (diff) |
Implement generic "inheritsFrom" method for Descriptor class
Diffstat (limited to 'src/core/model/Ontology.hpp')
-rw-r--r-- | src/core/model/Ontology.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/model/Ontology.hpp b/src/core/model/Ontology.hpp index 014f912..ddfa468 100644 --- a/src/core/model/Ontology.hpp +++ b/src/core/model/Ontology.hpp @@ -618,6 +618,16 @@ protected: bool doValidate(Logger &logger) const override; + /** + * Called when the "inheritsFrom" function is called, and this instance and + * c are of the same type, but not the same instance. Default implementation + * return false. + * + * @param c is the descriptor that should be checked for inheritance. + * @return true if this instance inherits from c. + */ + virtual bool doCheckInheritsFrom(Handle<Descriptor> c) const; + public: Descriptor(Manager &mgr, std::string name, Handle<Ontology> ontology) : Node(mgr, std::move(name), ontology), @@ -627,6 +637,16 @@ public: } /** + * Returns true if this class is a subclass of the given class or the given + * class itself. + * + * @param c is the class that should be checked for inheriting from this + * class. + * @return true if c either is this class or c inherits from this class. + */ + bool inheritsFrom(Handle<Descriptor> c) const; + + /** * Returns a reference to the StructType that specifies the attribute keys * as well as value ontologies for this Descriptor. * @@ -1042,6 +1062,7 @@ private: protected: bool doValidate(Logger &logger) const override; + bool doCheckInheritsFrom(Handle<Descriptor> c) const override; public: /** |