diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/GraphNode.hpp | 3 | ||||
| -rw-r--r-- | src/model/RangeSet.hpp | 1 | ||||
| -rw-r--r-- | src/model/domain/Annotation.cpp | 2 | ||||
| -rw-r--r-- | src/model/domain/Annotation.hpp | 46 | ||||
| -rw-r--r-- | src/model/domain/Class.hpp | 68 | ||||
| -rw-r--r-- | src/model/domain/ClassReferenceSet.hpp | 72 | ||||
| -rw-r--r-- | src/model/domain/ClassSet.hpp | 33 | ||||
| -rw-r--r-- | src/model/domain/Domain.cpp | 3 | ||||
| -rw-r--r-- | src/model/domain/Domain.hpp | 34 | ||||
| -rw-r--r-- | src/model/domain/Field.cpp | 2 | ||||
| -rw-r--r-- | src/model/domain/Field.hpp | 23 | ||||
| -rw-r--r-- | src/model/domain/Layer.hpp | 36 | ||||
| -rw-r--r-- | src/model/domain/Structure.cpp | 2 | ||||
| -rw-r--r-- | src/model/domain/Structure.hpp | 22 | ||||
| -rw-r--r-- | src/model/types/Type.hpp | 10 | ||||
| -rw-r--r-- | src/model/types/Value.hpp | 6 | 
16 files changed, 231 insertions, 132 deletions
diff --git a/src/model/GraphNode.hpp b/src/model/GraphNode.hpp index 8ce1a39..73d26a0 100644 --- a/src/model/GraphNode.hpp +++ b/src/model/GraphNode.hpp @@ -26,8 +26,7 @@ namespace ousia {  namespace model {  enum class GraphNodeType { -	None, Domain, Class, Annotation, Structure, ClassCategory, -	AnnotationCategory +	Domain, Class, Annotation, Structure, ClassCategory, AnnotationCategory  };  class GraphNode { diff --git a/src/model/RangeSet.hpp b/src/model/RangeSet.hpp index e6e60e0..ef86363 100644 --- a/src/model/RangeSet.hpp +++ b/src/model/RangeSet.hpp @@ -20,6 +20,7 @@  #define _OUSIA_MODEL_RANGE_SET_HPP_  #include <limits> +#include <set>  namespace ousia {  namespace model { diff --git a/src/model/domain/Annotation.cpp b/src/model/domain/Annotation.cpp index 8dabf5e..42e6ce8 100644 --- a/src/model/domain/Annotation.cpp +++ b/src/model/domain/Annotation.cpp @@ -19,10 +19,12 @@  #include <model/domain/Annotation.hpp>  namespace ousia { +namespace model {  namespace domain {  //This class is fully defined by its header.  }  } +} diff --git a/src/model/domain/Annotation.hpp b/src/model/domain/Annotation.hpp index 233b421..0e84d1c 100644 --- a/src/model/domain/Annotation.hpp +++ b/src/model/domain/Annotation.hpp @@ -16,22 +16,22 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _ANNOTATION_HPP_ -#define _ANNOTATION_HPP_ +#ifndef _OUSIA_MODEL_DOMAIN_ANNOTATION_HPP_ +#define _OUSIA_MODEL_DOMAIN_ANNOTATION_HPP_  #include <memory> +#include <string>  #include <vector>  #include <model/GraphNode.hpp> -#include <model/domain/Anchor.hpp> -#include <model/domain/Structure.hpp> -#include <model/domain/Field.hpp> +#include "Structure.hpp" +#include "Field.hpp"  namespace ousia { +namespace model {  namespace domain {  //class Structure; -//class Anchor;  //class Field;  class Annotation : public GraphNode { @@ -39,11 +39,15 @@ class Annotation : public GraphNode {  private:  	std::vector<std::shared_ptr<Structure>> structures;  	std::vector<std::shared_ptr<Field>> fields; -	std::shared_ptr<Anchor> start; -	std::shared_ptr<Anchor> end;  public: -	using GraphNode::GraphNode; + +	Annotation(std::shared_ptr<GraphNode> parent = nullptr, +			const std::string &name = "") : +		GraphNode(GraphNodeType::Annotation, parent, name) +	{ +		// Do nothing here +	}  	std::vector<std::shared_ptr<Structure>>& getStructures()  	{ @@ -54,28 +58,8 @@ public:  	{  		return fields;  	} - -	std::shared_ptr<Anchor> getStart() -	{ -		return start; -	} - -	void setStart(std::shared_ptr<Anchor> start) -	{ -		this->start = start; -	} - -	std::shared_ptr<Anchor> getEnd() -	{ -		return end; -	} - -	void setEnd(std::shared_ptr<Anchor> end) -	{ -		this->end = end; -	}  };  }  } - -#endif /* _ANNOTATION_HPP_ */ +} +#endif /* _OUSIA_MODEL_DOMAIN_ANNOTATION_HPP_ */ diff --git a/src/model/domain/Class.hpp b/src/model/domain/Class.hpp index 231bb80..6100214 100644 --- a/src/model/domain/Class.hpp +++ b/src/model/domain/Class.hpp @@ -16,26 +16,84 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _CLASS_HPP_ -#define _CLASS_HPP_ +#ifndef _OUSIA_MODEL_DOMAIN_CLASS_HPP_ +#define _OUSIA_MODEL_DOMAIN_CLASS_HPP_  #include <memory> +#include <string>  #include <vector>  #include <model/GraphNode.hpp> +#include "ClassReferenceSet.hpp" +#include "Field.hpp" +#include "Layer.hpp"  namespace ousia { +namespace model {  namespace domain { +/** + * A class represents some semantic concept in a given domain that has + * structural relevance, like headings in a text. Classes are usually expected + * to be in a "tree-esque" structure: It is not really a tree, but we still + * think about classes as nodes with children, even though children might be + * nodes higher up the tree, which leads to cycles. + */  class Class : public GraphNode {  private: -	std::vector<std::shared_ptr<Class>> children; -}; +	std::vector<std::shared_ptr<ClassReferenceSet>> children; +	std::vector<std::shared_ptr<Field>> fields; +	std::vector<std::shared_ptr<Layer>> layers; + +public: +	 +	Class(std::shared_ptr<GraphNode> parent = nullptr, +			const std::string &name = "") : +		GraphNode(GraphNodeType::Class, parent, name) +	{ +		// Do nothing here +	} + +	/** +	 * The children of a given class are not resolved on parsing time but lazily +	 * during document creation and validation time. This circumvents some +	 * problems we would have otherwise like: How do we treat the case that +	 * merging two domains adds more possible classes to some given category? +	 * How do we treat references to linked domains? +	 * +	 * Thus we do not specify the children that are allowed but a sequence of +	 * sets that define what set of classes is allowed at each point in the +	 * children sequence. Please note that each ClassReferenceSet also stores +	 * a cardinality, how many children, that are members of this set, have to +	 * exist. Therefore this construction can be interpreted as a quasi finite +	 * state automaton, e.g.: +	 * +	 * (class1|class2)* (class3){1,4} +	 */ +	std::vector<std::shared_ptr<ClassReferenceSet>>& getChildren() +	{ +		return children; +	} +	std::vector<std::shared_ptr<Field>>& getFields() +	{ +		return fields; +	} + +	/** +	 * Layers specify the annotations that are allowed upon instances of this +	 * class and its children. +	 */ +	std::vector<std::shared_ptr<Layer>>& getLayers() +	{ +		return layers; +	} +}; +}  }  } -#endif /* _CLASS_HPP_ */ +#endif /* _OUSIA_MODEL_DOMAIN_CLASS_HPP_ */ diff --git a/src/model/domain/ClassReferenceSet.hpp b/src/model/domain/ClassReferenceSet.hpp new file mode 100644 index 0000000..61db014 --- /dev/null +++ b/src/model/domain/ClassReferenceSet.hpp @@ -0,0 +1,72 @@ +/* +    Ousía +    Copyright (C) 2014  Benjamin Paaßen, Andreas Stöckel + +    This program is free software: you can redistribute it and/or modify +    it under the terms of the GNU General Public License as published by +    the Free Software Foundation, either version 3 of the License, or +    (at your option) any later version. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +    GNU General Public License for more details. + +    You should have received a copy of the GNU General Public License +    along with this program.  If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _OUSIA_MODEL_DOMAIN_CLASSREFERENCESET_HPP_ +#define _OUSIA_MODEL_DOMAIN_CLASSREFERENCESET_HPP_ + +#include "ClassReference.hpp" +#include <model/RangeSet.hpp> + +namespace ousia { +namespace model { +namespace domain { + +/** + * A ClassReferenceSet lazily defines references to classes that are allowed at + * this point of the domain description. It specifies a set in a twofold meaning: + * 1.) It defines the set of classes, that are allowed. + * 2.) It defines how many instances of those classes have to be instantiated + *		in a document that implements this domain standard (cardinality). + */ +class ClassReferenceSet { + +private: +	std::vector<std::shared_ptr<ClassReference>> conjunctions; +	std::shared_ptr<RangeSet<unsigned int>> cardinality; + +public: + +	/** +	 * This defines the conjunctions of references to classes that are allowed +	 * Please note that each ClassReference again does not have to reference to +	 * a single class but can also reference to multiple classes in a * +	 * expression. +	 */ +	std::vector<std::shared_ptr<ClassReference>>& getConjunctions() +	{ +		return conjunctions; +	} + +	std::shared_ptr<RangeSet<unsigned int>> getCardinality() +	{ +		return cardinality; +	} + +	void setCardinality(std::shared_ptr<RangeSet<unsigned int>>) +	{ +		this->cardinality = cardinality; +	} + +}; + +} +} +} + +#endif /* _OUSIA_MODEL_DOMAIN_CLASSREFERENCESET_HPP_ */ + diff --git a/src/model/domain/ClassSet.hpp b/src/model/domain/ClassSet.hpp deleted file mode 100644 index ebfe508..0000000 --- a/src/model/domain/ClassSet.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* -    Ousía -    Copyright (C) 2014  Benjamin Paaßen, Andreas Stöckel - -    This program is free software: you can redistribute it and/or modify -    it under the terms of the GNU General Public License as published by -    the Free Software Foundation, either version 3 of the License, or -    (at your option) any later version. - -    This program is distributed in the hope that it will be useful, -    but WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -    GNU General Public License for more details. - -    You should have received a copy of the GNU General Public License -    along with this program.  If not, see <http://www.gnu.org/licenses/>. -*/ - -namespace ousia { -namespace domain { - -#include "Class.hpp"; - -class ClassSet { - -private: -	std::vector<Class> classes; - -}; - -} -} - diff --git a/src/model/domain/Domain.cpp b/src/model/domain/Domain.cpp index 3def24b..9b27e3a 100644 --- a/src/model/domain/Domain.cpp +++ b/src/model/domain/Domain.cpp @@ -19,8 +19,9 @@  #include "Domain.hpp"  namespace ousia { +namespace model {  namespace domain {  }  } - +} diff --git a/src/model/domain/Domain.hpp b/src/model/domain/Domain.hpp index 957ae4a..278adc5 100644 --- a/src/model/domain/Domain.hpp +++ b/src/model/domain/Domain.hpp @@ -19,16 +19,16 @@  #ifndef _OUSIA_MODEL_DOMAIN_DOMAIN_HPP_  #define _OUSIA_MODEL_DOMAIN_DOMAIN_HPP_ -//#include <memory> -//#include <string> -//#include <vector> +#include <memory> +#include <string> +#include <vector>  #include <model/GraphNode.hpp> -//#include "Class.hpp" -//#include "Structure.hpp" -//#include "Category.hpp" -//#include "Layer.hpp" +#include "Structure.hpp" +#include "ClassCategory.hpp" +#include "AnnotationCategory.hpp" +#include "ClassReferenceSet.hpp"  namespace ousia {  namespace model { @@ -37,10 +37,10 @@ namespace domain {  class Domain : public GraphNode {  private: -//	std::shared_ptr<Class> root; -//	std::vector<std::shared_ptr<Structure>> structures; -//	std::vector<std::shared_ptr<Category>> categories; -//	std::vector<std::shared_ptr<Layer>> layers; +	std::shared_ptr<ClassReferenceSet> root; +	std::vector<std::shared_ptr<Structure>> structures; +	std::vector<std::shared_ptr<ClassCategory>> classCategories; +	std::vector<std::shared_ptr<AnnotationCategory>> annotationCategories;  public: @@ -51,7 +51,7 @@ public:  		// Do nothing here  	} -/*	std::shared_ptr<Class>& getRoot() +	std::shared_ptr<ClassReferenceSet>& getRoot()  	{  		return root;  	} @@ -61,15 +61,15 @@ public:  		return structures;  	} -	std::vector<std::shared_ptr<Category>>& getCategories() +	std::vector<std::shared_ptr<ClassCategory>>& getClassCategories()  	{ -		return categories; +		return classCategories;  	} -	std::vector<std::shared_ptr<Layer>>& getLayers() +	std::vector<std::shared_ptr<AnnotationCategory>>& getAnnotationCategories()  	{ -		return layers; -	}*/ +		return annotationCategories; +	}  }; diff --git a/src/model/domain/Field.cpp b/src/model/domain/Field.cpp index 4fd06a3..af7f81e 100644 --- a/src/model/domain/Field.cpp +++ b/src/model/domain/Field.cpp @@ -19,9 +19,11 @@  #include <model/domain/Field.hpp>  namespace ousia { +namespace model {  namespace domain {  	//This class is fully specified by its header.  }  } +} diff --git a/src/model/domain/Field.hpp b/src/model/domain/Field.hpp index d1944ee..293a361 100644 --- a/src/model/domain/Field.hpp +++ b/src/model/domain/Field.hpp @@ -16,29 +16,27 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _FIELD_HPP_ -#define _FIELD_HPP_ +#ifndef _OUSIA_MODEL_DOMAIN_FIELD_HPP_ +#define _OUSIA_MODEL_DOMAIN_FIELD_HPP_  #include <memory>  #include <model/GraphNode.hpp>  #include <model/types/Type.hpp> -#include <model/types/Value.hpp> -namespace ousia { +namespace ousia{  //namespace types {  //	class Type;  //	class Value;  //} - +namespace model {  namespace domain {  class Field : public GraphNode {  private:  	std::shared_ptr<types::Type> type; -	std::shared_ptr<types::Value> value;  	bool optional;  public: @@ -54,16 +52,6 @@ public:  		this->type = type;  	} -	std::shared_ptr<types::Value> getValue() -	{ -		return value; -	} - -	void setValue(std::shared_ptr<types::Value> value) -	{ -		this->value = value; -	} -  	bool getOptional()  	{  		return optional; @@ -76,5 +64,6 @@ public:  };  }  } +} -#endif /* _FIELD_HPP_ */ +#endif /* _OUSIA_MODEL_DOMAIN_FIELD_HPP_ */ diff --git a/src/model/domain/Layer.hpp b/src/model/domain/Layer.hpp index 5d609ca..898c54d 100644 --- a/src/model/domain/Layer.hpp +++ b/src/model/domain/Layer.hpp @@ -16,32 +16,42 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _LAYER_HPP_ -#define _LAYER_HPP_ +#ifndef _OUSIA_MODEL_DOMAIN_LAYER_HPP_ +#define _OUSIA_MODEL_DOMAIN_LAYER_HPP_ -#include <memory> -#include <vector> - -#include <model/GraphNode.hpp> -#include <model/domain/Annotation.hpp> +#include "AnnotationReference.hpp"  namespace ousia { +namespace model {  namespace domain { -class Layer : public GraphNode { +/** + * A Layer lazily defines references to annotations that are allowed upon + * certain classes. You can interpret a layer as a ClassReferenceSet minus the + * cardinality. + */ +class Layer {  private: -	std::vector<std::shared_ptr<Annotation>> annotations; +	std::vector<std::shared_ptr<AnnotationReference>> conjunctions;  public: -	using GraphNode::GraphNode; -	std::vector<std::shared_ptr<Annotation>>& getAnnotations() +	/** +	 * This defines the conjunctions of references to annotations that are allowed +	 * Please note that each AnnotationReference again does not have to reference to +	 * a single class but can also reference to multiple classes in a * +	 * expression. +	 */ +	std::vector<std::shared_ptr<AnnotationReference>>& getConjunctions()  	{ -		return annotations; +		return conjunctions;  	}  }; +  }  } +} + +#endif /* _OUSIA_MODEL_DOMAIN_LAYER_HPP_ */ -#endif /* _LAYER_HPP_ */ diff --git a/src/model/domain/Structure.cpp b/src/model/domain/Structure.cpp index fd9f3ce..f0f9d1e 100644 --- a/src/model/domain/Structure.cpp +++ b/src/model/domain/Structure.cpp @@ -20,6 +20,7 @@  #include <model/domain/Structure.hpp>  namespace ousia { +namespace model {  namespace domain {  	//This class for now has no special features that would distinguish it @@ -27,3 +28,4 @@ namespace domain {  }  } +} diff --git a/src/model/domain/Structure.hpp b/src/model/domain/Structure.hpp index 897b265..4f0604a 100644 --- a/src/model/domain/Structure.hpp +++ b/src/model/domain/Structure.hpp @@ -16,18 +16,32 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _STRUCTURE_HPP_ -#define _STRUCTURE_HPP_ +#ifndef _OUSIA_MODEL_DOMAIN_STRUCTURE_HPP_ +#define _OUSIA_MODEL_DOMAIN_STRUCTURE_HPP_ + +#include <memory> +#include <string>  #include <model/GraphNode.hpp>  namespace ousia { +namespace model {  namespace domain {  class Structure : public GraphNode { -	using GraphNode::GraphNode; + +public: +	Structure(std::shared_ptr<GraphNode> parent = nullptr, +			const std::string &name = "") : +		GraphNode(GraphNodeType::Structure, parent, name) +	{ +		// Do nothing here +	} + +  };  }  } +} -#endif /* _STRUCTURE_HPP_ */ +#endif /* _OUSIA_MODEL_DOMAIN_STRUCTURE_HPP_ */ diff --git a/src/model/types/Type.hpp b/src/model/types/Type.hpp index 155f898..c4a9900 100644 --- a/src/model/types/Type.hpp +++ b/src/model/types/Type.hpp @@ -16,18 +16,16 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _TYPE_HPP_ -#define _TYPE_HPP_ - -#include <model/GraphNode.hpp> +#ifndef _OUSIA_TYPES_TYPE_HPP_ +#define _OUSIA_TYPES_TYPE_HPP_  namespace ousia {  namespace types { -class Type : public GraphNode { +class Type {  //TODO: THIS IS A DUMMY CLASS DECLARATION  };  }  } -#endif /* _TYPE_HPP_ */ +#endif /* _OUSIA_TYPES_TYPE_HPP_ */ diff --git a/src/model/types/Value.hpp b/src/model/types/Value.hpp index 3076dd2..ec9f354 100644 --- a/src/model/types/Value.hpp +++ b/src/model/types/Value.hpp @@ -16,8 +16,8 @@      along with this program.  If not, see <http://www.gnu.org/licenses/>.  */ -#ifndef _VALUE_HPP_ -#define _VALUE_HPP_ +#ifndef _OUSIA_TYPES_VALUE_HPP_ +#define _OUSIA_TYPES_VALUE_HPP_  namespace ousia {  namespace types { @@ -28,4 +28,4 @@ class Value {  };  }  } -#endif /* _VALUE_HPP_ */ +#endif /* _OUSIA_TYPES_VALUE_HPP_ */  | 
