From 5fcdd424d7bd798673b1b545f7f990aba65471a9 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 16 Oct 2014 00:26:02 +0000 Subject: removed old code git-svn-id: file:///var/local/svn/basicwriter@57 daaaf23c-2e50-4459-9457-1e69db5a47bf --- src/core/model/RangeSet.hpp | 326 +++++++++++++++++++++++++++++++ src/core/script/Variant.cpp | 80 ++++++++ src/core/script/Variant.hpp | 274 ++++++++++++++++++++++++++ src/gui/components/GridTree.cpp | 95 --------- src/gui/components/GridTree.hpp | 232 ---------------------- src/gui/components/UIGrid.cpp | 81 -------- src/gui/components/UIGrid.hpp | 49 ----- src/gui/components/UIPaneFrame.cpp | 113 ----------- src/gui/components/UIPaneFrame.hpp | 50 ----- src/gui/framework/TileTreeNode.cpp | 115 ----------- src/gui/framework/TileTreeNode.hpp | 74 ------- src/gui/notepad.cpp | 19 -- src/gui/notepad.hpp | 17 -- src/model/GraphNode.cpp | 46 ----- src/model/GraphNode.hpp | 77 -------- src/model/RangeSet.hpp | 326 ------------------------------- src/model/document/Anchor.cpp | 28 --- src/model/document/Anchor.hpp | 36 ---- src/model/domain/Annotation.cpp | 30 --- src/model/domain/Annotation.hpp | 65 ------ src/model/domain/AnnotationCategory.hpp | 60 ------ src/model/domain/AnnotationReference.hpp | 66 ------- src/model/domain/Category.cpp | 19 -- src/model/domain/Category.hpp | 50 ----- src/model/domain/Class.cpp | 0 src/model/domain/Class.hpp | 99 ---------- src/model/domain/ClassCategory.hpp | 60 ------ src/model/domain/ClassReference.hpp | 66 ------- src/model/domain/ClassReferenceSet.cpp | 28 --- src/model/domain/ClassReferenceSet.hpp | 72 ------- src/model/domain/Domain.cpp | 27 --- src/model/domain/Domain.hpp | 81 -------- src/model/domain/Field.cpp | 29 --- src/model/domain/Field.hpp | 69 ------- src/model/domain/Layer.cpp | 27 --- src/model/domain/Layer.hpp | 60 ------ src/model/domain/Structure.cpp | 31 --- src/model/domain/Structure.hpp | 47 ----- src/model/types/Type.cpp | 29 --- src/model/types/Type.hpp | 31 --- src/model/types/Value.cpp | 29 --- src/model/types/Value.hpp | 31 --- src/xml/XmlAttributeHandler.hpp | 138 ------------- src/xml/XmlElementHandler.hpp | 146 -------------- src/xml/XmlReader.cpp | 155 --------------- src/xml/XmlReader.hpp | 87 --------- 46 files changed, 680 insertions(+), 2990 deletions(-) create mode 100644 src/core/model/RangeSet.hpp create mode 100644 src/core/script/Variant.cpp create mode 100644 src/core/script/Variant.hpp delete mode 100644 src/gui/components/GridTree.cpp delete mode 100644 src/gui/components/GridTree.hpp delete mode 100644 src/gui/components/UIGrid.cpp delete mode 100644 src/gui/components/UIGrid.hpp delete mode 100644 src/gui/components/UIPaneFrame.cpp delete mode 100644 src/gui/components/UIPaneFrame.hpp delete mode 100644 src/gui/framework/TileTreeNode.cpp delete mode 100644 src/gui/framework/TileTreeNode.hpp delete mode 100644 src/gui/notepad.cpp delete mode 100644 src/gui/notepad.hpp delete mode 100644 src/model/GraphNode.cpp delete mode 100644 src/model/GraphNode.hpp delete mode 100644 src/model/RangeSet.hpp delete mode 100644 src/model/document/Anchor.cpp delete mode 100644 src/model/document/Anchor.hpp delete mode 100644 src/model/domain/Annotation.cpp delete mode 100644 src/model/domain/Annotation.hpp delete mode 100644 src/model/domain/AnnotationCategory.hpp delete mode 100644 src/model/domain/AnnotationReference.hpp delete mode 100644 src/model/domain/Category.cpp delete mode 100644 src/model/domain/Category.hpp delete mode 100644 src/model/domain/Class.cpp delete mode 100644 src/model/domain/Class.hpp delete mode 100644 src/model/domain/ClassCategory.hpp delete mode 100644 src/model/domain/ClassReference.hpp delete mode 100644 src/model/domain/ClassReferenceSet.cpp delete mode 100644 src/model/domain/ClassReferenceSet.hpp delete mode 100644 src/model/domain/Domain.cpp delete mode 100644 src/model/domain/Domain.hpp delete mode 100644 src/model/domain/Field.cpp delete mode 100644 src/model/domain/Field.hpp delete mode 100644 src/model/domain/Layer.cpp delete mode 100644 src/model/domain/Layer.hpp delete mode 100644 src/model/domain/Structure.cpp delete mode 100644 src/model/domain/Structure.hpp delete mode 100644 src/model/types/Type.cpp delete mode 100644 src/model/types/Type.hpp delete mode 100644 src/model/types/Value.cpp delete mode 100644 src/model/types/Value.hpp delete mode 100644 src/xml/XmlAttributeHandler.hpp delete mode 100644 src/xml/XmlElementHandler.hpp delete mode 100644 src/xml/XmlReader.cpp delete mode 100644 src/xml/XmlReader.hpp (limited to 'src') diff --git a/src/core/model/RangeSet.hpp b/src/core/model/RangeSet.hpp new file mode 100644 index 0000000..ef86363 --- /dev/null +++ b/src/core/model/RangeSet.hpp @@ -0,0 +1,326 @@ +/* + 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 . +*/ + +#ifndef _OUSIA_MODEL_RANGE_SET_HPP_ +#define _OUSIA_MODEL_RANGE_SET_HPP_ + +#include +#include + +namespace ousia { +namespace model { +/** + * The Range structure represents an interval of numerical values of type T. + */ +template +struct Range { + /** + * Start is the start value of the range. + */ + T start; + + /** + * End is the end value of the range (inclusively). + */ + T end; + + /** + * Default constructor of the range class. The range is initialized as + * invalid, with start being set to the maximum possible value of the + * numerical type T, and end being set to the minimum possible value. + */ + Range() : + start(std::numeric_limits::max()), + end(std::numeric_limits::min()) + { + // Do nothing here + } + + /** + * Copies the given start and end value. The given values are not checked + * for validity. Use the "isValid" + * + * @param start is the minimum value the range still covers. + * @param end is the maximum value the range still covers. + */ + Range(const T &start, const T &end) : + start(start), end(end) + { + // Do nothing here + } + + /** + * Creates a range that covers exactly one element, namely the value given + * as parameter n. + */ + Range(const T &n) : + start(n), end(n) + { + // Do nothing here + } + + /** + * Returns true if this range is valid, e.g. its start value is smaller or + * equal to its end value. + * + * @return true if start is smaller or equal to end, false otherwise. + */ + bool isValid() const + { + return start <= end; + } + + /** + * Checks whether the given value lies inside the range. + * + * @param v is the value that is being checked. + * @return true if the value lies within the range, false otherwise. + */ + bool inRange(T v) const + { + return (v >= start) && (v <= end); + } + + /** + * Checks whether the given range overlapps with another range. Not that + * this check is only meaningful if both ranges are valid. + * + * @param r is the range that should be checked for overlapping with this + * range. + */ + bool overlapps(const Range &r) const + { + return (((r.start >= start) || (r.end >= start)) + && ((r.start <= end) || (r.end <= end))); + } + + /** + * Returns true if the two given ranges are neighbours (their limits only + * differ in the smallest representable difference between them). + */ + bool neighbours(const Range &r) const + { + constexpr T eps = std::numeric_limits::is_integer + ? 1 : std::numeric_limits::epsilon(); + return ((r.start > end) && ((r.start - eps) <= end)) + || ((r.end < start) && ((r.end + eps) >= start)); + } + + /** + * Checks whether the given range completely covers this range. + */ + bool coveredBy(const Range &r) const + { + return (r.start <= start) && (r.end >= end); + } + + /** + * Checks whether this range completely covers the given range. + */ + bool covers(const Range &r) const + { + return r.coveredBy(*this); + } + + /** + * Calculates the union of the two ranges -- not that this operation is only + * valid if the ranges overlapp. Use the RangeSet class if you cannot + * guarantee that. + */ + Range merge(const Range &r) const + { + return Range(std::min(start, r.start), std::max(end, r.end)); + } + + /** + * Returns a range that represents the spans the complete set defined by the + * given type T. + */ + static Range typeRange() + { + return Range(std::numeric_limits::min(), + std::numeric_limits::max()); + } + + /** + * Returns a range that represents the spans the complete set defined by the + * given type T up to a given value. + * + * @param till is the value up to which the range should be defined (till is + * included in the set). + */ + static Range typeRangeUntil(const T &till) + { + return Range(std::numeric_limits::min(), till); + } + + /** + * Returns a range that represents the spans the complete set defined by the + * given type T up to a given value. + * + * @param from is the value from which the range should be defined (from is + * included in the set). + */ + static Range typeRangeFrom(const T &from) + { + return Range(from, std::numeric_limits::max()); + } +}; + +/** + * RangeComp is a comperator used to order to sort the ranges within the + * ranges list. Sorts by the start element. + */ +template +struct RangeComp { + bool operator() (const Range& lhs, const Range& rhs) const + { + return lhs.start < rhs.start; + } +}; + +/** + * RangeSet represents a set of ranges of the given numerical type and is thus + * capable of representing any possible subset of the given numerical type T. + */ +template +class RangeSet { + +protected: + /** + * Set of ranges used internally. + */ + std::set, RangeComp> ranges; + + /** + * Returns an iterator to the first element in the ranges list that overlapps + * with the given range. + * + * @param r is the range for which the first overlapping element should be + * found. + * @return an iterator pointing to the first overlapping element or to the + * end of the list if no such element was found. + */ + typename std::set, RangeComp>::iterator firstOverlapping( + const Range &r, const bool allowNeighbours) + { + // Find the element with the next larger start value compared to the + // start value given in r. + auto it = ranges.upper_bound(r); + + // Go back one element + if (it != ranges.begin()) { + it--; + } + + // Iterate until an overlapping element is found + while (!(it->overlapps(r) || (allowNeighbours && it->neighbours(r))) + && (it != ranges.end())) { + it++; + } + return it; + } + +public: + /** + * Calculates the union of this range set and the given range. + * + * @param range is the range that should be merged into this range set. + */ + void merge(Range r) + { + // Calculate a new range that covers both the new range and all old + // ranges in the set -- delete all old elements on the way + auto it = firstOverlapping(r, true); + while ((it->overlapps(r) || it->neighbours(r)) && it != ranges.end()) { + r = r.merge(*it); + it = ranges.erase(it); + } + + // Insert the new range + ranges.insert(r); + } + + /** + * Calculates the union of this range set and the given range set. + * + * @param ranges is another range set for which the union with this set + * should be calculated. + */ + void merge(const RangeSet &s) + { + for (Range &r : s.ranges) { + merge(r); + } + } + + /** + * Checks whether this range set S contains the given range R: + * S u R = R + * (The intersection between R and S equals the given range) + * + * @param r is the range for which the containment should be checked. + * @return true if the above condition is met, false otherwise. + */ + bool contains(const Range &r) + { + auto it = firstOverlapping(r, false); + if (it != ranges.end()) { + return (*it).covers(r); + } + return false; + } + + /** + * Checks whether this range set S1 contains the given range set S2: + * + * @param s is the range for which the containment should be checked. + * @return true if the above condition is met, false otherwise. + */ + bool contains(const RangeSet &s) + { + bool res = true; + for (Range &r : s.ranges) { + res = res && contains(r); + } + return res; + } + + /** + * Empties the set. + */ + void clear() + { + ranges.clear(); + } + + /** + * Returns the current list of ranges as a const reference. + */ + const std::set, RangeComp>& getRanges() + { + return this->ranges; + } + +}; + +} +} + +#endif /* _OUSIA_MODEL_RANGE_SET_HPP_ */ + diff --git a/src/core/script/Variant.cpp b/src/core/script/Variant.cpp new file mode 100644 index 0000000..623b396 --- /dev/null +++ b/src/core/script/Variant.cpp @@ -0,0 +1,80 @@ +/* + Ousía + Copyright (C) 2014, 2015 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 . +*/ + +#include "Variant.hpp" + +namespace ousia { +namespace script { + +std::ostream& operator<< (std::ostream& os, const Variant &v) +{ + switch (v.type) { + case VariantType::none: + os << "null"; + break; + case VariantType::integer: + os << v.integerValue; + break; + case VariantType::number: + os << v.numberValue; + break; + case VariantType::string: + os << "\"" << v.stringValue << "\""; + break; + case VariantType::array: { + bool first = true; + os << "["; + for (auto &v2 : v.arrayValue) { + if (!first) { + os << ", "; + } + os << v2; + first = false; + } + os << "]"; + break; + } + case VariantType::map: { + bool first = true; + os << "{"; + for (auto &v2 : v.mapValue) { + if (!first) { + os << ", "; + } + os << "\"" << v2.first << "\": " << v2.second; + first = false; + } + os << "}"; + break; + } + case VariantType::function: + os << ""; + break; + case VariantType::object: + os << ""; + break; + case VariantType::buffer: + os << ""; + break; + } + return os; +} + +} +} + diff --git a/src/core/script/Variant.hpp b/src/core/script/Variant.hpp new file mode 100644 index 0000000..208bfa5 --- /dev/null +++ b/src/core/script/Variant.hpp @@ -0,0 +1,274 @@ +/* + Ousía + Copyright (C) 2014, 2015 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 . +*/ + +#ifndef _OUSIA_VARIANT_HPP_ +#define _OUSIA_VARIANT_HPP_ + +#include +#include +#include +#include +#include + +namespace ousia { +namespace script { + +/** + * Enum containing the possible types a variant may have. + */ +enum class VariantType { + none, integer, number, string, array, map, function, object, buffer +}; + +/** + * Instances of the Variant class represent any kind of data that is exchanged + * between the host application and the script engine. + */ +class Variant { + +private: + VariantType type; + + union { + int64_t integerValue; + double numberValue; + std::string stringValue; + std::vector arrayValue; + std::map mapValue; + }; + + /** + * Private function calling the destructor of the currently used union + * member. + */ + void free() { + // Explicitly call the destructor + switch (type) { + case VariantType::string: + stringValue.std::string::~string(); + break; + case VariantType::array: + arrayValue.std::vector::~vector(); + break; + case VariantType::map: + mapValue.std::map::~map(); + break; + default: + break; + } + + // Reset the type + type = VariantType::none; + } + + /** + * Function for copying the content of the given instance v to this + * instance. Callers must make sure the storage space has been freed + * beforehand. + */ + void copy(const Variant &v) + { + type = v.type; + switch (type) { + case VariantType::integer: + integerValue = v.integerValue; + break; + case VariantType::number: + numberValue = v.numberValue; + break; + case VariantType::string: + new (&stringValue) std::string(v.stringValue); + break; + case VariantType::array: + new (&arrayValue) std::vector(v.arrayValue); + break; + case VariantType::map: + new (&mapValue) std::map(v.mapValue); + break; + default: + break; + } + } + + /** + * Function for moving the content of the given instance v to this instance. + * No copy operation is used. Callers must make sure the storage space has + * been freed beforehand. + */ + void move(Variant &v) + { + type = v.type; + switch (type) { + case VariantType::integer: + integerValue = v.integerValue; + break; + case VariantType::number: + numberValue = v.numberValue; + break; + case VariantType::string: + new (&stringValue) std::string(std::move(v.stringValue)); + break; + case VariantType::array: + new (&arrayValue) std::vector(std::move(v.arrayValue)); + break; + case VariantType::map: + new (&mapValue) std::map(std::move(v.mapValue)); + break; + default: + break; + } + + // Reset the type of v to "none" + v.type = VariantType::none; + } + +public: + + class EBadEntry {}; + + Variant(const Variant &v) + { + copy(v); + } + + Variant(Variant &&v) + { + move(v); + } + + Variant& operator=(const Variant &v) + { + free(); + copy(v); + return *this; + } + + Variant& operator=(Variant &&v) + { + free(); + move(v); + return *this; + } + + + Variant(int64_t i) : + type(VariantType::integer), + integerValue(i) + { + // Do nothing here + } + + Variant(double d) : + type(VariantType::number), + numberValue(d) + { + // Do nothing here + } + + Variant(const char *s) : + type(VariantType::string) + { + new (&stringValue) std::string(s); + } + + Variant(const std::vector &a) : + type(VariantType::array) + { + new (&arrayValue) std::vector(a); + } + + + Variant(const std::map &m) : + type(VariantType::map) + { + new (&mapValue) std::map(m); + } + + ~Variant() + { + free(); + } + + VariantType getType() const + { + return type; + } + + int64_t getIntegerValue() const + { + switch (type) { + case VariantType::integer: + return integerValue; + case VariantType::number: + return static_cast(numberValue); + default: + throw EBadEntry{}; + } + } + + double getNumberValue() const + { + switch (type) { + case VariantType::integer: + return static_cast(integerValue); + case VariantType::number: + return numberValue; + default: + throw EBadEntry{}; + } + } + + std::string getStringValue() const + { + switch (type) { + case VariantType::string: + return stringValue; + default: + throw EBadEntry {}; + } + } + + const std::vector& getArrayValue() const + { + switch (type) { + case VariantType::array: + return arrayValue; + default: + throw EBadEntry {}; + } + } + + const std::map& getMapValue() const + { + switch (type) { + case VariantType::map: + return mapValue; + default: + throw EBadEntry {}; + } + } + + friend std::ostream& operator<< (std::ostream& os, const Variant &v); + +}; + +} +} + +#endif /* _OUSIA_VARIANT_HPP_ */ + diff --git a/src/gui/components/GridTree.cpp b/src/gui/components/GridTree.cpp deleted file mode 100644 index 000b859..0000000 --- a/src/gui/components/GridTree.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#include "GridTree.hpp" - -#include - -namespace uigrid { - -Splitter getSplitter(Orientation orientation, const Rect &r) -{ - switch (orientation) { - case Orientation::vert: - return Splitter(this, Rect(r.x1, r.y2 - ss, r.x2, r.y2), - orientation); - case Orientation::horz: - return Splitter(this, Rect(r.x1, r.y1, r.x2 - ss, r.y2 - ss), - orientation); - default: - return Rect(0, 0, 0, 0); - } -} - -void GridTreeNode::gatherBoundingBoxes(std::vector *areas, - std::vector *splitters, const Rect &r, - int splitterSize) -{ - const int ss = splitterSize; - const int h = r.h(); - const int w = r.w(); - - // If this node is a leaf, store the area of the frame and the splitter - // positions in the given lists and abort. - if (isLeaf()) { - if (areas) { - areas->push_back(FrameArea(this, r)); - } - if (splitters) { - splitters->push_back(getSplitter(Orientation::vert, r)); - splitters->push_back(getSplitter(Orientation::horz, r)); - } - return; - } - - // Recursively descend into the child nodes. Calculate the area the - // child nodes occupy. The last child should always occupy all remaining - // space in order to avoid gaps caused by rounding errors. - unsigned int i = 0; - switch (orientation) { - case Orientation::vert: { - int offsY = r.y1; - for (auto it = children.begin(); it != children.end(); - it++, i++) { - const int ch = (i == children.size() - 1) - ? r.y2 - offsY : h * (*it)->relativeSize; - (*it)->gatherBoundingBoxes(areas, splitters, - Rect::bounds(r.x1, offsY, w, ch), splitterSize); - offsY += ch; - } - } - break; - case Orientation::horz: { - int offsX = r.x1; - for (auto it = children.begin(); it != children.end(); - it++, i++) { - const int cw = (i == children.size() - 1) - ? r.x2 - offsX : w * (*it)->relativeSize; - (*it)->gatherBoundingBoxes(areas, splitters, - Rect::bounds(offsX, r.y1, cw, h), splitterSize); - offsX += cw; - } - } - break; - case Orientation::none: - break; - } -} - -} - diff --git a/src/gui/components/GridTree.hpp b/src/gui/components/GridTree.hpp deleted file mode 100644 index 1b0a52a..0000000 --- a/src/gui/components/GridTree.hpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#ifndef _GRID_TREE_H_ -#define _GRID_TREE_H_ - -#include -#include - -namespace uigrid { - -class GridTreeNode; - -enum class Orientation -{ - none, horz, vert -}; - -struct Rect -{ - int x1, y1, x2, y2; - - Rect(int x1, int y1, int x2, int y2) : - x1(x1), y1(y1), x2(x2), y2(y2) - { - // Do nothing here - } - - static Rect bounds(int x, int y, int w, int h) - { - return Rect(x, y, x + w, y + h); - } - - int w() const - { - return x2 - x1; - } - - int h() const - { - return y2 - y1; - } - -}; - -struct FrameArea -{ - GridTreeNode *node; - Rect r; - - FrameArea(GridTreeNode *node, const Rect &r) : - node(node), r(r) - { - // Do nothing here - } -}; - -struct Splitter -{ - GridTreeNode *node; - Rect r; - Orientation orientation; - - Splitter(GridTreeNode *node, const Rect &r, Orientation orientation) : - node(node), r(r), orientation(orientation) - { - // Do nothing here - } -}; - -class GridTreeNode -{ - -private: - Orientation orientation; - float relativeSize; - GridTreeNode *parent; - void *data; - - std::list children; - - void setParent(GridTreeNode *parent) - { - if (this->parent) { - this->parent->removeChild(this); - } - if (parent) { - parent->addChild(this); - } - this->parent = parent; - } - - void removeChild(GridTreeNode *node) - { - for (auto it = children.begin(); it != children.end();) { - if (*it == node) { - it = children.erase(it); - } else { - it++; - } - } - } - - void addChild(GridTreeNode *node) - { - children.push_back(node); - } - -public: - - /** - * Constructor of the GridTreeNode class. - * - * @param orientation describes the orientation of the children of - * this grid tree node. - * @param relativeSize contains the size of this node relative to the size - * of its parent node. The sum of the relativeSizes of all siblings has to - * be one. - * @param data is the data that should be attached to the node. - */ - GridTreeNode(Orientation orientation, float relativeSize = 1.0f, - GridTreeNode *parent = nullptr, void *data = nullptr) : - orientation(orientation), relativeSize(relativeSize), parent(nullptr), - data(data) - { - setParent(parent); - } - - ~GridTreeNode() - { - // Delete all children - for (auto c : children) { - delete c; - } - } - - /** - * Returns true if this element of the grid tree is a "leaf" (e.g. this - * element has no children). - * - * @return true if the grid element is a leaf node, false otherwise. - */ - bool isLeaf() const - { - return children.empty(); - } - - /** - * Returns true if this element is the root node (has no parent). - * - * @return true if this element is the root node, false otherwise. - */ - bool isRoot() const - { - return parent == nullptr; - } - - /** - * Sets the relative size of the node. - * - * @param relativeSize is the new relative size of the frame. Should be in - * an interval of [0, 1]. - */ - void setRelativeSize(float relativeSize) - { - this->relativeSize = relativeSize; - } - - /** - * Returns the current relative size of the node. - * - * @return the current relative size of the node. - */ - float getRelativeSize() - { - return relativeSize; - } - - /** - * Returns the data that was attached to this grid tree node. - * - * @return the data that was attached to this grid tree node. - */ - void* getData() - { - return data; - } - - /** - * Gathers the frame areas and the areas for which splitters should be - * drawn. - * - * @param areas is the list into which the frame area descriptors should be - * inserted. - * @param splitters is the list into which the splitter descriptors should - * be inserted. If nullptr is given, the list is not filled - * @param w is the width of the region for which the splitters should be - * gathered. - * @param h is the height of the region for which the splitters should be - * gathered. - */ - void gatherBoundingBoxes(std::vector *areas, - std::vector *splitters, const Rect &r, - int splitterSize); - - /** - * Returns the position of the splitter with the given orientation for this - * element. - */ - Rect getSplitterPosition(Orientation orientation, const Rect &r); - -}; - -} - -#endif /* _GRID_TREE_H_ */ - diff --git a/src/gui/components/UIGrid.cpp b/src/gui/components/UIGrid.cpp deleted file mode 100644 index 4d6f0e8..0000000 --- a/src/gui/components/UIGrid.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#include -#include -#include -#include - -#include "GridTree.hpp" - -#include "UIGrid.hpp" - -#include - -namespace uigrid { - -UIGrid::UIGrid(QWidget *parent) : - QWidget(parent) -{ - // Enable automatic ereasing of the background - setAutoFillBackground(true); - - // Create the root grid node. - rootGridNode = new GridTreeNode(Orientation::horz, 1.0); - - // Insert two new nodes into the tree - GridTreeNode *nd1 = new GridTreeNode(Orientation::vert, 0.25, rootGridNode); - GridTreeNode *nd2 = new GridTreeNode(Orientation::horz, 0.75, rootGridNode); - - // Add three nodes as children of the first node - new GridTreeNode(Orientation::horz, 0.33, nd1); - new GridTreeNode(Orientation::horz, 0.33, nd1); - new GridTreeNode(Orientation::horz, 0.33, nd1); - - new GridTreeNode(Orientation::vert, 0.75, nd2); - new GridTreeNode(Orientation::horz, 0.25, nd2); -} - -UIGrid::~UIGrid() -{ - delete rootGridNode; -} - -void UIGrid::paintEvent(QPaintEvent *event) -{ - const QPalette &palette = QApplication::palette(); - // Gather all splitter and frame area regions - std::vector splitters; - std::vector areas; - rootGridNode->gatherBoundingBoxes(&areas, &splitters, - Rect(0, 0, width(), height()), 5); - - QPainter painter(this); - - // Draw the splitters (first the background, then the dividing line) - painter.setPen(palette.mid().color()); - for (auto &c : splitters) { - QRect r(c.r.x1, c.r.y1, c.r.w(), c.r.h()); - painter.fillRect(r, palette.light()); - } - -} - - -} - diff --git a/src/gui/components/UIGrid.hpp b/src/gui/components/UIGrid.hpp deleted file mode 100644 index 14d161d..0000000 --- a/src/gui/components/UIGrid.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#ifndef _UI_GRID_H_ -#define _UI_GRID_H_ - -#include - -namespace uigrid { - -class GridTreeNode; - -class UIGrid : public QWidget -{ - Q_OBJECT - -private: - GridTreeNode *rootGridNode; - -protected: - virtual void paintEvent(QPaintEvent *event); - -public: - - UIGrid(QWidget *parent); - - ~UIGrid(); - -}; - -} - -#endif /* _UI_GRID_H_ */ - diff --git a/src/gui/components/UIPaneFrame.cpp b/src/gui/components/UIPaneFrame.cpp deleted file mode 100644 index 1192bad..0000000 --- a/src/gui/components/UIPaneFrame.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static void setWidgetColor(QWidget *w, const QColor c) -{ - QPalette p(w->palette()); - p.setColor(QPalette::Background, c); - w->setAutoFillBackground(true); - w->setPalette(p); -} - -UIPaneFrame::UIPaneFrame(QWidget *parent) : - QWidget(parent) -{ - // Create the layout components - rootLayout = new QVBoxLayout; - topLayout = new QHBoxLayout; - centerLayout = new QVBoxLayout; - bottomLayout = new QHBoxLayout; - - // Assemble the top bar -// QToolButton *btn = new QToolButton; -// btn->setIcon(QIcon::fromTheme("user-home")); - - QLabel *lbl = new QLabel("Dies ist nur ein Test"); - lbl->setContentsMargins(10, 0, 10, 0); - - QToolButton *btn2 = new QToolButton; - btn2->setIcon(QIcon::fromTheme("edit-find")); - - QToolButton *btn3 = new QToolButton; - btn3->setIcon(QIcon::fromTheme("window-new")); - -// topLayout->addWidget(btn); - topLayout->addWidget(lbl); - topLayout->addWidget(btn2); - topLayout->addWidget(btn3); - - QTreeView *tree = new QTreeView; - QFileSystemModel *model = new QFileSystemModel; - model->setRootPath(QDir::currentPath()); - tree->setModel(model); - centerLayout->addWidget(tree); - - // Remove the spacing of the layout components - removeLayoutSpacing(rootLayout); - removeLayoutSpacing(topLayout); - removeLayoutSpacing(centerLayout); - removeLayoutSpacing(bottomLayout); - - // Create the widget containers - topContainer = new QWidget; - centerContainer = new QWidget; - bottomContainer = new QWidget; - - // Assign the layouts to the top and bottom part, add the components to the - // root layout - topContainer->setLayout(topLayout); - topContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - - centerContainer->setLayout(centerLayout); - - bottomContainer->setLayout(bottomLayout); - topContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - - rootLayout->addWidget(topContainer, 0); - rootLayout->addWidget(centerContainer, 1); - rootLayout->addWidget(bottomContainer, 0); - - this->setLayout(rootLayout); -} - -UIPaneFrame::~UIPaneFrame() -{ - -} - -void UIPaneFrame::removeLayoutSpacing(QBoxLayout *layout) -{ - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); -} - diff --git a/src/gui/components/UIPaneFrame.hpp b/src/gui/components/UIPaneFrame.hpp deleted file mode 100644 index 32bbca7..0000000 --- a/src/gui/components/UIPaneFrame.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#ifndef _UI_PANE_FRAME_HPP_ -#define _UI_PANE_FRAME_HPP_ - -#include - -class QBoxLayout; -class QVBoxLayout; -class QHBoxLayout; - -class UIPaneFrame : public QWidget -{ - Q_OBJECT - -private: - QVBoxLayout *rootLayout; - QHBoxLayout *topLayout; - QVBoxLayout *centerLayout; - QHBoxLayout *bottomLayout; - QWidget *topContainer; - QWidget *centerContainer; - QWidget *bottomContainer; - - void removeLayoutSpacing(QBoxLayout *layout); - -public: - explicit UIPaneFrame(QWidget *parent = 0); - ~UIPaneFrame(); - -}; - -#endif /* _UI_PANE_FRAME_HPP_ */ - diff --git a/src/gui/framework/TileTreeNode.cpp b/src/gui/framework/TileTreeNode.cpp deleted file mode 100644 index 58abf65..0000000 --- a/src/gui/framework/TileTreeNode.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#include "TileTreeNode.hpp" - -namespace TiledUI { - -TileTreeNode::TileTreeNode() : - parent(nullptr); -{ - // Do nothing here -} - -TileTreeNode::TileTreeNode(TileTreeNode *parent) : - TileTreeNode() -{ - setParent(parent); -} - -TileTreeNode::~TileTreeNode() -{ - // Free the memory for all children - for (auto &c : children) { - delete c; - } -} - -void TileTreeNode::setParent(TileTreeNode *newParent) -{ - // Automatically remove this child from the old parent - if (parent) { - parent->removeChild(this); - } - - // Add this element to the new parent - if (newParent) { - newParent->addChild(this); - } - - // The current parent is the new parent - parent = newParent; -} - -bool TileTreeNode::removeChild(GridTreeNode *node, bool recursive) -{ - // Iterate of the current container and remove the given node - const int idx = indexOf(node); - if (indexOf(node) >= 0) { - children.erase(children.begin() + idx); - return true; - } - - // Descend into the tree if the recursive flag is set to true and the node - // was not yet found - if (recursive) { - for (auto &c : children) { - if (c.removeChild(node, true)) { - return true; - } - } - } - - return false; -} - -void TileTreeNode::addChild(TileTreeNode *child, int idx) -{ - // Make sure the given child is only inserted once into the tree - removeChild(child, true); - - // Insert the child at the given position, or at the end if idx < 0 - if (idx < 0) { - children.push_back(child); - } else { - children.insert(children.begin() + idx, child); - } -} - -int TileTreeNode::indexOf(TileTreeNode *child) -{ - int i = 0; - for (auto it = children.begin(); it != children.end(); it++, i++) { - if (*it == node) { - return i; - } - } - return -1; -} - -void TileTreeNode::parentWidget() -{ - if (parent) - { - return parent->parentWidget(); - } - return nullptr; -} - -} - diff --git a/src/gui/framework/TileTreeNode.hpp b/src/gui/framework/TileTreeNode.hpp deleted file mode 100644 index 07586e1..0000000 --- a/src/gui/framework/TileTreeNode.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - BasicWriter - 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 . -*/ - -#ifndef _TILE_TREE_NODE_HPP_ -#define _TILE_TREE_NODE_HPP_ - -#include -#include - -#include - -namespace TiledUI { - -class TileTreeNode { - -private: - TileTreeNode *parent; - std::list children; - -protected: - - void setParent(TileTreeNode *newParent); - - bool removeChild(TileTreeNode *child, bool recursive = false); - - void addChild(TileTreeNode *child, int idx = -1); - - int indexOf(TileTreeNode *child); - - virtual (); - -public: - - TileTreeNode(); - - TileTreeNode(TileTreeNode *parent); - - ~TileTreeNode(); - - virtual QSize minimumSize() const = 0; - - virtual QSize maximumSize() const = 0; - - virtual QRect geometry() const = 0; - - void resize(QSize size); - - void resize(int width, int height); - - virtual QWidget* parentWidget(); - - virtual void - -}; - -} - -#endif /* _TILE_TREE_NODE_HPP_ */ - diff --git a/src/gui/notepad.cpp b/src/gui/notepad.cpp deleted file mode 100644 index e7035f1..0000000 --- a/src/gui/notepad.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#include -//#include - -Notepad::Notepad(QWidget *parent) : - QMainWindow(parent) -{ - UIPaneFrame *frame = new UIPaneFrame(this); - this->setCentralWidget(frame); -// resize(1024, 768); -// uigrid::UIGrid *grid = new uigrid::UIGrid(this); -// setCentralWidget(grid); -} - -Notepad::~Notepad() -{ - -} diff --git a/src/gui/notepad.hpp b/src/gui/notepad.hpp deleted file mode 100644 index d5c713c..0000000 --- a/src/gui/notepad.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _NOTEPAD_H_ -#define _NOTEPAD_H_ - -#include - -class Notepad : public QMainWindow -{ - Q_OBJECT - -public: - explicit Notepad(QWidget *parent = 0); - ~Notepad(); - -}; - -#endif /* _NOTEPAD_H_ */ - diff --git a/src/model/GraphNode.cpp b/src/model/GraphNode.cpp deleted file mode 100644 index bfb8e63..0000000 --- a/src/model/GraphNode.cpp +++ /dev/null @@ -1,46 +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 . -*/ - -#include "GraphNode.hpp" - -#include -#include - -namespace ousia { -namespace model { - -GraphNode::GraphNode(GraphNodeType type, std::shared_ptr parent, - const std::string &name) : - type(type), parent(parent), name(name) -{ - // Do nothing here -} - -const std::string GraphNode::getFullyQualifiedName() -{ - if (parent) { - std::stringstream ss; - ss << parent->getFullyQualifiedName() << "." << name; - return ss.str(); - } - return name; -} - -} -} - diff --git a/src/model/GraphNode.hpp b/src/model/GraphNode.hpp deleted file mode 100644 index 73d26a0..0000000 --- a/src/model/GraphNode.hpp +++ /dev/null @@ -1,77 +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 . -*/ - -#ifndef _OUSIA_MODEL_GRAPH_NODE_HPP_ -#define _OUSIA_MODEL_GRAPH_NODE_HPP_ - -#include -#include - -namespace ousia { -namespace model { - -enum class GraphNodeType { - Domain, Class, Annotation, Structure, ClassCategory, AnnotationCategory -}; - -class GraphNode { - -private: - GraphNodeType type; - std::shared_ptr parent; - std::string name; - -protected: - GraphNode(GraphNodeType type, std::shared_ptr parent = nullptr, - const std::string &name = ""); - -public: - const std::string getFullyQualifiedName(); - - const std::string& getName() - { - return name; - } - - void setName(const std::string &name) - { - this->name = name; - } - - std::shared_ptr getParent() - { - return parent; - } - - void setParent(std::shared_ptr parent) - { - this->parent = parent; - } - - GraphNodeType getType() - { - return type; - } - -}; - -} -} - -#endif /* _OUSIA_MODEL_GRAPH_NODE_HPP_ */ - diff --git a/src/model/RangeSet.hpp b/src/model/RangeSet.hpp deleted file mode 100644 index ef86363..0000000 --- a/src/model/RangeSet.hpp +++ /dev/null @@ -1,326 +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 . -*/ - -#ifndef _OUSIA_MODEL_RANGE_SET_HPP_ -#define _OUSIA_MODEL_RANGE_SET_HPP_ - -#include -#include - -namespace ousia { -namespace model { -/** - * The Range structure represents an interval of numerical values of type T. - */ -template -struct Range { - /** - * Start is the start value of the range. - */ - T start; - - /** - * End is the end value of the range (inclusively). - */ - T end; - - /** - * Default constructor of the range class. The range is initialized as - * invalid, with start being set to the maximum possible value of the - * numerical type T, and end being set to the minimum possible value. - */ - Range() : - start(std::numeric_limits::max()), - end(std::numeric_limits::min()) - { - // Do nothing here - } - - /** - * Copies the given start and end value. The given values are not checked - * for validity. Use the "isValid" - * - * @param start is the minimum value the range still covers. - * @param end is the maximum value the range still covers. - */ - Range(const T &start, const T &end) : - start(start), end(end) - { - // Do nothing here - } - - /** - * Creates a range that covers exactly one element, namely the value given - * as parameter n. - */ - Range(const T &n) : - start(n), end(n) - { - // Do nothing here - } - - /** - * Returns true if this range is valid, e.g. its start value is smaller or - * equal to its end value. - * - * @return true if start is smaller or equal to end, false otherwise. - */ - bool isValid() const - { - return start <= end; - } - - /** - * Checks whether the given value lies inside the range. - * - * @param v is the value that is being checked. - * @return true if the value lies within the range, false otherwise. - */ - bool inRange(T v) const - { - return (v >= start) && (v <= end); - } - - /** - * Checks whether the given range overlapps with another range. Not that - * this check is only meaningful if both ranges are valid. - * - * @param r is the range that should be checked for overlapping with this - * range. - */ - bool overlapps(const Range &r) const - { - return (((r.start >= start) || (r.end >= start)) - && ((r.start <= end) || (r.end <= end))); - } - - /** - * Returns true if the two given ranges are neighbours (their limits only - * differ in the smallest representable difference between them). - */ - bool neighbours(const Range &r) const - { - constexpr T eps = std::numeric_limits::is_integer - ? 1 : std::numeric_limits::epsilon(); - return ((r.start > end) && ((r.start - eps) <= end)) - || ((r.end < start) && ((r.end + eps) >= start)); - } - - /** - * Checks whether the given range completely covers this range. - */ - bool coveredBy(const Range &r) const - { - return (r.start <= start) && (r.end >= end); - } - - /** - * Checks whether this range completely covers the given range. - */ - bool covers(const Range &r) const - { - return r.coveredBy(*this); - } - - /** - * Calculates the union of the two ranges -- not that this operation is only - * valid if the ranges overlapp. Use the RangeSet class if you cannot - * guarantee that. - */ - Range merge(const Range &r) const - { - return Range(std::min(start, r.start), std::max(end, r.end)); - } - - /** - * Returns a range that represents the spans the complete set defined by the - * given type T. - */ - static Range typeRange() - { - return Range(std::numeric_limits::min(), - std::numeric_limits::max()); - } - - /** - * Returns a range that represents the spans the complete set defined by the - * given type T up to a given value. - * - * @param till is the value up to which the range should be defined (till is - * included in the set). - */ - static Range typeRangeUntil(const T &till) - { - return Range(std::numeric_limits::min(), till); - } - - /** - * Returns a range that represents the spans the complete set defined by the - * given type T up to a given value. - * - * @param from is the value from which the range should be defined (from is - * included in the set). - */ - static Range typeRangeFrom(const T &from) - { - return Range(from, std::numeric_limits::max()); - } -}; - -/** - * RangeComp is a comperator used to order to sort the ranges within the - * ranges list. Sorts by the start element. - */ -template -struct RangeComp { - bool operator() (const Range& lhs, const Range& rhs) const - { - return lhs.start < rhs.start; - } -}; - -/** - * RangeSet represents a set of ranges of the given numerical type and is thus - * capable of representing any possible subset of the given numerical type T. - */ -template -class RangeSet { - -protected: - /** - * Set of ranges used internally. - */ - std::set, RangeComp> ranges; - - /** - * Returns an iterator to the first element in the ranges list that overlapps - * with the given range. - * - * @param r is the range for which the first overlapping element should be - * found. - * @return an iterator pointing to the first overlapping element or to the - * end of the list if no such element was found. - */ - typename std::set, RangeComp>::iterator firstOverlapping( - const Range &r, const bool allowNeighbours) - { - // Find the element with the next larger start value compared to the - // start value given in r. - auto it = ranges.upper_bound(r); - - // Go back one element - if (it != ranges.begin()) { - it--; - } - - // Iterate until an overlapping element is found - while (!(it->overlapps(r) || (allowNeighbours && it->neighbours(r))) - && (it != ranges.end())) { - it++; - } - return it; - } - -public: - /** - * Calculates the union of this range set and the given range. - * - * @param range is the range that should be merged into this range set. - */ - void merge(Range r) - { - // Calculate a new range that covers both the new range and all old - // ranges in the set -- delete all old elements on the way - auto it = firstOverlapping(r, true); - while ((it->overlapps(r) || it->neighbours(r)) && it != ranges.end()) { - r = r.merge(*it); - it = ranges.erase(it); - } - - // Insert the new range - ranges.insert(r); - } - - /** - * Calculates the union of this range set and the given range set. - * - * @param ranges is another range set for which the union with this set - * should be calculated. - */ - void merge(const RangeSet &s) - { - for (Range &r : s.ranges) { - merge(r); - } - } - - /** - * Checks whether this range set S contains the given range R: - * S u R = R - * (The intersection between R and S equals the given range) - * - * @param r is the range for which the containment should be checked. - * @return true if the above condition is met, false otherwise. - */ - bool contains(const Range &r) - { - auto it = firstOverlapping(r, false); - if (it != ranges.end()) { - return (*it).covers(r); - } - return false; - } - - /** - * Checks whether this range set S1 contains the given range set S2: - * - * @param s is the range for which the containment should be checked. - * @return true if the above condition is met, false otherwise. - */ - bool contains(const RangeSet &s) - { - bool res = true; - for (Range &r : s.ranges) { - res = res && contains(r); - } - return res; - } - - /** - * Empties the set. - */ - void clear() - { - ranges.clear(); - } - - /** - * Returns the current list of ranges as a const reference. - */ - const std::set, RangeComp>& getRanges() - { - return this->ranges; - } - -}; - -} -} - -#endif /* _OUSIA_MODEL_RANGE_SET_HPP_ */ - diff --git a/src/model/document/Anchor.cpp b/src/model/document/Anchor.cpp deleted file mode 100644 index e153161..0000000 --- a/src/model/document/Anchor.cpp +++ /dev/null @@ -1,28 +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 . -*/ - -#include - -namespace ousia { -namespace domain { - -//This class is fully specified by its header. - -} -} - diff --git a/src/model/document/Anchor.hpp b/src/model/document/Anchor.hpp deleted file mode 100644 index 66ff8eb..0000000 --- a/src/model/document/Anchor.hpp +++ /dev/null @@ -1,36 +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 . -*/ - -#ifndef _ANCHOR_HPP_ -#define _ANCHOR_HPP_ - -#include - -namespace ousia { -namespace domain { - -class Anchor : public GraphNode { - -public: - using GraphNode::GraphNode; - -}; -} -} - -#endif /* _ANCHOR_HPP_ */ diff --git a/src/model/domain/Annotation.cpp b/src/model/domain/Annotation.cpp deleted file mode 100644 index 42e6ce8..0000000 --- a/src/model/domain/Annotation.cpp +++ /dev/null @@ -1,30 +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 . -*/ - -#include - -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 deleted file mode 100644 index 0e84d1c..0000000 --- a/src/model/domain/Annotation.hpp +++ /dev/null @@ -1,65 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_ANNOTATION_HPP_ -#define _OUSIA_MODEL_DOMAIN_ANNOTATION_HPP_ - -#include -#include -#include - -#include -#include "Structure.hpp" -#include "Field.hpp" - -namespace ousia { -namespace model { -namespace domain { - -//class Structure; -//class Field; - -class Annotation : public GraphNode { - -private: - std::vector> structures; - std::vector> fields; - -public: - - Annotation(std::shared_ptr parent = nullptr, - const std::string &name = "") : - GraphNode(GraphNodeType::Annotation, parent, name) - { - // Do nothing here - } - - std::vector>& getStructures() - { - return structures; - } - - std::vector>& getFields() - { - return fields; - } -}; -} -} -} -#endif /* _OUSIA_MODEL_DOMAIN_ANNOTATION_HPP_ */ diff --git a/src/model/domain/AnnotationCategory.hpp b/src/model/domain/AnnotationCategory.hpp deleted file mode 100644 index 8ec6003..0000000 --- a/src/model/domain/AnnotationCategory.hpp +++ /dev/null @@ -1,60 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_ANNOTATIONCATEGORY_HPP_ -#define _OUSIA_MODEL_DOMAIN_ANNOTATIONCATEGORY_HPP_ - -#include -#include -#include - -#include - -#include "Annotation.hpp" - -namespace ousia { -namespace model { -namespace domain { - -class AnnotationCategory : public GraphNode { - -private: - std::vector> annotations; - -public: - - AnnotationCategory(std::shared_ptr parent = nullptr, - const std::string &name = "") : - GraphNode(GraphNodeType::AnnotationCategory, parent, name) - { - // Do nothing here - } - - std::vector>& getAnnotations() - { - return annotations; - } - -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_ANNOTATIONCATEGORY_HPP_ */ - diff --git a/src/model/domain/AnnotationReference.hpp b/src/model/domain/AnnotationReference.hpp deleted file mode 100644 index 873938e..0000000 --- a/src/model/domain/AnnotationReference.hpp +++ /dev/null @@ -1,66 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_ANNOTATIONREFERENCE_HPP_ -#define _OUSIA_MODEL_DOMAIN_ANNOTATIONREFERENCE_HPP_ - -#include - -namespace ousia { -namespace model { -namespace domain { - -/** - * A AnnotationReference is an expression resolvable to either a single - * annotation or any annotation in some given category (* expression). - */ -class AnnotationReference { - -private: - std::string domainName; - std::string categoryName; - /** - * The annotation name might also be "any". - */ - std::string className; - -public: - - const std::string& getDomainName() - { - return domainName; - } - - const std::string& getCategoryName() - { - return categoryName; - } - - const std::string& getClassName() - { - return className; - } - -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_ANNOTATIONREFERENCE_HPP_ */ - diff --git a/src/model/domain/Category.cpp b/src/model/domain/Category.cpp deleted file mode 100644 index c509285..0000000 --- a/src/model/domain/Category.cpp +++ /dev/null @@ -1,19 +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 . -*/ - - diff --git a/src/model/domain/Category.hpp b/src/model/domain/Category.hpp deleted file mode 100644 index 6255e6a..0000000 --- a/src/model/domain/Category.hpp +++ /dev/null @@ -1,50 +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 . -*/ - -#ifndef _CATEGORY_HPP_ -#define _CATEGORY_HPP_ - -#include -#include - -#include - -#include "Class.hpp" - -namespace ousia { -namespace domain { - -class Category : public GraphNode { - -private: - std::vector> classes; - -public: - - std::vector>& getClasses() - { - return classes; - } - -}; - -} -} - -#endif /* _CATEGORY_HPP_ */ - diff --git a/src/model/domain/Class.cpp b/src/model/domain/Class.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/model/domain/Class.hpp b/src/model/domain/Class.hpp deleted file mode 100644 index 6100214..0000000 --- a/src/model/domain/Class.hpp +++ /dev/null @@ -1,99 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_CLASS_HPP_ -#define _OUSIA_MODEL_DOMAIN_CLASS_HPP_ - -#include -#include -#include - -#include -#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> children; - std::vector> fields; - std::vector> layers; - -public: - - Class(std::shared_ptr 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>& getChildren() - { - return children; - } - - std::vector>& getFields() - { - return fields; - } - - /** - * Layers specify the annotations that are allowed upon instances of this - * class and its children. - */ - std::vector>& getLayers() - { - return layers; - } -}; -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_CLASS_HPP_ */ - diff --git a/src/model/domain/ClassCategory.hpp b/src/model/domain/ClassCategory.hpp deleted file mode 100644 index 2f60284..0000000 --- a/src/model/domain/ClassCategory.hpp +++ /dev/null @@ -1,60 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_CLASSCATEGORY_HPP_ -#define _OUSIA_MODEL_DOMAIN_CLASSCATEGORY_HPP_ - -#include -#include -#include - -#include - -#include "Class.hpp" - -namespace ousia { -namespace model { -namespace domain { - -class ClassCategory : public GraphNode { - -private: - std::vector> classes; - -public: - - ClassCategory(std::shared_ptr parent = nullptr, - const std::string &name = "") : - GraphNode(GraphNodeType::ClassCategory, parent, name) - { - // Do nothing here - } - - std::vector>& getClasses() - { - return classes; - } - -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_CLASSCATEGORY_HPP_ */ - diff --git a/src/model/domain/ClassReference.hpp b/src/model/domain/ClassReference.hpp deleted file mode 100644 index 807fd76..0000000 --- a/src/model/domain/ClassReference.hpp +++ /dev/null @@ -1,66 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_CLASSREFERENCE_HPP_ -#define _OUSIA_MODEL_DOMAIN_CLASSREFERENCE_HPP_ - -#include - -namespace ousia { -namespace model { -namespace domain { - -/** - * A ClassReference is an expression resolvable to either a single class or - * any class in some given category (* expression). - */ -class ClassReference { - -private: - std::string domainName; - std::string categoryName; - /** - * The class name might also be "any". - */ - std::string className; - -public: - - const std::string& getDomainName() - { - return domainName; - } - - const std::string& getCategoryName() - { - return categoryName; - } - - const std::string& getClassName() - { - return className; - } - -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_CLASSREFERENCE_HPP_ */ - diff --git a/src/model/domain/ClassReferenceSet.cpp b/src/model/domain/ClassReferenceSet.cpp deleted file mode 100644 index 14f57a2..0000000 --- a/src/model/domain/ClassReferenceSet.cpp +++ /dev/null @@ -1,28 +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 . -*/ -namespace ousia { -namespace model { -namespace domain { - - //For now this class is fully specified by its header. - -} -} -} - - diff --git a/src/model/domain/ClassReferenceSet.hpp b/src/model/domain/ClassReferenceSet.hpp deleted file mode 100644 index 61db014..0000000 --- a/src/model/domain/ClassReferenceSet.hpp +++ /dev/null @@ -1,72 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_CLASSREFERENCESET_HPP_ -#define _OUSIA_MODEL_DOMAIN_CLASSREFERENCESET_HPP_ - -#include "ClassReference.hpp" -#include - -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> conjunctions; - std::shared_ptr> 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>& getConjunctions() - { - return conjunctions; - } - - std::shared_ptr> getCardinality() - { - return cardinality; - } - - void setCardinality(std::shared_ptr>) - { - this->cardinality = cardinality; - } - -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_CLASSREFERENCESET_HPP_ */ - diff --git a/src/model/domain/Domain.cpp b/src/model/domain/Domain.cpp deleted file mode 100644 index 9b27e3a..0000000 --- a/src/model/domain/Domain.cpp +++ /dev/null @@ -1,27 +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 . -*/ - -#include "Domain.hpp" - -namespace ousia { -namespace model { -namespace domain { - -} -} -} diff --git a/src/model/domain/Domain.hpp b/src/model/domain/Domain.hpp deleted file mode 100644 index 278adc5..0000000 --- a/src/model/domain/Domain.hpp +++ /dev/null @@ -1,81 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_DOMAIN_HPP_ -#define _OUSIA_MODEL_DOMAIN_DOMAIN_HPP_ - -#include -#include -#include - -#include - -#include "Structure.hpp" -#include "ClassCategory.hpp" -#include "AnnotationCategory.hpp" -#include "ClassReferenceSet.hpp" - -namespace ousia { -namespace model { -namespace domain { - -class Domain : public GraphNode { - -private: - std::shared_ptr root; - std::vector> structures; - std::vector> classCategories; - std::vector> annotationCategories; - -public: - - Domain(std::shared_ptr parent = nullptr, - const std::string &name = "") : - GraphNode(GraphNodeType::Domain, parent, name) - { - // Do nothing here - } - - std::shared_ptr& getRoot() - { - return root; - } - - std::vector>& getStructures() - { - return structures; - } - - std::vector>& getClassCategories() - { - return classCategories; - } - - std::vector>& getAnnotationCategories() - { - return annotationCategories; - } - -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_DOMAIN_HPP_ */ - diff --git a/src/model/domain/Field.cpp b/src/model/domain/Field.cpp deleted file mode 100644 index af7f81e..0000000 --- a/src/model/domain/Field.cpp +++ /dev/null @@ -1,29 +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 . -*/ - -#include - -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 deleted file mode 100644 index 293a361..0000000 --- a/src/model/domain/Field.hpp +++ /dev/null @@ -1,69 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_FIELD_HPP_ -#define _OUSIA_MODEL_DOMAIN_FIELD_HPP_ - -#include - -#include -#include - -namespace ousia{ - -//namespace types { -// class Type; -// class Value; -//} -namespace model { -namespace domain { - -class Field : public GraphNode { - -private: - std::shared_ptr type; - bool optional; - -public: - using GraphNode::GraphNode; - - std::shared_ptr getType() - { - return type; - } - - void setType(std::shared_ptr type) - { - this->type = type; - } - - bool getOptional() - { - return optional; - } - - void setOptional(bool optional) - { - this->optional = optional; - } -}; -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_FIELD_HPP_ */ diff --git a/src/model/domain/Layer.cpp b/src/model/domain/Layer.cpp deleted file mode 100644 index fb22b4c..0000000 --- a/src/model/domain/Layer.cpp +++ /dev/null @@ -1,27 +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 . -*/ - -#include - -namespace ousia { -namespace domain { - - //This class is fully specified by its header. - -} -} diff --git a/src/model/domain/Layer.hpp b/src/model/domain/Layer.hpp deleted file mode 100644 index d419710..0000000 --- a/src/model/domain/Layer.hpp +++ /dev/null @@ -1,60 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_LAYER_HPP_ -#define _OUSIA_MODEL_DOMAIN_LAYER_HPP_ - -#include -#include - -#include "AnnotationReference.hpp" - -namespace ousia { -namespace model { -namespace domain { - -/** - * 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> conjunctions; - -public: - - /** - * 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>& getConjunctions() - { - return conjunctions; - } -}; - -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_LAYER_HPP_ */ - diff --git a/src/model/domain/Structure.cpp b/src/model/domain/Structure.cpp deleted file mode 100644 index f0f9d1e..0000000 --- a/src/model/domain/Structure.cpp +++ /dev/null @@ -1,31 +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 . -*/ - - -#include - -namespace ousia { -namespace model { -namespace domain { - - //This class for now has no special features that would distinguish it - //from an abstract GraphNode. - -} -} -} diff --git a/src/model/domain/Structure.hpp b/src/model/domain/Structure.hpp deleted file mode 100644 index 4f0604a..0000000 --- a/src/model/domain/Structure.hpp +++ /dev/null @@ -1,47 +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 . -*/ - -#ifndef _OUSIA_MODEL_DOMAIN_STRUCTURE_HPP_ -#define _OUSIA_MODEL_DOMAIN_STRUCTURE_HPP_ - -#include -#include - -#include - -namespace ousia { -namespace model { -namespace domain { - -class Structure : public GraphNode { - -public: - Structure(std::shared_ptr parent = nullptr, - const std::string &name = "") : - GraphNode(GraphNodeType::Structure, parent, name) - { - // Do nothing here - } - - -}; -} -} -} - -#endif /* _OUSIA_MODEL_DOMAIN_STRUCTURE_HPP_ */ diff --git a/src/model/types/Type.cpp b/src/model/types/Type.cpp deleted file mode 100644 index d219b61..0000000 --- a/src/model/types/Type.cpp +++ /dev/null @@ -1,29 +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 . -*/ - -#include -#include - -namespace ousia { -namespace types { - - -//TODO: THIS IS A DUMMY CLASS DECLARATION - -} -} diff --git a/src/model/types/Type.hpp b/src/model/types/Type.hpp deleted file mode 100644 index c4a9900..0000000 --- a/src/model/types/Type.hpp +++ /dev/null @@ -1,31 +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 . -*/ - -#ifndef _OUSIA_TYPES_TYPE_HPP_ -#define _OUSIA_TYPES_TYPE_HPP_ - -namespace ousia { -namespace types { - -class Type { - -//TODO: THIS IS A DUMMY CLASS DECLARATION -}; -} -} -#endif /* _OUSIA_TYPES_TYPE_HPP_ */ diff --git a/src/model/types/Value.cpp b/src/model/types/Value.cpp deleted file mode 100644 index 73d233a..0000000 --- a/src/model/types/Value.cpp +++ /dev/null @@ -1,29 +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 . -*/ - -#include -#include - -namespace ousia { -namespace types { - - -//TODO: THIS IS A DUMMY CLASS DECLARATION - -} -} diff --git a/src/model/types/Value.hpp b/src/model/types/Value.hpp deleted file mode 100644 index ec9f354..0000000 --- a/src/model/types/Value.hpp +++ /dev/null @@ -1,31 +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 . -*/ - -#ifndef _OUSIA_TYPES_VALUE_HPP_ -#define _OUSIA_TYPES_VALUE_HPP_ - -namespace ousia { -namespace types { - -class Value { - -//TODO: THIS IS A DUMMY CLASS DECLARATION -}; -} -} -#endif /* _OUSIA_TYPES_VALUE_HPP_ */ diff --git a/src/xml/XmlAttributeHandler.hpp b/src/xml/XmlAttributeHandler.hpp deleted file mode 100644 index 8fae6c3..0000000 --- a/src/xml/XmlAttributeHandler.hpp +++ /dev/null @@ -1,138 +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 . -*/ - -#ifndef _OUSIA_XML_XML_ATTRIBUTE_HANDLER_HPP_ -#define _OUSIA_XML_XML_ATTRIBUTE_HANDLER_HPP_ - -#include -#include - -namespace ousia { -namespace xml { - -/** - * The attribute handler class is responsible for handling attributes. It - * performs type checks and conversion. Note that the name of the attribute is - * not stored inside the handler, as the attribute handlers are meant to be used - * alongside a map. - */ -class XmlAttributeHandler { - -private: - /** - * Specifies whether this attribute was actually handled (set to true once - * the setter is called). - */ - bool handled; - - /** - * Specifies whether this attribute is required or not. - */ - bool required; - - /** - * Function which returns true if the given string is a valid entry for the - * type the attribute handler represents. - */ - std::function valid; - - /** - * Function which gets the attribute value and sets the type. - */ - std::function setter; - - /** - * Default value (as string) that should be used if no other value for that - * attribute is given. - */ - const char *defaultValue; - -public: - - /** - * Constructor of the XmlAttributeHandler class. - * - * @param required if true, the attribute is marked as "required" and it - * must occur in the xml. - * @param valid is a function reference which specifies whether the given - * string is valid. - * @param setter is the function that is meant to actually set the value - * of the attached class. - * @param defaultValue if given (it does not equal the nullptr), the setter - * is automatically called with the default value, unless the attribute is - * actually specified in the XML. - */ - XmlAttributeHandler(bool required, - const std::function &valid, - const std::function &setter, - const char *defaultValue = nullptr) : - handled(false), required(required), valid(valid), setter(setter), - defaultValue(defaultValue) - { - // Do nothing here - } - - /** - * Returns true if the given value for this attribute is valid. - */ - bool isValid(const std::string &value) - { - return valid(value); - } - - /** - * Calls the setter with the given value. The value should have been checked - * for validity first. - */ - void executeSettter(const std::string &value) - { - handled = true; - setter(value); - } - - /** - * Returns true if this element is required. - */ - bool isRequired() - { - return required; - } - - /** - * Returns the default value. - */ - const char* getDefaultValue() - { - return defaultValue; - } - - /** - * Returns true if the attribute was handled. - */ - bool isHandled() - { - return handled; - } - -}; - -} -} - -#endif /* _OUSIA_XML_XML_ATTRIBUTE_HANDLER_HPP_ */ - diff --git a/src/xml/XmlElementHandler.hpp b/src/xml/XmlElementHandler.hpp deleted file mode 100644 index 5d35b36..0000000 --- a/src/xml/XmlElementHandler.hpp +++ /dev/null @@ -1,146 +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 . -*/ - -#ifndef _OUSIA_XML_XML_ELEMENT_HANDLER_HPP_ -#define _OUSIA_XML_XML_ELEMENT_HANDLER_HPP_ - -#include - -namespace ousia { -namespace xml { - -/** - * Structure used internally for representing a function that is capable of - * handling a certain xml element tag. - */ -class XmlElementHandler { - -private: - /** - * Name of the XML element the handler is capable of handling. - */ - const char *name; - - /** - * Handler function. - */ - std::function handler; - - /** - * Counter that can be used in order to realize elements that may only - * appear a certain number of times. - */ - int count; - - /** - * Contains the current count of matches. Contains the maximum count a - * certain element must appear. If -1 the element may appear a unlimited - * number of times. - */ - int maxCount; - - /** - * A certain other handler this one depends on (the other element must have - * appeared at least once in order for this handler to match). If set to - * nullptr no requirement relationship is established. - */ - const XmlElementHandler *requiredElement; - -public: - - /** - * Constructor of the XmlElementHandler structure. - */ - XmlElementHandler(const char *name, const std::function &handler, - int maxCount = -1, const XmlElementHandler *requiredElement = nullptr) : - name(name), handler(handler), count(0), maxCount(maxCount), - requiredElement(requiredElement) - { - // Do nothing here - } - - /** - * Returns the name of the handler. - */ - const char* getName() const - { - return name; - } - - /** - * Returns true if this handler is currently valid. - */ - bool valid() const - { - return ((maxCount < 0) || (count < maxCount)) - && (!requiredElement || (requiredElement->count > 0)); - } - - /** - * Returns true if this handler matches the current state of the given - * QXmlStreamReader. - */ - template - bool matches(const StrType &tagName) const - { - return valid() && (tagName == name); - } - - /** - * Executes the given handler. - */ - bool execute() - { - count++; - return handler(); - } - - /** - * Function which assembles a string containing the names of the expected - * element types. Used for displaying error messages. - */ - static std::string expectedElementsStr(const std::vector &handlers) - { - // Calculate a list of valid element handlers - std::vector validHandlers; - for (auto &h : handlers) { - if (h.valid()) { - validHandlers.push_back(&h); - } - } - - // Assemble the string containing the list of expected elements - std::stringstream ss; - bool first = true; - for (auto &h : validHandlers) { - if (!first) { - ss << ", "; - } - ss << h->getName(); - first = false; - } - return ss.str(); - } - -}; - -} -} - -#endif /* _OUSIA_XML_XML_ELEMENT_HANDLER_HPP_ */ - diff --git a/src/xml/XmlReader.cpp b/src/xml/XmlReader.cpp deleted file mode 100644 index 06090d2..0000000 --- a/src/xml/XmlReader.cpp +++ /dev/null @@ -1,155 +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 . -*/ - -#include - -#include -#include -#include - -#include "XmlAttributeHandler.hpp" -#include "XmlElementHandler.hpp" -#include "XmlReader.hpp" - -namespace ousia { -namespace xml { - -XmlReader::XmlReader(QXmlStreamReader &xml) : - xml(xml) -{ - // Do nothing here -} - -bool XmlReader::expectOneOf(std::vector &handlers) -{ - // Skip all tokens except for "start element" and "end element" - while (!xml.atEnd()) { - // TODO: Implement mechanism for using the current state of the - // XmlStreamReader instead of always reading the next token? - const auto tokenType = xml.readNext(); - switch (tokenType) { - case QXmlStreamReader::StartElement: - for (auto &h : handlers) { - if (h.matches(xml.name())) { - return h.execute(); - } - } - // Expected tag was not found, display error message - // TODO: Use better logging mechanism! - std::cout << "Expected one of the following tags: (" - << XmlElementHandler::expectedElementsStr(handlers) - << "); but found element \"" - << xml.name().toString().toStdString() - << "\" instead!" << std::endl; - return false; - /* This is Benjamins noob way of handling things: We just ignore them. - case QXmlStreamReader::EndElement: - // Expected tag was not found, instead we found a closing tag! - // TODO: Use better logging mechanism! - std::cout << "Expected one of the following tags: (" - << XmlElementHandler::expectedElementsStr(handlers) - << "); but found end of element \"" - << xml.name().toString().toStdString() - << "\" instead!" << std::endl; - return false;*/ - default: - continue; - } - } - return false; -} - -bool XmlReader::parseArguments(std::map &handlers) -{ - // Iterate the attributes of the current xml node - for (auto &attr : xml.attributes()) { - // Convert the name to a std string - const std::string name = attr.name().toString().toStdString(); - const std::string value = attr.value().toString().toStdString(); - - // Try to fetch a corresponding attribute in the handlers map - auto it = handlers.find(name); - if (it != handlers.end()) { - XmlAttributeHandler &handler = (*it).second; - if (handler.isValid(value)) { - handler.executeSettter(value); - } else { - std::cout << "Invalid attribute value \"" << value - << "\" for attribute " << name << std::endl; - return false; - } - } else { - std::cout << "Unexpected attribute " << name << std::endl; - return false; - } - } - - // Iterate over all handlers to check whether all required handlers have - // been handled and in order to pass the default value to unhandled handlers - for (auto &it : handlers) { - // Fetch the name of the attribute and the handler - const std::string &name = it.first; - XmlAttributeHandler &handler = it.second; - if (!handler.isHandled()) { - if (handler.isRequired()) { - std::cout << "Attribute " << name - << " is required but was not set!" << std::endl; - return false; - } else if (handler.getDefaultValue()) { - handler.executeSettter(handler.getDefaultValue()); - } - } - } - - return true; -} - -std::shared_ptr XmlReader::process() -{ - std::shared_ptr res{nullptr}; - std::vector handlers{ - {"domain", [&](){return (res = this->readDomain()) != nullptr;}} - }; - if (!expectOneOf(handlers)) { - std::cout << "Errors occured while parsing XML file!" << std::endl; - return nullptr; - } - return res; -} - -std::shared_ptr XmlReader::readDomain() -{ - std::shared_ptr res{new model::domain::Domain()}; - std::map handlers{ - std::make_pair("name", XmlAttributeHandler( - true, - [&](const std::string& v) -> bool {return true;}, - [&](const std::string& v) -> void {res->setName(v);} - )) - }; - if (!parseArguments(handlers)) { - std::cout << "Errors while parsing arguments for domain node!" << std::endl; - return nullptr; - } - std::cout << res->getName() << std::endl; - return res; -} - -} -} - diff --git a/src/xml/XmlReader.hpp b/src/xml/XmlReader.hpp deleted file mode 100644 index f9b949b..0000000 --- a/src/xml/XmlReader.hpp +++ /dev/null @@ -1,87 +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 . -*/ - -#ifndef _OUSIA_XML_XML_READER_HPP_ -#define _OUSIA_XML_XML_READER_HPP_ - -#include -#include -#include -#include - -#include -#include - -class QXmlStreamReader; - -namespace ousia { -namespace xml { - -class XmlElementHandler; -class XmlAttributeHandler; - -/** - * The XmlReader class is responsible for parsing the ousia XML documents and - * deserializing them into the internal object representation. - */ -class XmlReader { - -private: - /** - * Reference to the QXmlStreamReader used for accessing the XML data on a - * token basis. - */ - QXmlStreamReader &xml; - - /** - * Parses a domain definition from the XML file. - */ - std::shared_ptr readDomain(); - - /** - * Used internally in order to conveniently expect one xml tag in a set of - * elements. Returns true if there was an error while waiting for the tag, - * false otherwise. - */ - bool expectOneOf(std::vector &handlers); - - /** - * Used internally to parse the current argument map. - */ - bool parseArguments(std::map &handlers); - -public: - - /** - * Instanciates the XMLReader class for the given instance of the - * QXMLStreamReader class. - */ - XmlReader(QXmlStreamReader &xml); - - /** - * Starts processing the xml and returns the generated graph node. - */ - std::shared_ptr process(); - -}; - -} -} - -#endif /* _OUSIA_XML_XML_READER_HPP_ */ - -- cgit v1.2.3