summaryrefslogtreecommitdiff
path: root/src/core/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/model')
-rw-r--r--src/core/model/Document.cpp32
-rw-r--r--src/core/model/Document.hpp14
-rw-r--r--src/core/model/Domain.cpp22
-rw-r--r--src/core/model/Domain.hpp10
-rw-r--r--src/core/model/Node.cpp7
-rw-r--r--src/core/model/Node.hpp2
-rw-r--r--src/core/model/Typesystem.cpp46
-rw-r--r--src/core/model/Typesystem.hpp50
8 files changed, 104 insertions, 79 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp
index b80cb5e..5ca257b 100644
--- a/src/core/model/Document.cpp
+++ b/src/core/model/Document.cpp
@@ -22,7 +22,7 @@
#include <set>
#include <core/common/Exceptions.hpp>
-#include <core/common/Rtti.hpp>
+#include <core/common/RttiBuilder.hpp>
namespace ousia {
namespace model {
@@ -409,20 +409,24 @@ bool Document::hasChild(Handle<StructureNode> s) const
/* Type registrations */
namespace RttiTypes {
-const Rtti<model::Document> Document =
- RttiBuilder("Document").parent(&Node).composedOf(
+const RttiType Document =
+ RttiBuilder<model::Document>("Document").parent(&Node).composedOf(
{&AnnotationEntity, &StructuredEntity});
-const Rtti<model::StructureNode> StructureNode =
- RttiBuilder("StructureNode").parent(&Node);
-const Rtti<model::StructuredEntity> StructuredEntity =
- RttiBuilder("StructuredEntity").parent(&StructureNode).composedOf(
- {&StructuredEntity, &DocumentPrimitive, &Anchor});
-const Rtti<model::DocumentPrimitive> DocumentPrimitive =
- RttiBuilder("DocumentPrimitive").parent(&StructureNode);
-const Rtti<model::Anchor> Anchor = RttiBuilder("Anchor").parent(&StructureNode);
-const Rtti<model::AnnotationEntity> AnnotationEntity =
- RttiBuilder("AnnotationEntity").parent(&Node).composedOf(
- {&StructuredEntity, &DocumentPrimitive, &Anchor});
+const RttiType StructureNode =
+ RttiBuilder<model::StructureNode>("StructureNode").parent(&Node);
+const RttiType StructuredEntity =
+ RttiBuilder<model::StructuredEntity>("StructuredEntity")
+ .parent(&StructureNode)
+ .composedOf({&StructuredEntity, &DocumentPrimitive, &Anchor});
+const RttiType DocumentPrimitive =
+ RttiBuilder<model::DocumentPrimitive>("DocumentPrimitive")
+ .parent(&StructureNode);
+const RttiType Anchor =
+ RttiBuilder<model::Anchor>("Anchor").parent(&StructureNode);
+const RttiType AnnotationEntity =
+ RttiBuilder<model::AnnotationEntity>("AnnotationEntity")
+ .parent(&Node)
+ .composedOf({&StructuredEntity, &DocumentPrimitive, &Anchor});
}
}
diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp
index 15d002c..80da260 100644
--- a/src/core/model/Document.hpp
+++ b/src/core/model/Document.hpp
@@ -644,13 +644,13 @@ public:
}
namespace RttiTypes {
-extern const Rtti<model::Document> Document;
-extern const Rtti<model::DocumentEntity> DocumentEntity;
-extern const Rtti<model::AnnotationEntity> AnnotationEntity;
-extern const Rtti<model::StructureNode> StructureNode;
-extern const Rtti<model::StructuredEntity> StructuredEntity;
-extern const Rtti<model::DocumentPrimitive> DocumentPrimitive;
-extern const Rtti<model::Anchor> Anchor;
+extern const RttiType Document;
+extern const RttiType DocumentEntity;
+extern const RttiType AnnotationEntity;
+extern const RttiType StructureNode;
+extern const RttiType StructuredEntity;
+extern const RttiType DocumentPrimitive;
+extern const RttiType Anchor;
}
}
diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp
index 9a0ed0d..6f50b1c 100644
--- a/src/core/model/Domain.cpp
+++ b/src/core/model/Domain.cpp
@@ -18,7 +18,7 @@
#include <set>
-#include <core/common/Rtti.hpp>
+#include <core/common/RttiBuilder.hpp>
#include <core/common/Exceptions.hpp>
#include "Domain.hpp"
@@ -279,17 +279,17 @@ void Domain::addAnnotationClass(Handle<AnnotationClass> a)
/* Type registrations */
namespace RttiTypes {
-const Rtti<model::FieldDescriptor> FieldDescriptor =
- RttiBuilder("FieldDescriptor").parent(&Node);
-const Rtti<model::Descriptor> Descriptor =
- RttiBuilder("Descriptor").parent(&Node);
-const Rtti<model::StructuredClass> StructuredClass =
- RttiBuilder("StructuredClass").parent(&Descriptor).composedOf(
+const RttiType FieldDescriptor =
+ RttiBuilder<model::FieldDescriptor>("FieldDescriptor").parent(&Node);
+const RttiType Descriptor =
+ RttiBuilder<model::Descriptor>("Descriptor").parent(&Node);
+const RttiType StructuredClass =
+ RttiBuilder<model::StructuredClass>("StructuredClass").parent(&Descriptor).composedOf(
&FieldDescriptor);
-const Rtti<model::AnnotationClass> AnnotationClass =
- RttiBuilder("AnnotationClass").parent(&Descriptor);
-const Rtti<model::Domain> Domain =
- RttiBuilder("Domain").parent(&Node).composedOf(
+const RttiType AnnotationClass =
+ RttiBuilder<model::AnnotationClass>("AnnotationClass").parent(&Descriptor);
+const RttiType Domain =
+ RttiBuilder<model::Domain>("Domain").parent(&Node).composedOf(
{&StructuredClass, &AnnotationClass});
}
}
diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp
index 16d1f8f..734447e 100644
--- a/src/core/model/Domain.hpp
+++ b/src/core/model/Domain.hpp
@@ -773,11 +773,11 @@ public:
namespace RttiTypes {
-extern const Rtti<model::FieldDescriptor> FieldDescriptor;
-extern const Rtti<model::Descriptor> Descriptor;
-extern const Rtti<model::StructuredClass> StructuredClass;
-extern const Rtti<model::AnnotationClass> AnnotationClass;
-extern const Rtti<model::Domain> Domain;
+extern const RttiType FieldDescriptor;
+extern const RttiType Descriptor;
+extern const RttiType StructuredClass;
+extern const RttiType AnnotationClass;
+extern const RttiType Domain;
}
}
diff --git a/src/core/model/Node.cpp b/src/core/model/Node.cpp
index 539924d..d069eee 100644
--- a/src/core/model/Node.cpp
+++ b/src/core/model/Node.cpp
@@ -21,8 +21,7 @@
#include <core/common/Exceptions.hpp>
#include <core/common/Logger.hpp>
-#include <core/common/Rtti.hpp>
-#include <core/common/TypedRttiBuilder.hpp>
+#include <core/common/RttiBuilder.hpp>
#include <core/common/Utils.hpp>
#include "Node.hpp"
@@ -438,8 +437,8 @@ bool Node::validate(Logger &logger) const
/* RTTI type registrations */
namespace RttiTypes {
-const Rtti<ousia::Node> Node =
- TypedRttiBuilder<ousia::Node>("Node")
+const RttiType Node =
+ RttiBuilder<ousia::Node>("Node")
.property("name", {RttiTypes::String,
{[](const ousia::Node *obj) {
return Variant::fromString(obj->getName());
diff --git a/src/core/model/Node.hpp b/src/core/model/Node.hpp
index d951310..4fc7672 100644
--- a/src/core/model/Node.hpp
+++ b/src/core/model/Node.hpp
@@ -575,7 +575,7 @@ namespace RttiTypes {
/**
* Typeinformation for the base "Node" class.
*/
-extern const Rtti<Node> Node;
+extern const RttiType Node;
}
}
diff --git a/src/core/model/Typesystem.cpp b/src/core/model/Typesystem.cpp
index 13bb38c..6daa7fe 100644
--- a/src/core/model/Typesystem.cpp
+++ b/src/core/model/Typesystem.cpp
@@ -18,7 +18,7 @@
#include "Typesystem.hpp"
-#include <core/common/Rtti.hpp>
+#include <core/common/RttiBuilder.hpp>
#include <core/common/Utils.hpp>
#include <core/common/VariantConverter.hpp>
@@ -526,6 +526,7 @@ void Typesystem::doResolve(ResolutionState &state)
{
continueResolveComposita(constants, constants.getIndex(), state);
continueResolveComposita(types, constants.getIndex(), state);
+ continueResolveReferences(typesystems, state);
}
bool Typesystem::doValidate(Logger &logger) const
@@ -542,6 +543,11 @@ Rooted<StructType> Typesystem::createStructType(const std::string &name)
return structType;
}
+void Typesystem::includeTypesystem(Handle<Typesystem> typesystem)
+{
+ typesystems.push_back(typesystem);
+}
+
/* Class SystemTypesystem */
SystemTypesystem::SystemTypesystem(Manager &mgr)
@@ -560,27 +566,27 @@ SystemTypesystem::SystemTypesystem(Manager &mgr)
/* RTTI type registrations */
namespace RttiTypes {
-const Rtti<model::Type> Type = RttiBuilder("Type").parent(&Node);
-const Rtti<model::StringType> StringType =
- RttiBuilder("StringType").parent(&Type);
-const Rtti<model::IntType> IntType = RttiBuilder("IntType").parent(&Type);
-const Rtti<model::DoubleType> DoubleType =
- RttiBuilder("DoubleType").parent(&Type);
-const Rtti<model::BoolType> BoolType = RttiBuilder("BoolType").parent(&Type);
-const Rtti<model::EnumType> EnumType = RttiBuilder("EnumType").parent(&Type);
-const Rtti<model::StructType> StructType =
- RttiBuilder("StructType").parent(&Type).composedOf(&Attribute);
-const Rtti<model::ArrayType> ArrayType = RttiBuilder("ArrayType").parent(&Type);
-const Rtti<model::UnknownType> UnknownType =
- RttiBuilder("UnknownType").parent(&Type);
-const Rtti<model::Constant> Constant = RttiBuilder("Constant").parent(&Node);
-const Rtti<model::Attribute> Attribute = RttiBuilder("Attribute").parent(&Node);
-const Rtti<model::Typesystem> Typesystem =
- RttiBuilder("Typesystem").parent(&Node).composedOf(
+const RttiType Type = RttiBuilder<model::Type>("Type").parent(&Node);
+const RttiType StringType =
+ RttiBuilder<model::StringType>("StringType").parent(&Type);
+const RttiType IntType = RttiBuilder<model::IntType>("IntType").parent(&Type);
+const RttiType DoubleType =
+ RttiBuilder<model::DoubleType>("DoubleType").parent(&Type);
+const RttiType BoolType = RttiBuilder<model::BoolType>("BoolType").parent(&Type);
+const RttiType EnumType = RttiBuilder<model::EnumType>("EnumType").parent(&Type);
+const RttiType StructType =
+ RttiBuilder<model::StructType>("StructType").parent(&Type).composedOf(&Attribute);
+const RttiType ArrayType = RttiBuilder<model::ArrayType>("ArrayType").parent(&Type);
+const RttiType UnknownType =
+ RttiBuilder<model::UnknownType>("UnknownType").parent(&Type);
+const RttiType Constant = RttiBuilder<model::Constant>("Constant").parent(&Node);
+const RttiType Attribute = RttiBuilder<model::Attribute>("Attribute").parent(&Node);
+const RttiType Typesystem =
+ RttiBuilder<model::Typesystem>("Typesystem").parent(&Node).composedOf(
{&StringType, &IntType, &DoubleType, &BoolType, &EnumType, &StructType,
&Constant});
-const Rtti<model::SystemTypesystem> SystemTypesystem =
- RttiBuilder("SystemTypesystem").parent(&Typesystem);
+const RttiType SystemTypesystem =
+ RttiBuilder<model::SystemTypesystem> ("SystemTypesystem").parent(&Typesystem);
}
}
diff --git a/src/core/model/Typesystem.hpp b/src/core/model/Typesystem.hpp
index a4a679d..803d0e8 100644
--- a/src/core/model/Typesystem.hpp
+++ b/src/core/model/Typesystem.hpp
@@ -679,8 +679,8 @@ public:
*/
static Rooted<StructType> createValidated(
Manager &mgr, std::string name, Handle<Typesystem> system,
- Handle<StructType> parentStructure, const NodeVector<Attribute> &attributes,
- Logger &logger);
+ Handle<StructType> parentStructure,
+ const NodeVector<Attribute> &attributes, Logger &logger);
/**
* Returns a handle pointing at the parent type.
@@ -945,6 +945,11 @@ private:
*/
NodeVector<Constant> constants;
+ /**
+ * List containing references to other referenced typesystems.
+ */
+ NodeVector<Typesystem> typesystems;
+
protected:
void doResolve(ResolutionState &state) override;
@@ -958,7 +963,10 @@ public:
* @param name is the name of the typesystem.
*/
Typesystem(Manager &mgr, std::string name)
- : Node(mgr, std::move(name)), types(this), constants(this)
+ : Node(mgr, std::move(name)),
+ types(this),
+ constants(this),
+ typesystems(this)
{
}
@@ -972,6 +980,14 @@ public:
Rooted<StructType> createStructType(const std::string &name);
/**
+ * Adds a reference to the given typesystem class.
+ *
+ * @param typesystem is the typesystem that should be added to the
+ * referenced typesystems list.
+ */
+ void includeTypesystem(Handle<Typesystem> typesystem);
+
+ /**
* Adds the given type to the to the type list.
*
* @param type is the Type that should be stored in this Typesystem
@@ -1097,67 +1113,67 @@ namespace RttiTypes {
/**
* Type information for the Type class.
*/
-extern const Rtti<model::Type> Type;
+extern const RttiType Type;
/**
* Type information for the StringType class.
*/
-extern const Rtti<model::StringType> StringType;
+extern const RttiType StringType;
/**
* Type information for the IntType class.
*/
-extern const Rtti<model::IntType> IntType;
+extern const RttiType IntType;
/**
* Type information for the DoubleType class.
*/
-extern const Rtti<model::DoubleType> DoubleType;
+extern const RttiType DoubleType;
/**
* Type information for the BoolType class.
*/
-extern const Rtti<model::BoolType> BoolType;
+extern const RttiType BoolType;
/**
* Type information for the EnumType class.
*/
-extern const Rtti<model::EnumType> EnumType;
+extern const RttiType EnumType;
/**
* Type information for the StructType class.
*/
-extern const Rtti<model::StructType> StructType;
+extern const RttiType StructType;
/**
* Type information for the ArrayType class.
*/
-extern const Rtti<model::ArrayType> ArrayType;
+extern const RttiType ArrayType;
/**
* Type information for the UnknownType class.
*/
-extern const Rtti<model::UnknownType> UnknownType;
+extern const RttiType UnknownType;
/**
* Type information for the Constant class.
*/
-extern const Rtti<model::Constant> Constant;
+extern const RttiType Constant;
/**
- * Type information for the Constant class.
+ * Type information for the Attribute class.
*/
-extern const Rtti<model::Attribute> Attribute;
+extern const RttiType Attribute;
/**
* Type information for the Typesystem class.
*/
-extern const Rtti<model::Typesystem> Typesystem;
+extern const RttiType Typesystem;
/**
* Type information for the SystemTypesystem class.
*/
-extern const Rtti<model::SystemTypesystem> SystemTypesystem;
+extern const RttiType SystemTypesystem;
}
}