Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
placement-index-query-test.cpp
Go to the documentation of this file.
1/*
2 PlacementIndexQuery(Test) - querying the placement index through the generic query interface
3
4 Copyright (C)
5 2009, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
25#include "lib/format-cout.hpp"
26#include "lib/util.hpp"
27
28
29
30namespace steam {
31namespace mobject {
32namespace session {
33namespace test {
34
39
40
41 /************************************************************************/
51 class PlacementIndexQuery_test : public Test
52 {
53
54 virtual void
55 run (Arg)
56 {
59 }
60
61 void
63 {
64 PPIdx index = build_testScopes();
67
68 CHECK (isSameObject (resolver1, resolver2));
69
70 PlacementMO& root1 = index->getRoot();
72 CHECK (isSameObject (root1, root2));
73
74 PlacementMO& elm1 = *ContentsQuery<TestSubMO2>(root1).resolveBy(resolver1);
75 PlacementMO& elm2 = *ContentsQuery<TestSubMO1>(root1).resolveBy(resolver1);
76 PlacementMO& elm3 = *(index->getReferrers(elm1));
77 CHECK (isSameObject (elm3, elm2));
78 // relying on the specific setup of the test index
79 // MO1 is the sole "referrer" of MO2 (the only content within MO2's scope)
80 // root \ TestSubMO2 \ TestSubMO1
81 }
82
83 void
85 {
86 // Prepare an (test)Index (dummy "session")
87 PPIdx index = build_testScopes();
88 PlacementMO& root = index->getRoot();
89 PlacementIndexQueryResolver resolver(*index);
90
91 cout << "explore contents depth-first..." << endl;
92 discover (ContentsQuery<MObject>(root).resolveBy(resolver));
93
94 PlacementMO& elm = *ContentsQuery<TestSubMO1>(root).resolveBy(resolver);
95
96 cout << "path to root starting at " << elm << endl;
97 discover (PathQuery<MObject> (elm).resolveBy(resolver));
98 }
99
100
101 template<class IT>
102 void
103 discover (IT result)
104 {
105 for ( ; result; ++result)
106 cout << *result << endl;
107 }
108 };
109
110
111
114
115
116}}}} // namespace steam::mobject::session::test
Interface: a facility for resolving (some kind of) queries A concrete subclass has the ability to cre...
iterator resolveBy(QueryResolver const &resolver) const
Wrapper for the PlacementIndex, allowing to resolve scope contents discovery.
Automatically use custom string conversion in C++ stream output.
PPIdx build_testScopes()
helper for tests: create a pseudo-session (actually just a PlacementIndex), which contains some neste...
std::shared_ptr< PlacementIndex > PPIdx
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Definition util.hpp:421
Implementing resolution of "discover contents"-queries based on PlacementIndex.
framework and to resolve logical queries.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Specific queries to explore contents of a scope within the high-level model.
Implementation level session API: query a scope.
static lumiera::QueryResolver const & getResolver()
Unit test helper to generate a system of nested test scopes.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...