diff options
Diffstat (limited to 'src')
26 files changed, 366 insertions, 348 deletions
diff --git a/src/cli/Main.cpp b/src/cli/Main.cpp index d03735d..2fe0585 100644 --- a/src/cli/Main.cpp +++ b/src/cli/Main.cpp @@ -41,7 +41,7 @@ #include <core/frontend/TerminalLogger.hpp> #include <core/managed/Manager.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Project.hpp> #include <core/model/Typesystem.hpp> #include <core/parser/ParserContext.hpp> @@ -120,7 +120,7 @@ int main(int argc, char **argv) "The input document file name")( "include,I", po::value<std::vector<std::string>>(), "Include paths, where resources like the input document " - "or additional domains, typesystems, etc. might be " + "or additional ontologies, typesystems, etc. might be " "found.")( "output,o", po::value<std::string>(&outputPath), "The output file name. Per default the input file name will be used.")( @@ -234,11 +234,11 @@ int main(int argc, char **argv) OsxmlParser osxmlParser; registry.registerParser( {"text/vnd.ousia.osml"}, - {&RttiTypes::Document, &RttiTypes::Domain, &RttiTypes::Typesystem}, + {&RttiTypes::Document, &RttiTypes::Ontology, &RttiTypes::Typesystem}, &osmlParser); registry.registerParser( {"text/vnd.ousia.osml+xml"}, - {&RttiTypes::Document, &RttiTypes::Domain, &RttiTypes::Typesystem}, + {&RttiTypes::Document, &RttiTypes::Ontology, &RttiTypes::Typesystem}, &osxmlParser); registry.registerResourceLocator(&fileLocator); diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index 2fcd20d..b29767e 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -180,7 +180,7 @@ bool DocumentEntity::doValidate(Logger &logger) const // check if the parent reference is correct. if (child->getParent() != subInst) { logger.error(std::string("A child of field \"") + - fieldDescs[f]->getName() + + fieldDescs[f]->getNameOrDefaultName() + "\" has the wrong parent reference!", *child); valid = false; @@ -209,7 +209,7 @@ bool DocumentEntity::doValidate(Logger &logger) const c->getDescriptor()->getName() + "\" is not allowed as child of an instance of \"" + descriptor->getName() + "\" in field \"" + - fieldDescs[f]->getName() + "\"", + fieldDescs[f]->getNameOrDefaultName() + "\"", *child); valid = false; continue; @@ -285,7 +285,7 @@ static int enforceGetFieldDescriptorIndex( if (idx == -1) { throw OusiaException(std::string("Descriptor \"") + desc->getName() + "\" does not reference the given field \"" + - fieldDescriptor->getName() + "\""); + fieldDescriptor->getNameOrDefaultName() + "\""); } return idx; } @@ -723,7 +723,7 @@ void Document::doResolve(ResolutionState &state) if (root != nullptr) { continueResolveCompositum(root, state); } - continueResolveReferences(domains, state); + continueResolveReferences(ontologies, state); continueResolveReferences(typesystems, state); } @@ -761,8 +761,8 @@ bool Document::doValidate(Logger &logger) const void Document::doReference(Handle<Node> node) { - if (node->isa(&RttiTypes::Domain)) { - referenceDomain(node.cast<Domain>()); + if (node->isa(&RttiTypes::Ontology)) { + referenceOntology(node.cast<Ontology>()); } if (node->isa(&RttiTypes::Typesystem)) { referenceTypesystem(node.cast<Typesystem>()); @@ -771,7 +771,7 @@ void Document::doReference(Handle<Node> node) RttiSet Document::doGetReferenceTypes() const { - return RttiSet{&RttiTypes::Domain, &RttiTypes::Typesystem}; + return RttiSet{&RttiTypes::Ontology, &RttiTypes::Typesystem}; } Rooted<StructuredEntity> Document::createRootStructuredEntity( diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp index a5e40ce..dc0f73f 100644 --- a/src/core/model/Document.hpp +++ b/src/core/model/Document.hpp @@ -22,29 +22,29 @@ * This header contains the class hierarchy of actual document classes. A graph * of connected instances of these nodes is a "Document". How the different * DocumentEntity instances may be connected within the graph is subject to the - * specification in the respective Domain(s) (see also the Domain.hpp). + * specification in the respective Ontology(s) (see also the Ontology.hpp). * * A Document, from top to bottom, consists of "Document" instance, * which "owns" the structural root node of the in-document graph. This might - * for example be a "book" node of the "book" domain. That root node in turn has + * for example be a "book" node of the "book" ontology. That root node in turn has * structure nodes as children, which in turn may have children. This * constitutes a Structure Tree. Additionally annotations may be attached to * Structure Nodes, effectively resulting in a Document Graph instead of a * Document Tree (other references may introduce cycles as well). * - * Consider this XML representation of a document using the "book" domain: + * Consider this XML representation of a document using the "book" ontology: * * \code{.xml} * <doc> * <head> - * <import rel="domain" src="book_domain.oxm"/> - * <import rel="domain" src="emphasized_domain.oxm"/> + * <import rel="ontology" src="book_ontology.oxm"/> + * <import rel="ontology" src="emphasized_ontology.oxm"/> * <alias tag="paragraph" aka="p"/> * </head> * <book> * This might be some introductory text or a dedication. Ideally, of * course, such elements would be semantically specified as such in - * additional domains (or in this one). + * additional ontologies (or in this one). * <chapter name="myFirstChapter"> * Here we might have an introduction to the chapter, including some * overview of the chapters structure. @@ -63,9 +63,9 @@ * \endcode * * As can be seen the StructureEntities inherently follow a tree structure that - * is restricted by the implicit context free grammar of the "book" Domain + * is restricted by the implicit context free grammar of the "book" Ontology * definition (e.g. it is not allowed to have a "book" node inside a "section"; - * refer to te Domain.hpp for more information). + * refer to te Ontology.hpp for more information). * * Another interesting fact is the special place of AnnotationEntities: They are * Defined by start and end Anchors in the text. Note that this allows for @@ -114,7 +114,7 @@ #include <core/common/Variant.hpp> #include "Node.hpp" -#include "Domain.hpp" +#include "Ontology.hpp" #include "RootNode.hpp" #include "Typesystem.hpp" @@ -131,7 +131,7 @@ class Anchor; /** * A DocumentEntity is the common superclass for StructuredEntities and - * AnnotationEntities. Similarly to DescriptorEntity in the Domain.hpp it + * AnnotationEntities. Similarly to DescriptorEntity in the Ontology.hpp it * defines that each node in the Document graph may have attributes (in form * of a struct Variant), and fields. * The fields here are a vector of vectors. The first vector implements all @@ -215,7 +215,7 @@ public: * If the name is unknown an exception is thrown. * * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return a NodeVector of all StructuredEntities in that field. */ const NodeVector<StructureNode> &getField( @@ -243,7 +243,7 @@ public: * If the index is out of bounds an exception is thrown. * * @param idx is the index of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return a NodeVector of all StructuredEntities in that field. */ const NodeVector<StructureNode> &getField(const size_t &idx) const; @@ -257,7 +257,7 @@ public: * * @param s is the StructureNode that shall be added. * @param fieldIdx is the index of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. */ void addStructureNode(Handle<StructureNode> s, const size_t &fieldIdx); /** @@ -271,7 +271,7 @@ public: * * @param s is the StructureNode that shall be added. * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. */ void addStructureNode(Handle<StructureNode> s, const std::string &fieldName = DEFAULT_FIELD_NAME); @@ -287,7 +287,7 @@ public: * * @param ss are the StructureNodes that shall be added. * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. */ void addStructureNodes(const std::vector<Handle<StructureNode>> &ss, const std::string &fieldName = DEFAULT_FIELD_NAME); @@ -298,7 +298,7 @@ public: * * @param s is the StructureNode that shall be removed. * @param fieldIdx is the index of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return true if this StructureNode was a child here and false if * if was not found. */ @@ -313,7 +313,7 @@ public: * * @param s is the StructureNode that shall be removed. * @param fieldName is the name of a field as specified in the - * FieldDescriptor in the Domain description. + * FieldDescriptor in the Ontology description. * @return true if this StructureNode was a child here and false if * if was not found. */ @@ -866,7 +866,7 @@ public: /** * A Document is mainly a wrapper for the Root structure node of the Document - * Graph. It also references the domains that have been used within this + * Graph. It also references the ontologies that have been used within this * document and the AnnotationEntities that span over Anchors in this Document. */ class Document : public RootNode { @@ -874,7 +874,7 @@ private: // TODO: Might there be several roots? E.g. metadata? Owned<StructuredEntity> root; NodeVector<AnnotationEntity> annotations; - NodeVector<Domain> domains; + NodeVector<Ontology> ontologies; NodeVector<Typesystem> typesystems; protected: @@ -893,7 +893,7 @@ public: Document(Manager &mgr, std::string name) : RootNode(mgr, std::move(name), nullptr), annotations(this), - domains(this), + ontologies(this), typesystems(this) { } @@ -987,30 +987,30 @@ public: std::string name = ""); /** - * Returns a const reference to the NodeVector of Domains that are used + * Returns a const reference to the NodeVector of ontologies that are used * within this Document. * - * @return a const reference to the NodeVector of Domains that are used + * @return a const reference to the NodeVector of ontologies that are used * within this Document. */ - const NodeVector<Domain> &getDomains() const { return domains; } + const NodeVector<Ontology> &getOntologys() const { return ontologies; } /** - * Adds a Domain reference to this Document. + * Adds a Ontology reference to this Document. */ - void referenceDomain(Handle<Domain> d) + void referenceOntology(Handle<Ontology> d) { invalidate(); - domains.push_back(d); + ontologies.push_back(d); } /** - * Adds multiple Domain references to this Document. + * Adds multiple Ontology references to this Document. */ - void referenceDomains(const std::vector<Handle<Domain>> &d) + void referenceOntologys(const std::vector<Handle<Ontology>> &d) { invalidate(); - domains.insert(domains.end(), d.begin(), d.end()); + ontologies.insert(ontologies.end(), d.begin(), d.end()); } /** diff --git a/src/core/model/Node.hpp b/src/core/model/Node.hpp index fe8db16..0567e67 100644 --- a/src/core/model/Node.hpp +++ b/src/core/model/Node.hpp @@ -88,7 +88,7 @@ struct ResolutionResult { /** * Root node of the subtree in which the node was found. This e.g. points to - * the Domain in which a Structure was defined or the Typesystem in which a + * the Ontology in which a Structure was defined or the Typesystem in which a * Type was defined. May be nullptr. */ Rooted<Node> resolutionRoot; @@ -119,7 +119,7 @@ class ResolutionState; /** * The Node class builds the base class for any Node within the DOM graph. A - * node may either be a descriptive node (such as a domain description etc.) + * node may either be a descriptive node (such as a ontology description etc.) * or a document element. Each node is identified by acharacteristic name and * a parent element. Note that the node name is not required to be unique. Nodes * without parent are considered root nodes. diff --git a/src/core/model/Domain.cpp b/src/core/model/Ontology.cpp index 587a382..3af727d 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Ontology.cpp @@ -24,7 +24,7 @@ #include <core/common/RttiBuilder.hpp> #include <core/common/Utils.hpp> -#include "Domain.hpp" +#include "Ontology.hpp" namespace ousia { @@ -485,9 +485,9 @@ bool Descriptor::doValidate(Logger &logger) const std::string("Descriptor \"") + getName() + "\" has no parent!", *this); valid = false; - } else if (!getParent()->isa(&RttiTypes::Domain)) { + } else if (!getParent()->isa(&RttiTypes::Ontology)) { logger.error(std::string("The parent of Descriptor \"") + getName() + - "\" is not a Domain!", + "\" is not a Ontology!", *this); valid = false; } @@ -768,10 +768,10 @@ std::vector<SyntaxDescriptor> Descriptor::getPermittedTokens() const /* Class StructuredClass */ StructuredClass::StructuredClass(Manager &mgr, std::string name, - Handle<Domain> domain, Variant cardinality, + Handle<Ontology> ontology, Variant cardinality, Handle<StructuredClass> superclass, bool transparent, bool root) - : Descriptor(mgr, std::move(name), domain), + : Descriptor(mgr, std::move(name), ontology), cardinality(cardinality), superclass(acquire(superclass)), subclasses(this), @@ -782,8 +782,8 @@ StructuredClass::StructuredClass(Manager &mgr, std::string name, if (superclass != nullptr) { superclass->addSubclass(this, logger); } - if (domain != nullptr) { - domain->addStructuredClass(this); + if (ontology != nullptr) { + ontology->addStructuredClass(this); } } @@ -949,27 +949,27 @@ NodeVector<FieldDescriptor> StructuredClass::getFieldDescriptors() const /* Class AnnotationClass */ AnnotationClass::AnnotationClass(Manager &mgr, std::string name, - Handle<Domain> domain) - : Descriptor(mgr, std::move(name), domain) + Handle<Ontology> ontology) + : Descriptor(mgr, std::move(name), ontology) { - if (domain != nullptr) { - domain->addAnnotationClass(this); + if (ontology != nullptr) { + ontology->addAnnotationClass(this); } } -/* Class Domain */ +/* Class Ontology */ -void Domain::doResolve(ResolutionState &state) +void Ontology::doResolve(ResolutionState &state) { continueResolveComposita(structuredClasses, structuredClasses.getIndex(), state); continueResolveComposita(annotationClasses, annotationClasses.getIndex(), state); continueResolveReferences(typesystems, state); - continueResolveReferences(domains, state); + continueResolveReferences(ontologies, state); } -bool Domain::doValidate(Logger &logger) const +bool Ontology::doValidate(Logger &logger) const { // check validity of name, of StructuredClasses, of AnnotationClasses and // TypeSystems. @@ -979,22 +979,22 @@ bool Domain::doValidate(Logger &logger) const continueValidationCheckDuplicates(typesystems, logger); } -void Domain::doReference(Handle<Node> node) +void Ontology::doReference(Handle<Node> node) { if (node->isa(&RttiTypes::Typesystem)) { referenceTypesystem(node.cast<Typesystem>()); } - if (node->isa(&RttiTypes::Domain)) { - referenceDomain(node.cast<Domain>()); + if (node->isa(&RttiTypes::Ontology)) { + referenceOntology(node.cast<Ontology>()); } } -RttiSet Domain::doGetReferenceTypes() const +RttiSet Ontology::doGetReferenceTypes() const { - return RttiSet{&RttiTypes::Domain, &RttiTypes::Typesystem}; + return RttiSet{&RttiTypes::Ontology, &RttiTypes::Typesystem}; } -void Domain::addStructuredClass(Handle<StructuredClass> s) +void Ontology::addStructuredClass(Handle<StructuredClass> s) { // only add it if we need to. if (structuredClasses.find(s) == structuredClasses.end()) { @@ -1005,13 +1005,13 @@ void Domain::addStructuredClass(Handle<StructuredClass> s) if (par != this) { if (par != nullptr) { // remove the StructuredClass from the old parent. - par.cast<Domain>()->removeStructuredClass(s); + par.cast<Ontology>()->removeStructuredClass(s); } s->setParent(this); } } -bool Domain::removeStructuredClass(Handle<StructuredClass> s) +bool Ontology::removeStructuredClass(Handle<StructuredClass> s) { auto it = structuredClasses.find(s); if (it != structuredClasses.end()) { @@ -1023,7 +1023,7 @@ bool Domain::removeStructuredClass(Handle<StructuredClass> s) return false; } -Rooted<StructuredClass> Domain::createStructuredClass( +Rooted<StructuredClass> Ontology::createStructuredClass( std::string name, Variant cardinality, Handle<StructuredClass> superclass, bool transparent, bool root) { @@ -1032,7 +1032,7 @@ Rooted<StructuredClass> Domain::createStructuredClass( std::move(transparent), std::move(root))}; } -void Domain::addAnnotationClass(Handle<AnnotationClass> a) +void Ontology::addAnnotationClass(Handle<AnnotationClass> a) { // only add it if we need to. if (annotationClasses.find(a) == annotationClasses.end()) { @@ -1043,13 +1043,13 @@ void Domain::addAnnotationClass(Handle<AnnotationClass> a) if (par != this) { if (par != nullptr) { // remove the StructuredClass from the old parent. - par.cast<Domain>()->removeAnnotationClass(a); + par.cast<Ontology>()->removeAnnotationClass(a); } a->setParent(this); } } -bool Domain::removeAnnotationClass(Handle<AnnotationClass> a) +bool Ontology::removeAnnotationClass(Handle<AnnotationClass> a) { auto it = annotationClasses.find(a); if (it != annotationClasses.end()) { @@ -1061,7 +1061,7 @@ bool Domain::removeAnnotationClass(Handle<AnnotationClass> a) return false; } -Rooted<AnnotationClass> Domain::createAnnotationClass(std::string name) +Rooted<AnnotationClass> Ontology::createAnnotationClass(std::string name) { return Rooted<AnnotationClass>{ new AnnotationClass(getManager(), std::move(name), this)}; @@ -1125,7 +1125,7 @@ const Rtti StructuredClass = .composedOf(&FieldDescriptor); const Rtti AnnotationClass = RttiBuilder<ousia::AnnotationClass>("AnnotationClass").parent(&Descriptor); -const Rtti Domain = RttiBuilder<ousia::Domain>("Domain") +const Rtti Ontology = RttiBuilder<ousia::Ontology>("Ontology") .parent(&RootNode) .composedOf({&StructuredClass, &AnnotationClass}); } diff --git a/src/core/model/Domain.hpp b/src/core/model/Ontology.hpp index e984ed9..d682bdf 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Ontology.hpp @@ -17,11 +17,12 @@ */ /** - * @file Domain.hpp + * @file Ontology.hpp * - * This header contains the class hierarchy of descriptor classes for domains. - * Properly connected instances of these classes with a Domain node as root - * describe a semantic Domain in a formal way. It specifies the allowed (tree) + * This header contains the class hierarchy of descriptor classes for + * ontologies. + * Properly connected instances of these classes with a Ontology node as root + * describe a semantic Ontology in a formal way. It specifies the allowed (tree) * structure of a document by means of StructuredClasses as well as the allowed * Annotations by means of AnnotationClasses. * @@ -33,7 +34,7 @@ * book and one for the actual structure. Consider the following XML: * * \code{.xml} - * <domain name="book"> + * <ontology name="book"> * <struct name="book" cardinality="1" isRoot="true"> * <field> * <childRef ref="book.chapter"/> @@ -65,7 +66,7 @@ * <struct name="text" transparent="true"> * <primitive type="string"/> * </struct> - * </domain> + * </ontology> * \endcode * * Note that we define one field as the TREE (meaning the main or default @@ -95,12 +96,12 @@ * the proper StructuredClass. This can be regulated by the "cardinality" * property of a StructuredClass. * - * It is possible to add further fields, like we would in the "headings" domain - * to add titles to our structure. + * It is possible to add further fields, like we would in the "headings" + * ontology to add titles to our structure. * * \code{.xml} - * <domain name="headings"> - * <import rel="domain" src="./book_domain.osxml"/> + * <ontology name="headings"> + * <import rel="ontology" src="./book_ontology.osxml"/> * <struct name="heading" cardinality="1" transparent="true"> * <parentRef ref="book.book"> * <field name="heading" isSubtree="true" optional="true"/> @@ -108,7 +109,7 @@ * ... * <fieldRef name="book.paragraph."> * </struct> - * </domain> + * </ontology> * \endcode * * This would change the context free grammar as follows: @@ -119,14 +120,14 @@ * \endcode * * AnnotationClasses on the other hand do not specify a context free grammar. - * They merely specify what kinds of Annotations are allowed within this domain - * and which fields or attributes they have. Note that Annotations are allowed - * to define structured children that manifest e.g. meta information of that - * Annotation. An example for that would be the "comment" domain: + * They merely specify what kinds of Annotations are allowed within this + * ontology and which fields or attributes they have. Note that Annotations are + * allowed to define structured children that manifest e.g. meta information of + * that Annotation. An example for that would be the "comment" ontology: * * \code{.xml} - * <domain name="comments"> - * <import rel="domain" src="./book_domain.osxml"/> + * <ontology name="comments"> + * <import rel="ontology" src="./book_ontology.osxml"/> * * <annotation name="comment"> * <field name="content" isSubtree="true"> @@ -156,7 +157,7 @@ * <childRef ref="reply"/> * </field> * </struct> - * </domain> + * </ontology> * \endcode * * Here we have comment annotations, which have a reply tree as sub structure. @@ -182,7 +183,7 @@ namespace ousia { class Rtti; class Descriptor; class StructuredClass; -class Domain; +class Ontology; /** * Magic field name used to identify the default field. The default field is @@ -451,6 +452,23 @@ public: NodeVector<FieldDescriptor> getDefaultFields() const; /** + * Returns the name of this FieldDescriptor or the default field name + * if the name is empty. + * + * @return the name of this FieldDescriptor or the default field name + * if the name is empty. + */ + std::string getNameOrDefaultName() + { + std::string name = getName(); + if (name.empty()) { + return DEFAULT_FIELD_NAME; + } else { + return std::move(name); + } + } + + /** * Returns a pointer to the start TokenDescriptor. This Token is used as a * signifier during parsing that an instance of this FieldDescriptor starts. * @@ -601,8 +619,8 @@ protected: bool doValidate(Logger &logger) const override; public: - Descriptor(Manager &mgr, std::string name, Handle<Domain> domain) - : Node(mgr, std::move(name), domain), + Descriptor(Manager &mgr, std::string name, Handle<Ontology> ontology) + : Node(mgr, std::move(name), ontology), attributesDescriptor(acquire(new StructType(mgr, "", nullptr))), fieldDescriptors(this) { @@ -610,10 +628,10 @@ public: /** * Returns a reference to the StructType that specifies the attribute keys - * as well as value domains for this Descriptor. + * as well as value ontologies for this Descriptor. * * @return a reference to the StructType that specifies the attribute keys - * as well as value domains for this Descriptor. + * as well as value ontologies for this Descriptor. */ Rooted<StructType> getAttributesDescriptor() const { @@ -765,7 +783,7 @@ public: /** * This tries to construct the shortest possible path of this Descriptor - * to the given child Descriptor. As an example consider the book domain + * to the given child Descriptor. As an example consider the book ontology * from above. * * First consider the call book->pathTo(chapter). This is an easy example: @@ -928,17 +946,17 @@ public: /** * A StructuredClass specifies nodes in the StructureTree of a document that - * implements this domain. For more information on the StructureTree please + * implements this ontology. For more information on the StructureTree please * consult the Header documentation above. * - * Note that a StructuredClass may "invade" an existing Domain description by + * Note that a StructuredClass may "invade" an existing Ontology description by * defining itself as a viable child in one existing field. Consider the - * example of the "heading" domain from the header documentation again: + * example of the "heading" ontology from the header documentation again: * * \code{.xml} - * <domain name="headings"> + * <ontology name="headings"> * <head> - * <import rel="domain" src="book.oxm"/> + * <import rel="ontology" src="book.oxm"/> * </head> * <structs> * <struct name="heading" cardinality="0-1" transparent="true"> @@ -952,14 +970,14 @@ public: * <fieldRef name="book.paragraph."> * </fields> * </structs> - * </domain> + * </ontology> * \endcode * - * The "parent" construct allows to "invade" another domain. + * The "parent" construct allows to "invade" another ontology. * - * This does indeed interfere with an existing domain and one must carefully + * This does indeed interfere with an existing ontology and one must carefully * craft such parent references to not create undesired side effects. However - * they provide the most convenient mechanism to extend existing domains + * they provide the most convenient mechanism to extend existing ontologies * without having to rewrite them. * * Another important factor is the 'transparent' flag. Transparent @@ -997,7 +1015,7 @@ public: * Inheritance therefore also goes for fields. */ class StructuredClass : public Descriptor { - friend Domain; + friend Ontology; private: const Variant cardinality; @@ -1024,7 +1042,7 @@ public: * * @param mgr is the current Manager. * @param name is the name of the StructuredClass. - * @param domain is the Domain this StructuredClass belongs + * @param ontology is the Ontology this StructuredClass belongs * to. * @param cardinality specifies how often an element of this type * may occur at a specific point in the @@ -1046,7 +1064,7 @@ public: * allowed to be at the root of a Document. */ StructuredClass(Manager &mgr, std::string name, - Handle<Domain> domain = nullptr, + Handle<Ontology> ontology = nullptr, Variant cardinality = Cardinality::any(), Handle<StructuredClass> superclass = nullptr, bool transparent = false, bool root = false); @@ -1216,7 +1234,7 @@ public: * This class has no special properties and is in essence just a Descriptor. */ class AnnotationClass : public Descriptor { - friend Domain; + friend Ontology; public: /** @@ -1227,18 +1245,19 @@ public: * @param name is a name for this AnnotationClass that will * be used for later references to this * AnnotationClass. - * @param domain is the Domain this AnnotationClass belongs + * @param ontology is the Ontology this AnnotationClass belongs * to. */ - AnnotationClass(Manager &mgr, std::string name, Handle<Domain> domain); + AnnotationClass(Manager &mgr, std::string name, Handle<Ontology> ontology); }; /** - * A Domain node specifies which StructuredClasses and which AnnotationClasses - * are part of this domain. TODO: Do we want to be able to restrict Annotations + * A Ontology node specifies which StructuredClasses and which AnnotationClasses + * are part of this ontology. TODO: Do we want to be able to restrict + * Annotations * to certain Structures? */ -class Domain : public RootNode { +class Ontology : public RootNode { friend StructuredClass; friend AnnotationClass; @@ -1246,7 +1265,7 @@ private: NodeVector<StructuredClass> structuredClasses; NodeVector<AnnotationClass> annotationClasses; NodeVector<Typesystem> typesystems; - NodeVector<Domain> domains; + NodeVector<Ontology> ontologies; protected: void doResolve(ResolutionState &state) override; @@ -1256,81 +1275,81 @@ protected: public: /** - * The constructor for a new domain. Note that this is an empty Domain and - * still has to be filled with StructuredClasses and AnnotationClasses. + * The constructor for a new ontology. Note that this is an empty Ontology + * and still has to be filled with StructuredClasses and AnnotationClasses. * * @param mgr is the Manager instance. - * @param name is a name for this domain which will be used for later - * references to this Domain. + * @param name is a name for this ontology which will be used for later + * references to this Ontology. */ - Domain(Manager &mgr, std::string name = "") + Ontology(Manager &mgr, std::string name = "") : RootNode(mgr, std::move(name), nullptr), structuredClasses(this), annotationClasses(this), typesystems(this), - domains(this) + ontologies(this) { } /** - * The constructor for a new domain. Note that this is an empty Domain and - * still has to be filled with StructuredClasses and AnnotationClasses. + * The constructor for a new ontology. Note that this is an empty Ontology + * and still has to be filled with StructuredClasses and AnnotationClasses. * * @param mgr is the Manager instance. * @param sys is the SystemTypesystem instance. - * @param name is a name for this domain which will be used for later - * references to this Domain. + * @param name is a name for this ontology which will be used for later + * references to this Ontology. */ - Domain(Manager &mgr, Handle<SystemTypesystem> sys, std::string name = "") - : Domain(mgr, std::move(name)) + Ontology(Manager &mgr, Handle<SystemTypesystem> sys, std::string name = "") + : Ontology(mgr, std::move(name)) { referenceTypesystem(sys); } /** - * Creates a new Domain and returns it. + * Creates a new Ontology and returns it. * * @param mgr is the Manager instance. - * @param name is a name for this domain which will be used for later - * references to this Domain. + * @param name is a name for this ontology which will be used for later + * references to this Ontology. */ - static Rooted<Domain> createEmptyDomain(Manager &mgr, std::string name) + static Rooted<Ontology> createEmptyOntology(Manager &mgr, std::string name) { - return Rooted<Domain>{new Domain(mgr, std::move(name))}; + return Rooted<Ontology>{new Ontology(mgr, std::move(name))}; } /** * Returns a const reference to the NodeVector of StructuredClasses that are - * part of this Domain. + * part of this Ontology. * * @return a const reference to the NodeVector of StructuredClasses that are - * part of this Domain. + * part of this Ontology. */ const NodeVector<StructuredClass> &getStructureClasses() const { return structuredClasses; } /** - * Adds a StructuredClass to this domain. This also sets the parent of the - * given StructuredClass if it is not set to this Domain already and removes - * it from the old Domain. + * Adds a StructuredClass to this ontology. This also sets the parent of the + * given StructuredClass if it is not set to this Ontology already and + * removes it from the old Ontology. * * @param s is some StructuredClass. */ void addStructuredClass(Handle<StructuredClass> s); /** - * Removes a StructuredClass from this domain. This also sets the parent of - * the given StructuredClass to null. + * Removes a StructuredClass from this ontology. This also sets the parent + * of the given StructuredClass to null. * * @param s is some StructuredClass. * @return true if the given StructuredClass was removed and false if this - * Domain did not have the given StructuredClass as child. + * Ontology did not have the given StructuredClass as child. */ bool removeStructuredClass(Handle<StructuredClass> s); /** - * This creates a new StructuredClass and appends it to this Domain. + * This creates a new StructuredClass and appends it to this Ontology. * * @param name is the name of the StructuredClass. * @param cardinality specifies how often an element of this type @@ -1361,36 +1380,36 @@ public: /** * Returns a const reference to the NodeVector of AnnotationClasses that are - * part of this Domain. + * part of this Ontology. * * @return a const reference to the NodeVector of AnnotationClasses that are - * part of this Domain. + * part of this Ontology. */ const NodeVector<AnnotationClass> &getAnnotationClasses() const { return annotationClasses; } /** - * Adds an AnnotationClass to this domain. This also sets the parent of the - * given AnnotationClass if it is not set to this Domain already and removes - * it from the old Domain. + * Adds an AnnotationClass to this ontology. This also sets the parent of + * the given AnnotationClass if it is not set to this Ontology already and + * removes it from the old Ontology. * * @param a is some AnnotationClass. */ void addAnnotationClass(Handle<AnnotationClass> a); /** - * Removes a AnnotationClass from this domain. This also sets the parent of - * the given AnnotationClass to null. + * Removes a AnnotationClass from this ontology. This also sets the parent + * of the given AnnotationClass to null. * * @param a is some AnnotationClass. * @return true if the given AnnotationClass was removed and false if this - * Domain did not have the given AnnotationClass as child. + * Ontology did not have the given AnnotationClass as child. */ bool removeAnnotationClass(Handle<AnnotationClass> a); /** - * This creates a new AnnotationClass and appends it to this Domain. + * This creates a new AnnotationClass and appends it to this Ontology. * * @param name is a name for this AnnotationClass that will * be used for later references to this @@ -1400,20 +1419,20 @@ public: /** * Returns a const reference to the NodeVector of TypeSystems that are - * references in this Domain. + * references in this Ontology. * * @return a const reference to the NodeVector of TypeSystems that are - * references in this Domain. + * references in this Ontology. */ const NodeVector<Typesystem> &getTypesystems() const { return typesystems; } /** - * Adds a Typesystem reference to this Domain. + * Adds a Typesystem reference to this Ontology. */ void referenceTypesystem(Handle<Typesystem> t) { typesystems.push_back(t); } /** - * Adds multiple Typesystem references to this Domain. + * Adds multiple Typesystem references to this Ontology. */ void referenceTypesystems(const std::vector<Handle<Typesystem>> &ts) { @@ -1421,16 +1440,16 @@ public: } /** - * Adds a Domain reference to this Domain. + * Adds a Ontology reference to this Ontology. */ - void referenceDomain(Handle<Domain> d) { domains.push_back(d); } + void referenceOntology(Handle<Ontology> d) { ontologies.push_back(d); } /** - * Adds multiple Domain references to this Domain. + * Adds multiple Ontology references to this Ontology. */ - void referenceDomains(const std::vector<Handle<Domain>> &ds) + void referenceOntologys(const std::vector<Handle<Ontology>> &ds) { - domains.insert(domains.end(), ds.begin(), ds.end()); + ontologies.insert(ontologies.end(), ds.begin(), ds.end()); } /** @@ -1447,8 +1466,8 @@ extern const Rtti FieldDescriptor; extern const Rtti Descriptor; extern const Rtti StructuredClass; extern const Rtti AnnotationClass; -extern const Rtti Domain; +extern const Rtti Ontology; } } -#endif /* _OUSIA_MODEL_DOMAIN_HPP_ */
\ No newline at end of file +#endif /* _OUSIA_MODEL_DOMAIN_HPP_ */ diff --git a/src/core/model/Project.cpp b/src/core/model/Project.cpp index f7dab8a..ecc0589 100644 --- a/src/core/model/Project.cpp +++ b/src/core/model/Project.cpp @@ -18,7 +18,7 @@ #include <core/common/RttiBuilder.hpp> -#include "Domain.hpp" +#include "Ontology.hpp" #include "Document.hpp" #include "Project.hpp" #include "Typesystem.hpp" @@ -69,9 +69,9 @@ Rooted<Document> Project::createDocument(const std::string &name) return document; } -Rooted<Domain> Project::createDomain(const std::string &name) +Rooted<Ontology> Project::createOntology(const std::string &name) { - return Rooted<Domain>{new Domain(getManager(), systemTypesystem, name)}; + return Rooted<Ontology>{new Ontology(getManager(), systemTypesystem, name)}; } void Project::referenceDocument(Handle<Document> document) diff --git a/src/core/model/Project.hpp b/src/core/model/Project.hpp index 480609c..97c711c 100644 --- a/src/core/model/Project.hpp +++ b/src/core/model/Project.hpp @@ -20,7 +20,7 @@ * @file Project.hpp * * Contains the concept of the "Project" class which represents the entity into - * which domains, documents, typesystems and other resources are embedded. + * which ontologies, documents, typesystems and other resources are embedded. * * @author Andreas Stöckel (astoecke@techfak.uni-bielefeld.de) */ @@ -40,12 +40,12 @@ class Registry; class SystemTypesystem; class Typesystem; class Document; -class Domain; +class Ontology; /** * The Project class constitutes the top-level node in which a collection of * documents are stored. It also contains an instance of the SystemTypesystem - * and allows for simple creation of new Typesystem and Domain instances. + * and allows for simple creation of new Typesystem and Ontology instances. */ class Project : public RootNode { private: @@ -99,12 +99,12 @@ public: Rooted<Document> createDocument(const std::string &name); /** - * Returns a new domain with the given name and adds it to the list of - * domains. Provides a reference of the system typesystem to the domain. + * Returns a new ontology with the given name and adds it to the list of + * ontologies. Provides a reference of the system typesystem to the ontology. * - * @param name is the name of the domain that should be created. + * @param name is the name of the ontology that should be created. */ - Rooted<Domain> createDomain(const std::string &name); + Rooted<Ontology> createOntology(const std::string &name); /** * Adds the given document to the list of documents in the project. diff --git a/src/core/model/RootNode.hpp b/src/core/model/RootNode.hpp index 173a6e4..d26917f 100644 --- a/src/core/model/RootNode.hpp +++ b/src/core/model/RootNode.hpp @@ -37,7 +37,7 @@ namespace ousia { /** * The RootNode class represents a Node that may be a Root node (such as - * Documents, Typesystems and Domains). Root nodes have the property, that the + * Documents, Typesystems and Ontologys). Root nodes have the property, that the * allow importing/referencing other Nodes. */ class RootNode : public Node { diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index dabb03c..c46dc51 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -19,7 +19,7 @@ #include <core/common/Exceptions.hpp> #include <core/common/Utils.hpp> #include <core/common/VariantWriter.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include <core/model/RootNode.hpp> diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp index e931d8d..26b9b6e 100644 --- a/src/core/parser/stack/DocumentHandler.cpp +++ b/src/core/parser/stack/DocumentHandler.cpp @@ -22,7 +22,7 @@ #include <core/common/Utils.hpp> #include <core/common/VariantReader.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Project.hpp> #include <core/model/Typesystem.hpp> #include <core/parser/utils/TokenizedData.hpp> @@ -234,7 +234,7 @@ bool DocumentChildHandler::startCommand(Variant::mapType &args) throw LoggableException( std::string("An instance of \"") + strct->getName() + "\" is not allowed as child of field \"" + - field->getName() + "\" of descriptor \"" + + field->getNameOrDefaultName() + "\" of descriptor \"" + parent->getDescriptor()->getName() + "\"", location()); } diff --git a/src/core/parser/stack/DocumentHandler.hpp b/src/core/parser/stack/DocumentHandler.hpp index d34c020..0e35558 100644 --- a/src/core/parser/stack/DocumentHandler.hpp +++ b/src/core/parser/stack/DocumentHandler.hpp @@ -46,7 +46,7 @@ namespace parser_stack { /** * The DocumentHandler class parses the "document" tag that is used to introduce * a new document. Note that this tag is not mandatory in osml files -- if the - * first command is not a typesystem, domain or any other declarative command, + * first command is not a typesystem, ontology or any other declarative command, * the DocumentHandler will be implicitly called. */ class DocumentHandler : public StaticHandler { diff --git a/src/core/parser/stack/GenericParserStates.cpp b/src/core/parser/stack/GenericParserStates.cpp index 69a6e0e..7287524 100644 --- a/src/core/parser/stack/GenericParserStates.cpp +++ b/src/core/parser/stack/GenericParserStates.cpp @@ -17,7 +17,7 @@ */ #include "DocumentHandler.hpp" -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "GenericParserStates.hpp" #include "ImportIncludeHandler.hpp" #include "TypesystemHandler.hpp" @@ -28,18 +28,18 @@ namespace parser_stack { const std::multimap<std::string, const State *> GenericParserStates{ {"document", &States::Document}, {"*", &States::DocumentChild}, - {"domain", &States::Domain}, - {"struct", &States::DomainStruct}, - {"annotation", &States::DomainAnnotation}, - {"attributes", &States::DomainAttributes}, - {"attribute", &States::DomainAttribute}, - {"field", &States::DomainField}, - {"fieldRef", &States::DomainFieldRef}, - {"primitive", &States::DomainStructPrimitive}, - {"childRef", &States::DomainStructChild}, - {"parentRef", &States::DomainStructParent}, - {"field", &States::DomainStructParentField}, - {"fieldRef", &States::DomainStructParentFieldRef}, + {"ontology", &States::Ontology}, + {"struct", &States::OntologyStruct}, + {"annotation", &States::OntologyAnnotation}, + {"attributes", &States::OntologyAttributes}, + {"attribute", &States::OntologyAttribute}, + {"field", &States::OntologyField}, + {"fieldRef", &States::OntologyFieldRef}, + {"primitive", &States::OntologyStructPrimitive}, + {"childRef", &States::OntologyStructChild}, + {"parentRef", &States::OntologyStructParent}, + {"field", &States::OntologyStructParentField}, + {"fieldRef", &States::OntologyStructParentFieldRef}, {"typesystem", &States::Typesystem}, {"enum", &States::TypesystemEnum}, {"entry", &States::TypesystemEnumEntry}, diff --git a/src/core/parser/stack/ImportIncludeHandler.cpp b/src/core/parser/stack/ImportIncludeHandler.cpp index d1ea97d..a6cbaea 100644 --- a/src/core/parser/stack/ImportIncludeHandler.cpp +++ b/src/core/parser/stack/ImportIncludeHandler.cpp @@ -20,7 +20,7 @@ #include <core/parser/ParserScope.hpp> #include <core/parser/ParserContext.hpp> -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "DocumentHandler.hpp" #include "ImportIncludeHandler.hpp" #include "State.hpp" @@ -38,7 +38,7 @@ void ImportHandler::doHandle(const Variant &fieldData, Variant::mapType &args) Rooted<Node> leaf = scope().getLeaf(); if (leaf == nullptr || !leaf->isa(&RttiTypes::RootNode)) { logger().error( - "Import not supported here, must be inside a document, domain " + "Import not supported here, must be inside a document, ontology " "or typesystem command.", location()); return; @@ -66,7 +66,7 @@ void IncludeHandler::doHandle(const Variant &fieldData, Variant::mapType &args) namespace States { const State Import = StateBuilder() - .parents({&Document, &Typesystem, &Domain}) + .parents({&Document, &Typesystem, &Ontology}) .elementHandler(ImportHandler::create) .arguments({Argument::String("rel", ""), Argument::String("type", ""), Argument::String("src", "")}); diff --git a/src/core/parser/stack/DomainHandler.cpp b/src/core/parser/stack/OntologyHandler.cpp index aef5b47..3b3b386 100644 --- a/src/core/parser/stack/DomainHandler.cpp +++ b/src/core/parser/stack/OntologyHandler.cpp @@ -18,52 +18,52 @@ #include <core/common/RttiBuilder.hpp> #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Project.hpp> #include <core/parser/ParserScope.hpp> #include <core/parser/ParserContext.hpp> #include "DocumentHandler.hpp" -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "State.hpp" #include "TypesystemHandler.hpp" namespace ousia { namespace parser_stack { -/* DomainHandler */ +/* OntologyHandler */ bool DomainHandler::startCommand(Variant::mapType &args) { - // Create the Domain node - Rooted<Domain> domain = - context().getProject()->createDomain(args["name"].asString()); - domain->setLocation(location()); + // Create the Ontology node + Rooted<Ontology> ontology = + context().getProject()->createOntology(args["name"].asString()); + ontology->setLocation(location()); - // If the domain is defined inside a document, add the reference to the + // If the ontology is defined inside a document, add the reference to the // document Rooted<Document> document = scope().select<Document>(); if (document != nullptr) { - document->reference(domain); + document->reference(ontology); } // Push the typesystem onto the scope, set the POST_HEAD flag to true - scope().push(domain); + scope().push(ontology); scope().setFlag(ParserFlag::POST_HEAD, false); return true; } -void DomainHandler::end() { scope().pop(logger()); } +void OntologyHandler::end() { scope().pop(logger()); } -/* DomainStructHandler */ +/* OntologyStructHandler */ -bool DomainStructHandler::startCommand(Variant::mapType &args) +bool OntologyStructHandler::start(Variant::mapType &args) { scope().setFlag(ParserFlag::POST_HEAD, true); - Rooted<Domain> domain = scope().selectOrThrow<Domain>(); + Rooted<Ontology> ontology = scope().selectOrThrow<Ontology>(); - Rooted<StructuredClass> structuredClass = domain->createStructuredClass( + Rooted<StructuredClass> structuredClass = ontology->createStructuredClass( args["name"].asString(), args["cardinality"].asCardinality(), nullptr, args["transparent"].asBool(), args["isRoot"].asBool()); structuredClass->setLocation(location()); @@ -85,28 +85,28 @@ bool DomainStructHandler::startCommand(Variant::mapType &args) return true; } -void DomainStructHandler::end() { scope().pop(logger()); } +void OntologyStructHandler::end() { scope().pop(logger()); } -/* DomainAnnotationHandler */ -bool DomainAnnotationHandler::startCommand(Variant::mapType &args) +/* OntologyAnnotationHandler */ +bool OntologyAnnotationHandler::start(Variant::mapType &args) { scope().setFlag(ParserFlag::POST_HEAD, true); - Rooted<Domain> domain = scope().selectOrThrow<Domain>(); + Rooted<Ontology> ontology = scope().selectOrThrow<Ontology>(); Rooted<AnnotationClass> annotationClass = - domain->createAnnotationClass(args["name"].asString()); + ontology->createAnnotationClass(args["name"].asString()); annotationClass->setLocation(location()); scope().push(annotationClass); return true; } -void DomainAnnotationHandler::end() { scope().pop(logger()); } +void OntologyAnnotationHandler::end() { scope().pop(logger()); } -/* DomainAttributesHandler */ +/* OntologyAttributesHandler */ -bool DomainAttributesHandler::startCommand(Variant::mapType &args) +bool OntologyAttributesHandler::start(Variant::mapType &args) { // Fetch the current typesystem and create the struct node Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>(); @@ -118,11 +118,11 @@ bool DomainAttributesHandler::startCommand(Variant::mapType &args) return true; } -void DomainAttributesHandler::end() { scope().pop(logger()); } +void OntologyAttributesHandler::end() { scope().pop(logger()); } -/* DomainFieldHandler */ +/* OntologyFieldHandler */ -bool DomainFieldHandler::startCommand(Variant::mapType &args) +bool OntologyFieldHandler::start(Variant::mapType &args) { FieldDescriptor::FieldType type; if (args["isSubtree"].asBool()) { @@ -148,11 +148,11 @@ bool DomainFieldHandler::startCommand(Variant::mapType &args) return true; } -void DomainFieldHandler::end() { scope().pop(logger()); } +void OntologyFieldHandler::end() { scope().pop(logger()); } -/* DomainFieldRefHandler */ +/* OntologyFieldRefHandler */ -bool DomainFieldRefHandler::startCommand(Variant::mapType &args) +bool OntologyFieldRefHandler::start(Variant::mapType &args) { Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>(); @@ -178,11 +178,11 @@ bool DomainFieldRefHandler::startCommand(Variant::mapType &args) return true; } -void DomainFieldRefHandler::end() {} +void OntologyFieldRefHandler::end() {} -/* DomainPrimitiveHandler */ +/* OntologyPrimitiveHandler */ -bool DomainPrimitiveHandler::startCommand(Variant::mapType &args) +bool OntologyPrimitiveHandler::start(Variant::mapType &args) { Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>(); @@ -206,7 +206,7 @@ bool DomainPrimitiveHandler::startCommand(Variant::mapType &args) } const std::string &type = args["type"].asString(); - scope().resolve<Type>(type, res.first, logger(), + scope().resolveType(type, res.first, logger(), [](Handle<Node> type, Handle<Node> field, Logger &logger) { if (type != nullptr) { @@ -218,11 +218,11 @@ bool DomainPrimitiveHandler::startCommand(Variant::mapType &args) return true; } -void DomainPrimitiveHandler::end() { scope().pop(logger()); } +void OntologyPrimitiveHandler::end() { scope().pop(logger()); } -/* DomainChildHandler */ +/* OntologyChildHandler */ -bool DomainChildHandler::startCommand(Variant::mapType &args) +bool OntologyChildHandler::start(Variant::mapType &args) { Rooted<FieldDescriptor> field = scope().selectOrThrow<FieldDescriptor>(); @@ -238,26 +238,26 @@ bool DomainChildHandler::startCommand(Variant::mapType &args) return true; } -/* DomainParentHandler */ +/* OntologyParentHandler */ -bool DomainParentHandler::startCommand(Variant::mapType &args) +bool OntologyParentHandler::start(Variant::mapType &args) { Rooted<StructuredClass> strct = scope().selectOrThrow<StructuredClass>(); - Rooted<DomainParent> parent{ - new DomainParent(strct->getManager(), args["ref"].asString(), strct)}; + Rooted<OntologyParent> parent{ + new OntologyParent(strct->getManager(), args["ref"].asString(), strct)}; parent->setLocation(location()); scope().push(parent); return true; } -void DomainParentHandler::end() { scope().pop(logger()); } +void OntologyParentHandler::end() { scope().pop(logger()); } -/* DomainParentFieldHandler */ +/* OntologyParentFieldHandler */ -bool DomainParentFieldHandler::startCommand(Variant::mapType &args) +bool OntologyParentFieldHandler::start(Variant::mapType &args) { - Rooted<DomainParent> parentNameNode = scope().selectOrThrow<DomainParent>(); + Rooted<OntologyParent> parentNameNode = scope().selectOrThrow<OntologyParent>(); FieldDescriptor::FieldType type; if (args["isSubtree"].asBool()) { type = FieldDescriptor::FieldType::SUBTREE; @@ -286,11 +286,11 @@ bool DomainParentFieldHandler::startCommand(Variant::mapType &args) return true; } -/* DomainParentFieldRefHandler */ +/* OntologyParentFieldRefHandler */ -bool DomainParentFieldRefHandler::startCommand(Variant::mapType &args) +bool OntologyParentFieldRefHandler::start(Variant::mapType &args) { - Rooted<DomainParent> parentNameNode = scope().selectOrThrow<DomainParent>(); + Rooted<OntologyParent> parentNameNode = scope().selectOrThrow<OntologyParent>(); const std::string &name = args["ref"].asString(); Rooted<StructuredClass> strct = @@ -317,100 +317,100 @@ bool DomainParentFieldRefHandler::startCommand(Variant::mapType &args) } namespace States { -const State Domain = StateBuilder() +const State Ontology = StateBuilder() .parents({&None, &Document}) - .createdNodeType(&RttiTypes::Domain) - .elementHandler(DomainHandler::create) + .createdNodeType(&RttiTypes::Ontology) + .elementHandler(OntologyHandler::create) .arguments({Argument::String("name")}); -const State DomainStruct = +const State OntologyStruct = StateBuilder() - .parent(&Domain) + .parent(&Ontology) .createdNodeType(&RttiTypes::StructuredClass) - .elementHandler(DomainStructHandler::create) + .elementHandler(OntologyStructHandler::create) .arguments({Argument::String("name"), Argument::Cardinality("cardinality", Cardinality::any()), Argument::Bool("isRoot", false), Argument::Bool("transparent", false), Argument::String("isa", "")}); -const State DomainAnnotation = +const State OntologyAnnotation = StateBuilder() - .parent(&Domain) + .parent(&Ontology) .createdNodeType(&RttiTypes::AnnotationClass) - .elementHandler(DomainAnnotationHandler::create) + .elementHandler(OntologyAnnotationHandler::create) .arguments({Argument::String("name")}); -const State DomainAttributes = +const State OntologyAttributes = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::StructType) - .elementHandler(DomainAttributesHandler::create) + .elementHandler(OntologyAttributesHandler::create) .arguments({}); -const State DomainAttribute = +const State OntologyAttribute = StateBuilder() - .parent(&DomainAttributes) + .parent(&OntologyAttributes) .elementHandler(TypesystemStructFieldHandler::create) .arguments({Argument::String("name"), Argument::String("type"), Argument::Any("default", Variant::fromObject(nullptr))}); -const State DomainField = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) +const State OntologyField = StateBuilder() + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainFieldHandler::create) + .elementHandler(OntologyFieldHandler::create) .arguments({Argument::String("name", ""), Argument::Bool("isSubtree", false), Argument::Bool("optional", false)}); -const State DomainFieldRef = +const State OntologyFieldRef = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainFieldRefHandler::create) + .elementHandler(OntologyFieldRefHandler::create) .arguments({Argument::String("ref", DEFAULT_FIELD_NAME)}); -const State DomainStructPrimitive = +const State OntologyStructPrimitive = StateBuilder() - .parents({&DomainStruct, &DomainAnnotation}) + .parents({&OntologyStruct, &OntologyAnnotation}) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainPrimitiveHandler::create) + .elementHandler(OntologyPrimitiveHandler::create) .arguments( {Argument::String("name", ""), Argument::Bool("isSubtree", false), Argument::Bool("optional", false), Argument::String("type")}); -const State DomainStructChild = StateBuilder() - .parent(&DomainField) - .elementHandler(DomainChildHandler::create) +const State OntologyStructChild = StateBuilder() + .parent(&OntologyField) + .elementHandler(OntologyChildHandler::create) .arguments({Argument::String("ref")}); -const State DomainStructParent = +const State OntologyStructParent = StateBuilder() - .parent(&DomainStruct) - .createdNodeType(&RttiTypes::DomainParent) - .elementHandler(DomainParentHandler::create) + .parent(&OntologyStruct) + .createdNodeType(&RttiTypes::OntologyParent) + .elementHandler(OntologyParentHandler::create) .arguments({Argument::String("ref")}); -const State DomainStructParentField = +const State OntologyStructParentField = StateBuilder() - .parent(&DomainStructParent) + .parent(&OntologyStructParent) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainParentFieldHandler::create) + .elementHandler(OntologyParentFieldHandler::create) .arguments({Argument::String("name", ""), Argument::Bool("isSubtree", false), Argument::Bool("optional", false)}); -const State DomainStructParentFieldRef = +const State OntologyStructParentFieldRef = StateBuilder() - .parent(&DomainStructParent) + .parent(&OntologyStructParent) .createdNodeType(&RttiTypes::FieldDescriptor) - .elementHandler(DomainParentFieldRefHandler::create) + .elementHandler(OntologyParentFieldRefHandler::create) .arguments({Argument::String("ref", DEFAULT_FIELD_NAME)}); } } namespace RttiTypes { -const Rtti DomainParent = RttiBuilder<ousia::parser_stack::DomainParent>( - "DomainParent").parent(&Node); +const Rtti OntologyParent = RttiBuilder<ousia::parser_stack::OntologyParent>( + "OntologyParent").parent(&Node); } } diff --git a/src/core/parser/stack/DomainHandler.hpp b/src/core/parser/stack/OntologyHandler.hpp index f12d863..66146bd 100644 --- a/src/core/parser/stack/DomainHandler.hpp +++ b/src/core/parser/stack/OntologyHandler.hpp @@ -17,10 +17,10 @@ */ /** - * @file DomainHandler.hpp + * @file OntologyHandler.hpp * - * Contains the Handler classes used for parsing Domain descriptors. This - * includes the "domain" tag and all describing tags below the "domain" tag. + * Contains the Handler classes used for parsing Ontology descriptors. This + * includes the "ontology" tag and all describing tags below the "ontology" tag. * * @author Benjamin Paaßen (bpaassen@techfak.uni-bielefeld.de) */ @@ -42,7 +42,7 @@ namespace parser_stack { // TODO: Documentation -class DomainHandler : public StaticHandler { +class OntologyHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -51,11 +51,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainHandler{handlerData}; + return new OntologyHandler{handlerData}; } }; -class DomainStructHandler : public StaticHandler { +class OntologyStructHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -64,11 +64,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainStructHandler{handlerData}; + return new OntologyStructHandler{handlerData}; } }; -class DomainAnnotationHandler : public StaticHandler { +class OntologyAnnotationHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -77,11 +77,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainAnnotationHandler{handlerData}; + return new OntologyAnnotationHandler{handlerData}; } }; -class DomainAttributesHandler : public StaticHandler { +class OntologyAttributesHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -90,11 +90,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainAttributesHandler{handlerData}; + return new OntologyAttributesHandler{handlerData}; } }; -class DomainFieldHandler : public StaticHandler { +class OntologyFieldHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -103,11 +103,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainFieldHandler{handlerData}; + return new OntologyFieldHandler{handlerData}; } }; -class DomainFieldRefHandler : public StaticHandler { +class OntologyFieldRefHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -116,11 +116,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainFieldRefHandler{handlerData}; + return new OntologyFieldRefHandler{handlerData}; } }; -class DomainPrimitiveHandler : public StaticHandler { +class OntologyPrimitiveHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -129,11 +129,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainPrimitiveHandler{handlerData}; + return new OntologyPrimitiveHandler{handlerData}; } }; -class DomainChildHandler : public StaticHandler { +class OntologyChildHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -141,16 +141,16 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainChildHandler{handlerData}; + return new OntologyChildHandler{handlerData}; } }; -class DomainParent : public Node { +class OntologyParent : public Node { public: using Node::Node; }; -class DomainParentHandler : public StaticHandler { +class OntologyParentHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -159,11 +159,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainParentHandler{handlerData}; + return new OntologyParentHandler{handlerData}; } }; -class DomainParentFieldHandler : public StaticHandler { +class OntologyParentFieldHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -171,11 +171,11 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainParentFieldHandler{handlerData}; + return new OntologyParentFieldHandler{handlerData}; } }; -class DomainParentFieldRefHandler : public StaticHandler { +class OntologyParentFieldRefHandler : public StaticHandler { public: using StaticHandler::StaticHandler; @@ -183,75 +183,75 @@ public: static Handler *create(const HandlerData &handlerData) { - return new DomainParentFieldRefHandler{handlerData}; + return new OntologyParentFieldRefHandler{handlerData}; } }; namespace States { /** - * State representing a "domain" struct. + * State representing a "ontology" struct. */ -extern const State Domain; +extern const State Ontology; /** - * State representing a "struct" tag within a domain description. + * State representing a "struct" tag within a ontology description. */ -extern const State DomainStruct; +extern const State OntologyStruct; /** - * State representing an "annotation" tag within a domain description. + * State representing an "annotation" tag within a ontology description. */ -extern const State DomainAnnotation; +extern const State OntologyAnnotation; /** * State representing an "attributes" tag within a structure or annotation. */ -extern const State DomainAttributes; +extern const State OntologyAttributes; /** * State representing an "attribute" tag within the "attributes". */ -extern const State DomainAttribute; +extern const State OntologyAttribute; /** * State representing a "field" tag within a structure or annotation. */ -extern const State DomainField; +extern const State OntologyField; /** * State representing a "fieldref" tag within a structure or annotation. */ -extern const State DomainFieldRef; +extern const State OntologyFieldRef; /** * State representing a "primitive" tag within a structure or annotation. */ -extern const State DomainStructPrimitive; +extern const State OntologyStructPrimitive; /** * State representing a "child" tag within a structure or annotation. */ -extern const State DomainStructChild; +extern const State OntologyStructChild; /** * State representing a "parent" tag within a structure or annotation. */ -extern const State DomainStructParent; +extern const State OntologyStructParent; /** * State representing a "field" tag within a "parent" tag. */ -extern const State DomainStructParentField; +extern const State OntologyStructParentField; /** * State representing a "fieldRef" tag within a "parent" tag. */ -extern const State DomainStructParentFieldRef; +extern const State OntologyStructParentFieldRef; } } namespace RttiTypes { -extern const Rtti DomainParent; +extern const Rtti OntologyParent; } } #endif diff --git a/src/core/parser/stack/TypesystemHandler.cpp b/src/core/parser/stack/TypesystemHandler.cpp index 3fa641a..73bcf62 100644 --- a/src/core/parser/stack/TypesystemHandler.cpp +++ b/src/core/parser/stack/TypesystemHandler.cpp @@ -17,13 +17,13 @@ */ #include <core/model/Document.hpp> -#include <core/model/Domain.hpp> +#include <core/model/Ontology.hpp> #include <core/model/Typesystem.hpp> #include <core/parser/ParserScope.hpp> #include <core/parser/ParserContext.hpp> #include "DocumentHandler.hpp" -#include "DomainHandler.hpp" +#include "OntologyHandler.hpp" #include "State.hpp" #include "TypesystemHandler.hpp" @@ -39,12 +39,12 @@ bool TypesystemHandler::startCommand(Variant::mapType &args) context().getProject()->createTypesystem(args["name"].asString()); typesystem->setLocation(location()); - // If the typesystem is defined inside a domain, add a reference to the - // typesystem to the domain -- do the same with a document, if no domain + // If the typesystem is defined inside a ontology, add a reference to the + // typesystem to the ontology -- do the same with a document, if no ontology // is found - Rooted<Domain> domain = scope().select<Domain>(); - if (domain != nullptr) { - domain->reference(typesystem); + Rooted<Ontology> ontology = scope().select<Ontology>(); + if (ontology != nullptr) { + ontology->reference(typesystem); } else { Rooted<Document> document = scope().select<Document>(); if (document != nullptr) { @@ -190,7 +190,7 @@ bool TypesystemConstantHandler::startCommand(Variant::mapType &args) namespace States { const State Typesystem = StateBuilder() - .parents({&None, &Domain, &Document}) + .parents({&None, &Ontology, &Document}) .createdNodeType(&RttiTypes::Typesystem) .elementHandler(TypesystemHandler::create) .arguments({Argument::String("name", "")}); diff --git a/src/core/resource/Resource.cpp b/src/core/resource/Resource.cpp index 4b9e496..7bcaf88 100644 --- a/src/core/resource/Resource.cpp +++ b/src/core/resource/Resource.cpp @@ -42,7 +42,7 @@ static std::unordered_map<ResourceType, std::string, Utils::EnumHash> reverseMap static const std::unordered_map<std::string, ResourceType> NAME_RESOURCE_TYPE_MAP{{"document", ResourceType::DOCUMENT}, - {"domain", ResourceType::DOMAIN_DESC}, + {"ontology", ResourceType::ONTOLOGY}, {"typesystem", ResourceType::TYPESYSTEM}, {"attributes", ResourceType::ATTRIBUTES}, {"stylesheet", ResourceType::STYLESHEET}, diff --git a/src/core/resource/Resource.hpp b/src/core/resource/Resource.hpp index 63ed591..548a255 100644 --- a/src/core/resource/Resource.hpp +++ b/src/core/resource/Resource.hpp @@ -48,9 +48,9 @@ enum class ResourceType { UNKNOWN, /** - * The resource contains a domain description. + * The resource contains a ontology description. */ - DOMAIN_DESC, + ONTOLOGY, /** * The resource contains a typesystem description. diff --git a/src/core/resource/ResourceRequest.cpp b/src/core/resource/ResourceRequest.cpp index f01a324..3c01e6a 100644 --- a/src/core/resource/ResourceRequest.cpp +++ b/src/core/resource/ResourceRequest.cpp @@ -33,7 +33,7 @@ namespace ousia { namespace RttiTypes { extern const Rtti Document; -extern const Rtti Domain; +extern const Rtti Ontology; extern const Rtti Node; extern const Rtti Typesystem; } @@ -43,7 +43,7 @@ extern const Rtti Typesystem; */ static const std::unordered_map<const Rtti *, ResourceType> RTTI_RESOURCE_TYPE_MAP{{&RttiTypes::Document, ResourceType::DOCUMENT}, - {&RttiTypes::Domain, ResourceType::DOMAIN_DESC}, + {&RttiTypes::Ontology, ResourceType::ONTOLOGY}, {&RttiTypes::Typesystem, ResourceType::TYPESYSTEM}}; /** diff --git a/src/formats/osml/OsmlParser.cpp b/src/formats/osml/OsmlParser.cpp index 36ef2b6..d169393 100644 --- a/src/formats/osml/OsmlParser.cpp +++ b/src/formats/osml/OsmlParser.cpp @@ -95,7 +95,7 @@ public: const std::string &cmd = parser.getCommandName().asString(); if (cmd != "typesystem" && cmd != "document" && - cmd != "domain") { + cmd != "ontology") { stack.commandStart("document", Variant::mapType{}, false); } diff --git a/src/plugins/filesystem/FileLocator.cpp b/src/plugins/filesystem/FileLocator.cpp index 2fd5483..994bbb9 100644 --- a/src/plugins/filesystem/FileLocator.cpp +++ b/src/plugins/filesystem/FileLocator.cpp @@ -103,8 +103,8 @@ void FileLocator::addDefaultSearchPaths(const std::string &relativeTo) // Add the search paths fs::path base{relativeTo}; addSearchPath(base.generic_string(), ResourceType::UNKNOWN); - addSearchPath((base / "domain").generic_string(), - ResourceType::DOMAIN_DESC); + addSearchPath((base / "ontology").generic_string(), + ResourceType::ONTOLOGY); addSearchPath((base / "typesystem").generic_string(), ResourceType::TYPESYSTEM); } diff --git a/src/plugins/filesystem/FileLocator.hpp b/src/plugins/filesystem/FileLocator.hpp index ad64db8..d1de6d0 100644 --- a/src/plugins/filesystem/FileLocator.hpp +++ b/src/plugins/filesystem/FileLocator.hpp @@ -116,7 +116,7 @@ public: * <li>The global application data directory used for make install * (default is /usr/local/share on UNIX)</li> * </ul> - * Resource type specific subdirectories (domain, typesytem, etc.) + * Resource type specific subdirectories (ontology, typesytem, etc.) * are automatically added to the aforementioned paths. */ void addDefaultSearchPaths(); diff --git a/src/plugins/html/DemoOutput.hpp b/src/plugins/html/DemoOutput.hpp index 4367202..b038a96 100644 --- a/src/plugins/html/DemoOutput.hpp +++ b/src/plugins/html/DemoOutput.hpp @@ -19,7 +19,7 @@ /** * @file DemoOutput.hpp * - * This implements a Demo HTML output for the following domains: + * This implements a Demo HTML output for the following ontologies: * * book * * headings * * emphasis @@ -67,18 +67,18 @@ public: * This writes a HTML representation of the given document to the given * output stream. Note that this method lacks the generality of our Ousia * approach with respect to two important points: - * 1.) It hardcodes the dependency to a certain set of domains in the C++ + * 1.) It hardcodes the dependency to a certain set of ontologies in the C++ * code. * 2.) It does not use the proposed pipeline of first copying the document * graph, then attaching style attributes and then transforming it to a * specific output format but does all of these steps at once. - * 3.) It does not use different transformers for the different domains but + * 3.) It does not use different transformers for the different ontologies but * does all transformations at once. * Therefore this is not an adequate model of our algorithms but only a * Demo. * * @param doc is a Document using concepts of the book, headings, - * emphasis and lists domains but no other. + * emphasis and lists ontologies but no other. * @param out is the output stream the data shall be written to. * @param pretty is a flag that manipulates whether newlines and tabs are * used. diff --git a/src/plugins/xml/XmlOutput.cpp b/src/plugins/xml/XmlOutput.cpp index ea1bc30..ffdecab 100644 --- a/src/plugins/xml/XmlOutput.cpp +++ b/src/plugins/xml/XmlOutput.cpp @@ -51,20 +51,19 @@ void XmlTransformer::writeXml(Handle<Document> doc, std::ostream &out, Manager &mgr = doc->getManager(); // the outermost tag is the document itself. Rooted<Element> document{new Element{mgr, {nullptr}, "document"}}; - // write imports for all referenced domains. - for (auto d : doc->getDomains()) { + // write imports for all referenced ontologies. + for (auto d : doc->getOntologys()) { Rooted<Element> import = - createImportElement(document, d, resourceManager, "domain"); + createImportElement(document, d, resourceManager, "ontology"); if (import != nullptr) { document->addChild(import); // add the import as namespace information to the document node as // well. document->getAttributes().emplace( - std::string("xmlns:") + d->getName(), - import->getAttributes()["src"]); + std::string("xmlns:") + d->getName(), d->getName()); } else { logger.warning(std::string( - "The location of domain \"" + d->getName() + + "The location of ontology \"" + d->getName() + "\" could not be retrieved using the given ResourceManager.")); } } @@ -200,7 +199,7 @@ Rooted<Element> XmlTransformer::transformStructuredEntity( Rooted<Element> elem{ new Element{mgr, parent, s->getDescriptor()->getName(), transformAttributes(s->getName(), s.get(), logger, pretty), - s->getDescriptor()->getParent().cast<Domain>()->getName()}}; + s->getDescriptor()->getParent().cast<Ontology>()->getName()}}; // then transform the children. transformChildren(s.get(), elem, logger, pretty); return elem; diff --git a/src/plugins/xml/XmlOutput.hpp b/src/plugins/xml/XmlOutput.hpp index da406a7..55c1c67 100644 --- a/src/plugins/xml/XmlOutput.hpp +++ b/src/plugins/xml/XmlOutput.hpp @@ -62,7 +62,7 @@ public: /** * This writes an XML serialization of the given document to the given * output stream. The serialization is equivalent to the input XML format, - * safe for the domain references. TODO: Can we change this? If so: how? + * safe for the ontology references. TODO: Can we change this? If so: how? * Note, though, that the serialization will not exploit transparency. * TODO: Can we change that? * @@ -70,7 +70,7 @@ public: * @param out is the output stream the XML serialization of the document * shall be written to. * @param logger is the logger errors shall be written to. - * @param resMgr is the ResourceManager to locate the domains and + * @param resMgr is the ResourceManager to locate the ontologies and * typesystems that were imported in this document. * @param pretty is a flag that manipulates whether newlines and tabs are * used. |