summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-29 22:52:29 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-29 22:52:29 +0100
commit90b2e9507e9d720452792b863b422221fe96d948 (patch)
tree407a271de4730d087de4132eab3921c44c65e400
parentde0891c69166f6988e0b13137f9bf2b7b67449f2 (diff)
Unified signature of resolve functions, passing the "owner" to the callback functions in ParserScope::resolve
-rw-r--r--src/core/model/Node.cpp26
-rw-r--r--src/core/model/Node.hpp17
-rw-r--r--src/core/parser/ParserScope.cpp35
-rw-r--r--src/core/parser/ParserScope.hpp89
-rw-r--r--src/plugins/xml/XmlParser.cpp32
-rw-r--r--test/core/model/DomainTest.cpp26
-rw-r--r--test/core/model/NodeTest.cpp62
-rw-r--r--test/core/model/TestAdvanced.hpp2
-rw-r--r--test/core/model/TestDocumentBuilder.hpp2
9 files changed, 141 insertions, 150 deletions
diff --git a/src/core/model/Node.cpp b/src/core/model/Node.cpp
index 6c00e89..7cbbbe1 100644
--- a/src/core/model/Node.cpp
+++ b/src/core/model/Node.cpp
@@ -60,14 +60,14 @@ using VisitorSet =
class SharedResolutionState {
public:
/**
- * Actual path (name pattern) that was requested for resolution.
+ * Type of the node that was requested for resolution.
*/
- const std::vector<std::string> &path;
+ const Rtti &type;
/**
- * Type of the node that was requested for resolution.
+ * Actual path (name pattern) that was requested for resolution.
*/
- const Rtti &type;
+ const std::vector<std::string> &path;
/**
* Tracks all nodes that have already been visited.
@@ -82,13 +82,13 @@ public:
/**
* Constructor of the SharedResolutionState class.
*
+ * @param type is the type of the node that should be resolved.
* @param path is a const reference to the actual path that should be
* resolved.
- * @param type is the type of the node that should be resolved.
*/
- SharedResolutionState(const std::vector<std::string> &path,
- const Rtti &type)
- : path(path), type(type)
+ SharedResolutionState(const Rtti &type,
+ const std::vector<std::string> &path)
+ : type(type), path(path)
{
}
};
@@ -329,10 +329,10 @@ bool Node::continueResolveReference(Handle<Node> h, ResolutionState &state)
}
std::vector<ResolutionResult> Node::resolve(
- const std::vector<std::string> &path, const Rtti &type)
+ const Rtti &type, const std::vector<std::string> &path)
{
// Create the state variables
- SharedResolutionState sharedState(path, type);
+ SharedResolutionState sharedState(type, path);
ResolutionState state(sharedState, this);
// Kickstart the resolution process by treating this very node as compositum
@@ -344,11 +344,11 @@ std::vector<ResolutionResult> Node::resolve(
return sharedState.result;
}
-std::vector<ResolutionResult> Node::resolve(const std::string &name,
- const Rtti &type)
+std::vector<ResolutionResult> Node::resolve(const Rtti &type,
+ const std::string &name)
{
// Place the name in a vector and call the corresponding resolve function
- return resolve(std::vector<std::string>{name}, type);
+ return resolve(type, std::vector<std::string>{name});
}
bool Node::checkDuplicate(Handle<Node> elem,
diff --git a/src/core/model/Node.hpp b/src/core/model/Node.hpp
index 036bcae..61bf418 100644
--- a/src/core/model/Node.hpp
+++ b/src/core/model/Node.hpp
@@ -223,7 +223,7 @@ private:
* @param thisRef is the Node of which the reference should be returned.
* @return the value of the reference.
*/
- using NodeReferenceCallback = const Node* (const Node* thisRef);
+ using NodeReferenceCallback = const Node *(const Node *thisRef);
/**
* Checks whether the a certain property is acyclic.
@@ -400,7 +400,8 @@ protected:
* @return true if the parent reference is acyclic, false otherwise.
*/
bool validateIsAcyclic(const std::string &name,
- NodeReferenceCallback callback, Logger &logger) const;
+ NodeReferenceCallback callback,
+ Logger &logger) const;
/**
* Makes sure the "parent" reference is not cyclic.
@@ -538,26 +539,26 @@ public:
* Function which resolves a name path to a list of possible nodes starting
* from this node.
*
+ * @param type specifies the type of the node that should be located.
* @param path is a list specifying a path of node names meant to specify a
* certain named node.
- * @param type specifies the type of the node that should be located.
* @return a vector containing ResolutionResult structures which describe
* the resolved elements.
*/
- std::vector<ResolutionResult> resolve(const std::vector<std::string> &path,
- const Rtti &type);
+ std::vector<ResolutionResult> resolve(const Rtti &type,
+ const std::vector<std::string> &path);
/**
* Function which resolves a single name to a list of possible nodes
* starting from this node.
*
- * @param name is the name which should be resolved.
* @param type specifies the type of the node that should be located.
+ * @param name is the name which should be resolved.
* @return a vector containing ResolutionResult structures which describe
* the resolved elements.
*/
- std::vector<ResolutionResult> resolve(const std::string &name,
- const Rtti &type);
+ std::vector<ResolutionResult> resolve(const Rtti &type,
+ const std::string &name);
/**
* Checks whether this node is valid and returns true if it is and false
diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp
index 0de0dbf..b76bb28 100644
--- a/src/core/parser/ParserScope.cpp
+++ b/src/core/parser/ParserScope.cpp
@@ -31,12 +31,13 @@ ParserScopeBase::ParserScopeBase(const NodeVector<Node> &nodes) : nodes(nodes)
{
}
-Rooted<Node> ParserScopeBase::resolve(const std::vector<std::string> &path,
- const Rtti &type, Logger &logger)
+Rooted<Node> ParserScopeBase::resolve(const Rtti &type,
+ const std::vector<std::string> &path,
+ Logger &logger)
{
// Go up the stack and try to resolve the
for (auto it = nodes.rbegin(); it != nodes.rend(); it++) {
- std::vector<ResolutionResult> res = (*it)->resolve(path, type);
+ std::vector<ResolutionResult> res = (*it)->resolve(type, path);
// Abort if the object could not be resolved
if (res.empty()) {
@@ -79,14 +80,14 @@ bool DeferredResolution::resolve(
// Fork the logger to prevent error messages from being shown if we actively
// ignore the resolution result
LoggerFork loggerFork = logger.fork();
- Rooted<Node> res = scope.resolve(path, type, loggerFork);
+ Rooted<Node> res = scope.resolve(type, path, loggerFork);
if (res != nullptr) {
if (!ignore.count(res.get())) {
loggerFork.commit();
try {
// Push the location onto the logger default location stack
GuardedLogger loggerGuard(logger, *owner);
- resultCallback(res, logger);
+ resultCallback(res, owner, logger);
}
catch (LoggableException ex) {
logger.log(ex);
@@ -227,29 +228,29 @@ bool ParserScope::getFlag(ParserFlag flag)
return false;
}
-bool ParserScope::resolve(const std::vector<std::string> &path,
- const Rtti &type, Logger &logger,
+bool ParserScope::resolve(const Rtti &type,
+ const std::vector<std::string> &path,
+ Handle<Node> owner, Logger &logger,
ResolutionImposterCallback imposterCallback,
- ResolutionResultCallback resultCallback,
- Handle<Node> owner)
+ ResolutionResultCallback resultCallback)
{
- if (!resolve(path, type, logger, resultCallback, owner)) {
- resultCallback(imposterCallback(), logger);
+ if (!resolve(type, path, owner, logger, resultCallback)) {
+ resultCallback(imposterCallback(), owner, logger);
return false;
}
return true;
}
-bool ParserScope::resolve(const std::vector<std::string> &path,
- const Rtti &type, Logger &logger,
- ResolutionResultCallback resultCallback,
- Handle<Node> owner)
+bool ParserScope::resolve(const Rtti &type,
+ const std::vector<std::string> &path,
+ Handle<Node> owner, Logger &logger,
+ ResolutionResultCallback resultCallback)
{
// Try to directly resolve the node
- Rooted<Node> res = ParserScopeBase::resolve(path, type, logger);
+ Rooted<Node> res = ParserScopeBase::resolve(type, path, logger);
if (res != nullptr && !awaitingResolution.count(res.get())) {
try {
- resultCallback(res, logger);
+ resultCallback(res, owner, logger);
}
catch (LoggableException ex) {
logger.log(ex, *owner);
diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp
index 2378967..e01acfe 100644
--- a/src/core/parser/ParserScope.hpp
+++ b/src/core/parser/ParserScope.hpp
@@ -50,14 +50,18 @@ class ParserScope;
* Callback function type used for creating a dummy object while no correct
* object is available for resolution.
*/
-using ResolutionImposterCallback = std::function<Rooted<Node>()>;
+using ResolutionImposterCallback = Rooted<Node>(*)();
/**
* Callback function type called whenever the result of a resolution is
* available.
+ *
+ * @param resolved is the new, resolved node.
+ * @param owner is the node that was passed as "owner".
+ * @param logger is the logger to which errors should be logged.
*/
-using ResolutionResultCallback =
- std::function<void(Handle<Node>, Logger &logger)>;
+using ResolutionResultCallback = void (*)(Handle<Node> resolved,
+ Handle<Node> owner, Logger &logger);
/**
* Base class for the
@@ -90,14 +94,14 @@ public:
* Tries to resolve a node for the given type and path for all nodes that
* are currently in the stack, starting with the topmost node on the stack.
*
- * @param path is the path for which a node should be resolved.
* @param type is the type of the node that should be resolved.
+ * @param path is the path for which a node should be resolved.
* @param logger is the logger instance into which resolution problems
* should be logged.
* @return a reference at a resolved node or nullptr if no node could be
* found.
*/
- Rooted<Node> resolve(const std::vector<std::string> &path, const Rtti &type,
+ Rooted<Node> resolve(const Rtti &type, const std::vector<std::string> &path,
Logger &logger);
};
@@ -396,8 +400,9 @@ public:
* temporary) and another time if the resolution turned out to be
* successful at a later point in time.
*
- * @param path is the path for which a node should be resolved.
* @param type is the type of the node that should be resolved.
+ * @param path is the path for which a node should be resolved.
+ * @param owner is the node for which the resolution takes place.
* @param logger is the logger instance into which resolution problems
* should be logged.
* @param imposterCallback is the callback function that is called if
@@ -410,15 +415,14 @@ public:
* the resolved object directly when this function is called. If the
* resolution was not successful the first time, it may be called another
* time later in the context of the "performDeferredResolution" function.
- * @param owner is the node for which the resolution takes place.
* @return true if the resolution was immediately successful. This does
* not mean, that the resolved object does not exist, as it may be resolved
* later.
*/
- bool resolve(const std::vector<std::string> &path, const Rtti &type,
- Logger &logger, ResolutionImposterCallback imposterCallback,
- ResolutionResultCallback resultCallback,
- Handle<Node> owner = nullptr);
+ bool resolve(const Rtti &type, const std::vector<std::string> &path,
+ Handle<Node> owner, Logger &logger,
+ ResolutionImposterCallback imposterCallback,
+ ResolutionResultCallback resultCallback);
/**
* Tries to resolve a node for the given type and path for all nodes
@@ -426,21 +430,21 @@ public:
* The "resultCallback" is called when the resolution was successful, which
* may be at a later point in time.
*
- * @param path is the path for which a node should be resolved.
* @param type is the type of the node that should be resolved.
+ * @param path is the path for which a node should be resolved.
+ * @param owner is the node for which the resolution takes place.
* @param logger is the logger instance into which resolution problems
* should be logged.
* @param resultCallback is the callback function to which the result of
* the resolution process is passed. This function is called once the
* resolution was successful.
- * @param owner is the node for which the resolution takes place.
* @return true if the resolution was immediately successful. This does not
* mean, that the resolved object does not exist, as it may be resolved
* later.
*/
- bool resolve(const std::vector<std::string> &path, const Rtti &type,
- Logger &logger, ResolutionResultCallback resultCallback,
- Handle<Node> owner = nullptr);
+ bool resolve(const Rtti &type, const std::vector<std::string> &path,
+ Handle<Node> owner, Logger &logger,
+ ResolutionResultCallback resultCallback);
/**
* Tries to resolve a node for the given type and path for all nodes
@@ -453,6 +457,7 @@ public:
*
* @tparam T is the type of the node that should be resolved.
* @param path is the path for which a node should be resolved.
+ * @param owner is the node for which the resolution takes place.
* @param logger is the logger instance into which resolution problems
* should be logged.
* @param imposterCallback is the callback function that is called if
@@ -465,24 +470,17 @@ public:
* resolved object directly when this function is called. If the resolution
* was not successful the first time, it may be called another time later
* in the context of the "performDeferredResolution" function.
- * @param owner is the node for which the resolution takes place.
* @return true if the resolution was immediately successful. This does not
* mean, that the resolved object does not exist, as it may be resolved
* later.
*/
template <class T>
- bool resolve(const std::vector<std::string> &path, Logger &logger,
- std::function<Rooted<T>()> imposterCallback,
- std::function<void(Handle<T>, Logger &)> resultCallback,
- Handle<Node> owner = nullptr)
+ bool resolve(const std::vector<std::string> &path, Handle<Node> owner,
+ Logger &logger, ResolutionImposterCallback imposterCallback,
+ ResolutionResultCallback resultCallback)
{
- return resolve(
- path, typeOf<T>(), logger,
- [imposterCallback]() -> Rooted<Node> { return imposterCallback(); },
- [resultCallback](Handle<Node> node, Logger &logger) {
- resultCallback(node.cast<T>(), logger);
- },
- owner);
+ return resolve(typeOf<T>(), path, owner, logger, imposterCallback,
+ resultCallback);
}
/**
@@ -493,26 +491,21 @@ public:
*
* @tparam T is the type of the node that should be resolved.
* @param path is the path for which a node should be resolved.
+ * @param owner is the node for which the resolution takes place.
* @param logger is the logger instance into which resolution problems
* should be logged.
* @param resultCallback is the callback function to which the result of
* the resolution process is passed. This function is called once the
* resolution was successful.
- * @param owner is the node for which the resolution takes place.
* @return true if the resolution was immediately successful. This does not
* mean, that the resolved object does not exist, as it may be resolved
* later.
*/
template <class T>
- bool resolve(const std::vector<std::string> &path, Logger &logger,
- std::function<void(Handle<T>, Logger &)> resultCallback,
- Handle<Node> owner = nullptr)
+ bool resolve(const std::vector<std::string> &path, Handle<Node> owner,
+ Logger &logger, ResolutionResultCallback resultCallback)
{
- return resolve(path, typeOf<T>(), logger,
- [resultCallback](Handle<Node> node, Logger &logger) {
- resultCallback(node.cast<T>(), logger);
- },
- owner);
+ return resolve(typeOf<T>(), path, owner, logger, resultCallback);
}
/**
@@ -527,6 +520,7 @@ public:
* @tparam T is the type of the node that should be resolved.
* @param name is the path for which a node should be resolved. The name is
* split at '.' to form a path.
+ * @param owner is the node for which the resolution takes place.
* @param logger is the logger instance into which resolution problems
* should be logged.
* @param imposterCallback is the callback function that is called if
@@ -539,19 +533,17 @@ public:
* resolved object directly when this function is called. If the resolution
* was not successful the first time, it may be called another time later
* in the context of the "performDeferredResolution" function.
- * @param owner is the node for which the resolution takes place.
* @return true if the resolution was immediately successful. This does not
* mean, that the resolved object does not exist, as it may be resolved
* later.
*/
template <class T>
- bool resolve(const std::string &name, Logger &logger,
- std::function<Rooted<T>()> imposterCallback,
- std::function<void(Handle<T>, Logger &)> resultCallback,
- Handle<Node> owner = nullptr)
+ bool resolve(const std::string &name, Handle<Node> owner, Logger &logger,
+ ResolutionImposterCallback imposterCallback,
+ ResolutionResultCallback resultCallback)
{
- return resolve<T>(Utils::split(name, '.'), logger, imposterCallback,
- resultCallback, owner);
+ return resolve<T>(Utils::split(name, '.'), owner, logger,
+ imposterCallback, resultCallback);
}
/**
@@ -574,12 +566,11 @@ public:
* later.
*/
template <class T>
- bool resolve(const std::string &name, Logger &logger,
- std::function<void(Handle<T>, Logger &)> resultCallback,
- Handle<Node> owner = nullptr)
+ bool resolve(const std::string &name, Handle<Node> owner, Logger &logger,
+ ResolutionResultCallback resultCallback)
{
- return resolve<T>(Utils::split(name, '.'), logger, resultCallback,
- owner);
+ return resolve<T>(Utils::split(name, '.'), owner, logger,
+ resultCallback);
}
/**
diff --git a/src/plugins/xml/XmlParser.cpp b/src/plugins/xml/XmlParser.cpp
index 6e0fea0..5e30fec 100644
--- a/src/plugins/xml/XmlParser.cpp
+++ b/src/plugins/xml/XmlParser.cpp
@@ -167,13 +167,13 @@ public:
// Try to resolve the parent type and set it as parent structure
if (!parent.empty()) {
- scope().resolve<StructType>(parent, logger(),
- [structType](Handle<StructType> parent,
- Logger &logger) mutable {
- structType->setParentStructure(
- parent, logger);
- },
- structType);
+ scope().resolve<StructType>(
+ parent, structType, logger(),
+ [](Handle<Node> parent, Handle<Node> structType,
+ Logger &logger) {
+ structType.cast<StructType>()->setParentStructure(
+ parent.cast<StructType>(), logger);
+ });
}
// Descend into the struct type
@@ -212,11 +212,10 @@ public:
// Try to resolve the type
scope().resolve<Type>(
- type, logger(),
- [attribute](Handle<Type> type, Logger &logger) mutable {
- attribute->setType(type, logger);
- },
- attribute);
+ type, attribute, logger(),
+ [](Handle<Node> type, Handle<Node> attribute, Logger &logger) {
+ attribute.cast<Attribute>()->setType(type.cast<Type>(), logger);
+ });
}
void end() override {}
@@ -244,11 +243,10 @@ public:
// Try to resolve the type
scope().resolve<Type>(
- type, logger(),
- [constant](Handle<Type> type, Logger &logger) mutable {
- constant->setType(type, logger);
- },
- constant);
+ type, constant, logger(),
+ [](Handle<Node> type, Handle<Node> constant, Logger &logger) {
+ constant.cast<Constant>()->setType(type.cast<Type>(), logger);
+ });
}
void end() override {}
diff --git a/test/core/model/DomainTest.cpp b/test/core/model/DomainTest.cpp
index 8bf1a47..767ac0c 100644
--- a/test/core/model/DomainTest.cpp
+++ b/test/core/model/DomainTest.cpp
@@ -50,41 +50,41 @@ TEST(Domain, testDomainResolving)
std::vector<ResolutionResult> res;
// There is one domain called "book"
- res = domain->resolve("book", typeOf<Domain>());
+ res = domain->resolve(RttiTypes::Domain, "book");
ASSERT_EQ(1U, res.size());
- assert_path(res[0], typeOf<Domain>(), {"book"});
+ assert_path(res[0], RttiTypes::Domain, {"book"});
// There is one domain called "book"
- res = domain->resolve("book", typeOf<StructuredClass>());
+ res = domain->resolve(RttiTypes::StructuredClass, "book");
ASSERT_EQ(1U, res.size());
- assert_path(res[0], typeOf<StructuredClass>(), {"book", "book"});
+ assert_path(res[0], RttiTypes::StructuredClass, {"book", "book"});
// If we explicitly ask for the "book, book" path, then only the
// StructuredClass should be returned.
- res = domain->resolve(std::vector<std::string>{"book", "book"},
- typeOf<Domain>());
+ res = domain->resolve(RttiTypes::Domain,
+ std::vector<std::string>{"book", "book"});
ASSERT_EQ(0U, res.size());
- res = domain->resolve(std::vector<std::string>{"book", "book"},
- typeOf<StructuredClass>());
+ res = domain->resolve(RttiTypes::StructuredClass,
+ std::vector<std::string>{"book", "book"});
ASSERT_EQ(1U, res.size());
// If we ask for "section" the result should be unique as well.
- res = domain->resolve("section", typeOf<StructuredClass>());
+ res = domain->resolve(RttiTypes::StructuredClass, "section");
ASSERT_EQ(1U, res.size());
- assert_path(res[0], typeOf<StructuredClass>(), {"book", "section"});
+ assert_path(res[0], RttiTypes::StructuredClass, {"book", "section"});
// If we ask for "paragraph" it is referenced two times in the Domain graph,
// but should be returned only once.
- res = domain->resolve("paragraph", typeOf<StructuredClass>());
+ res = domain->resolve(RttiTypes::StructuredClass, "paragraph");
ASSERT_EQ(1U, res.size());
- assert_path(res[0], typeOf<StructuredClass>(), {"book", "paragraph"});
+ assert_path(res[0], RttiTypes::StructuredClass, {"book", "paragraph"});
}
Rooted<StructuredClass> getClass(const std::string name, Handle<Domain> dom)
{
std::vector<ResolutionResult> res =
- dom->resolve(name, RttiTypes::StructuredClass);
+ dom->resolve(RttiTypes::StructuredClass, name);
return res[0].node.cast<StructuredClass>();
}
diff --git a/test/core/model/NodeTest.cpp b/test/core/model/NodeTest.cpp
index a9a699d..d9ca5bb 100644
--- a/test/core/model/NodeTest.cpp
+++ b/test/core/model/NodeTest.cpp
@@ -61,8 +61,8 @@ public:
namespace RttiTypes {
const Rtti TestNode = RttiBuilder<ousia::TestNode>("TestNode")
- .parent(&RttiTypes::Node)
- .composedOf(&TestNode);
+ .parent(&RttiTypes::Node)
+ .composedOf(&TestNode);
}
TEST(Node, isRoot)
@@ -85,18 +85,18 @@ TEST(Node, resolveCompositaSimple)
child1->addCompositum(new TestNode(mgr, "child11"));
std::vector<ResolutionResult> res;
- res = root->resolve(std::vector<std::string>{"root", "child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"root", "child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
- res = root->resolve(std::vector<std::string>{"child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
res =
- root->resolve(std::vector<std::string>{"child11"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
}
@@ -111,18 +111,18 @@ TEST(Node, resolveCompositaDouble)
child1->addCompositum(new TestNode(mgr, "child11"));
std::vector<ResolutionResult> res;
- res = root->resolve(std::vector<std::string>{"root", "child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"root", "child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
- res = root->resolve(std::vector<std::string>{"child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
res =
- root->resolve(std::vector<std::string>{"child11"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
}
@@ -141,14 +141,14 @@ TEST(Node, resolveAmbigousComposita)
child12->addCompositum(new TestNode(mgr, "child11"));
std::vector<ResolutionResult> res;
- res = root->resolve(std::vector<std::string>{"child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"child1", "child11"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child11 == res[0].node || child11 == res[1].node);
ASSERT_TRUE(child112 == res[0].node || child112 == res[1].node);
res =
- root->resolve(std::vector<std::string>{"child11"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child11"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child11 == res[0].node || child11 == res[1].node);
ASSERT_TRUE(child112 == res[0].node || child112 == res[1].node);
@@ -168,30 +168,30 @@ TEST(Node, resolveReferences)
child12->addCompositum(new TestNode(mgr, "child11"));
std::vector<ResolutionResult> res;
- res = root->resolve(std::vector<std::string>{"a", "child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"a", "child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
- res = root->resolve(std::vector<std::string>{"b", "child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"b", "child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child112 == res[0].node);
- res = root->resolve(std::vector<std::string>{"child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"child1", "child11"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child11 == res[0].node || child11 == res[1].node);
ASSERT_TRUE(child112 == res[0].node || child112 == res[1].node);
res =
- root->resolve(std::vector<std::string>{"child11"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child11"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child11 == res[0].node || child11 == res[1].node);
ASSERT_TRUE(child112 == res[0].node || child112 == res[1].node);
res =
- root->resolve(std::vector<std::string>{"child1"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child1"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child1 == res[0].node || child1 == res[1].node);
ASSERT_TRUE(child12 == res[0].node || child12 == res[1].node);
@@ -212,31 +212,31 @@ TEST(Node, resolveReferencesAndComposita)
Rooted<TestNode> child13 = root->addCompositum(new TestNode(mgr, "child1"));
std::vector<ResolutionResult> res;
- res = root->resolve(std::vector<std::string>{"a", "child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"a", "child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child11 == res[0].node);
- res = root->resolve(std::vector<std::string>{"b", "child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"b", "child1", "child11"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child112 == res[0].node);
- res = root->resolve(std::vector<std::string>{"child1", "child11"},
- RttiTypes::TestNode);
+ res = root->resolve(RttiTypes::TestNode,
+ std::vector<std::string>{"child1", "child11"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child11 == res[0].node || child11 == res[1].node);
ASSERT_TRUE(child112 == res[0].node || child112 == res[1].node);
res =
- root->resolve(std::vector<std::string>{"child11"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child11"});
ASSERT_EQ(2U, res.size());
ASSERT_TRUE(child11 == res[0].node || child11 == res[1].node);
ASSERT_TRUE(child112 == res[0].node || child112 == res[1].node);
// Resolving for "child1" should not descend into the referenced nodes
res =
- root->resolve(std::vector<std::string>{"child1"}, RttiTypes::TestNode);
+ root->resolve(RttiTypes::TestNode, std::vector<std::string>{"child1"});
ASSERT_EQ(1U, res.size());
ASSERT_TRUE(child13 == res[0].node);
}
diff --git a/test/core/model/TestAdvanced.hpp b/test/core/model/TestAdvanced.hpp
index d90f917..e3744b8 100644
--- a/test/core/model/TestAdvanced.hpp
+++ b/test/core/model/TestAdvanced.hpp
@@ -32,7 +32,7 @@ static Rooted<StructuredClass> resolveDescriptor(Handle<Domain> domain,
{
// use the actual resolve method.
std::vector<ResolutionResult> resolved =
- domain->resolve(className, typeOf<StructuredClass>());
+ domain->resolve(RttiTypes::StructuredClass, className);
// take the first valid result.
for (auto &r : resolved) {
return r.node.cast<StructuredClass>();
diff --git a/test/core/model/TestDocumentBuilder.hpp b/test/core/model/TestDocumentBuilder.hpp
index 149b88e..71b353d 100644
--- a/test/core/model/TestDocumentBuilder.hpp
+++ b/test/core/model/TestDocumentBuilder.hpp
@@ -48,7 +48,7 @@ static Rooted<Descriptor> resolveDescriptor(Handle<Document> doc,
const Rtti &type)
{
// use the actual resolve method.
- std::vector<ResolutionResult> resolved = doc->resolve(path, type);
+ std::vector<ResolutionResult> resolved = doc->resolve(type, path);
// if we don't find anything, log an error
if (resolved.size() == 0) {
logger.error(std::string("Could not resolve ") + getPathString(path));