diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/Node.hpp | 5 | ||||
| -rw-r--r-- | src/core/model/Domain.cpp | 54 | ||||
| -rw-r--r-- | src/core/model/Domain.hpp | 26 | 
3 files changed, 84 insertions, 1 deletions
diff --git a/src/core/Node.hpp b/src/core/Node.hpp index 4bc95be..516da03 100644 --- a/src/core/Node.hpp +++ b/src/core/Node.hpp @@ -350,6 +350,11 @@ public:  	 * Returns the name of the node.  	 */  	std::string getName() const { return name; } +	 +	/** +	 * Returns a reference to the name of the node. +	 */ +	const std::string& getNameRef() const { return name; }  	/**  	 * Specifies whether the node has a name, e.g. whether the current name is diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index bafd205..8eee86a 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -21,6 +21,60 @@  namespace ousia {  namespace model { +void FieldDescriptor::doResolve(std::vector<Rooted<Managed>> &res, +                                const std::vector<std::string> &path, +                                Filter filter, void *filterData, unsigned idx, +                                VisitorSet &visited) +{ +	// We call resolve for the children, but give them the field name as +	// alias. +	for (auto &c : children) { +		c->resolve(res, path, filter, filterData, idx, visited, &getNameRef()); +	} +} + +// TODO: better alias? +static std::string DESCRIPTOR_ATTRIBUTES_ALIAS {"attributes"}; + +void Descriptor::doResolve(std::vector<Rooted<Managed>> &res, +                           const std::vector<std::string> &path, Filter filter, +                           void *filterData, unsigned idx, VisitorSet &visited) +{ +	// TODO: This could be a problem, because the name of the field might be +	// needed in the path. +	for (auto &fd : fieldDescriptors) { +		fd->resolve(res, path, filter, filterData, idx, visited, nullptr); +	} +	// TODO: This throws a SEGFAULT for some reason. +//	attributesDescriptor->resolve(res, path, filter, filterData, idx, visited, +//	                              &DESCRIPTOR_ATTRIBUTES_ALIAS); +} + +void StructuredClass::doResolve(std::vector<Rooted<Managed>> &res, +                                const std::vector<std::string> &path, +                                Filter filter, void *filterData, unsigned idx, +                                VisitorSet &visited) +{ +	Descriptor::doResolve(res, path, filter, filterData, idx, visited); +	if(!isa.isNull()){ +		isa->doResolve(res, path, filter, filterData, idx, visited); +	} +} + +void Domain::doResolve(std::vector<Rooted<Managed>> &res, +                       const std::vector<std::string> &path, Filter filter, +                       void *filterData, unsigned idx, VisitorSet &visited) +{ +	for (auto &s : rootStructures) { +		s->resolve(res, path, filter, filterData, idx, visited, nullptr); +	} +	for (auto &a : annotationClasses) { +		a->resolve(res, path, filter, filterData, idx, visited, nullptr); +	} +	for (auto &t : typesystems) { +		t->resolve(res, path, filter, filterData, idx, visited, nullptr); +	} +}  }  } diff --git a/src/core/model/Domain.hpp b/src/core/model/Domain.hpp index e348136..112f2fa 100644 --- a/src/core/model/Domain.hpp +++ b/src/core/model/Domain.hpp @@ -139,6 +139,12 @@ private:  	FieldType fieldType;  	Owned<Type> primitiveType; +protected: +	void doResolve(std::vector<Rooted<Managed>> &res, +	               const std::vector<std::string> &path, Filter filter, +	               void *filterData, unsigned idx, +	               VisitorSet &visited) override; +  public:  	const bool optional; @@ -220,7 +226,7 @@ public:   * the attribute specification of a descriptor is done by referencing an   * appropriate StructType that contains all permitted keys and value types.   * - * TODO: What aout optional attributes? + * TODO: What about optional attributes?   *   * In XML terms the difference between primitive fields and attributes can be   * explained as the difference between node attributes and node children. @@ -241,6 +247,12 @@ private:  	Owned<StructType> attributesDescriptor;  	ManagedVector<FieldDescriptor> fieldDescriptors; +protected: +	void doResolve(std::vector<Rooted<Managed>> &res, +	               const std::vector<std::string> &path, Filter filter, +	               void *filterData, unsigned idx, +	               VisitorSet &visited) override; +  public:  	Descriptor(Manager &mgr, std::string name, Handle<Domain> domain,  	           // TODO: What would be a wise default value for attributes? @@ -351,6 +363,12 @@ private:  	Owned<StructuredClass> isa;  	ManagedVector<FieldDescriptor> parents; +protected: +	void doResolve(std::vector<Rooted<Managed>> &res, +	               const std::vector<std::string> &path, Filter filter, +	               void *filterData, unsigned idx, +	               VisitorSet &visited) override; +  public:  	const bool transparent; @@ -399,6 +417,12 @@ private:  	ManagedVector<AnnotationClass> annotationClasses;  	ManagedVector<Typesystem> typesystems; +protected: +	void doResolve(std::vector<Rooted<Managed>> &res, +	               const std::vector<std::string> &path, Filter filter, +	               void *filterData, unsigned idx, +	               VisitorSet &visited) override; +  public:  	Domain(Manager &mgr, std::string name)  	    // TODO: Can a domain have a parent?  | 
