Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
output-mapping-test.cpp
Go to the documentation of this file.
1/*
2 OutputMapping(Test) - verify generic output designation mapping
3
4 Copyright (C)
5 2010, 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"
22#include "steam/asset/pipe.hpp"
23#include "lib/format-string.hpp"
24#include "lib/util.hpp"
25
26#include <string>
27
28using util::_Fmt;
29using util::isnil;
30using std::string;
31
32
33namespace steam {
34namespace mobject {
35namespace test {
36
37 using asset::Pipe;
38 using asset::PPipe;
39 using mobject::OutputMapping;
40
42
43
44 /*****************************************************************************/
61 class OutputMapping_test : public Test
62 {
63 struct DummyDef
64 {
65 string
66 output (PID target)
67 {
68 return Pipe::lookup(target)->ident.name;
69 }
70
72 buildQuery (PID sourcePipeID, uint seqNr =0)
73 {
74 PPipe srcP = Pipe::lookup (sourcePipeID);
75 _Fmt queryPattern{"id(master_%1%), stream(%1%), ord(%2%)"};
76 return Query<Pipe> (queryPattern % srcP->getStreamID().getSym() % seqNr);
77 }
78 };
79
81
82 virtual void
83 run (Arg)
84 {
88 }
89
90
91 void
93 {
94 Mapping map;
95 CHECK (isnil (map));
96
97 PPipe p1 = Pipe::query("id(hairy)");
98 PPipe p2 = Pipe::query("id(furry)");
99 PPipe pX = Pipe::query("id(curly)");
100
101 map[p1] = p2;
102 CHECK (!isnil (map));
103 CHECK (1 == map.size());
104 CHECK (map[p1] == "furry");
105 CHECK (map[p1].isValid());
106 CHECK (map[p1]);
107
108 CHECK (!map.contains (pX));
109 CHECK (!map.contains (p2));
110
111 // create an unconnected mapping
112 map[pX].disconnect();
113 CHECK (map.contains (pX));
114 CHECK (!map[pX].isValid());
115 CHECK (!map[pX]);
116 }
117
118
119 void
121 {
122 Mapping m1;
123
124 PPipe p1 = Pipe::query("id(hairy)");
125 PPipe p2 = Pipe::query("id(furry)");
126 PPipe pi = Pipe::query("id(nappy)");
127
128 m1[pi] = p1;
129 Mapping m2(m1);
130 CHECK (!isnil (m2));
131 CHECK (1 == m2.size());
132 CHECK (m1[pi] == "hairy");
133 CHECK (m2[pi] == "hairy");
134
135 m1[pi] = p2;
136 CHECK (m1[pi] == "furry");
137 CHECK (m2[pi] == "hairy");
138
139 m2 = m1;
140 CHECK (m1[pi] == "furry");
141 CHECK (m2[pi] == "furry");
142
143 m1.clear();
144 CHECK (isnil(m1));
145 CHECK (!isnil(m2));
146 CHECK (m2[pi] == "furry");
147 CHECK (!m1.contains (pi));
148 }
149
150
151 void
153 {
154 Mapping map;
155 CHECK (isnil (map));
156
157 PPipe p1 = Pipe::query("stream(hairy)");
158 PPipe p2 = Pipe::query("stream(furry)");
159
160 CHECK (map[p1] == "master_hairy");
161 CHECK (map[p2] == "master_furry");
162
163 // create new mapping to an explicitly queried target
164 Query<Pipe> some_pipe ("pipe(super_curly)");
165 CHECK (map[some_pipe] == "super_curly");
166
167 // create a new mapping to the 2nd master for "furry" data
168 Query<Pipe> special_bus ("stream(furry), ord(2)");
169 CHECK (map[special_bus] == "master_furry.2");
170 }
171 };
172
173
175 LAUNCHER (OutputMapping_test, "unit session");
176
177
178
179}}} // namespace steam::mobject::test
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition p.hpp:77
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition query.hpp:254
thin wrapper around a size_t hash ID used as primary key for all Asset objects.
Definition asset.hpp:98
structural asset corresponding to the part of the model forming a processing pipe for generating medi...
Definition pipe.hpp:72
static PPipe query(string const &properties)
convenience shortcut for retrieving default configured pipes
Definition pipe.cpp:57
static PPipe lookup(ID< Pipe > id)
convenience shortcut for lookup by id
Definition pipe.cpp:67
OutputMapping is a facility to resolve output designations.
A front-end for using printf-style formatting.
Front-end for printf-style string template interpolation.
unsigned int uint
Definition integral.hpp:29
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Translating and wiring output designations.
A "processing pipe" represented as Asset.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Query< Pipe > buildQuery(PID sourcePipeID, uint seqNr=0)
A collection of frequently used helper functions to support unit testing.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...