2010-11-23 03:40:11 +01:00
|
|
|
|
/*
|
|
|
|
|
|
OutputMapping(Test) - verify generic output designation mapping
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2010, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
option) any later version. See the file COPYING for further details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2017-02-22 01:54:20 +01:00
|
|
|
|
/** @file output-mapping-test.cpp
|
2017-02-22 03:17:18 +01:00
|
|
|
|
** unit test \ref OutputMapping_test
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
|
|
|
|
|
#include "lib/test/test-helper.hpp"
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/mobject/output-mapping.hpp"
|
|
|
|
|
|
#include "steam/asset/pipe.hpp"
|
2016-01-04 01:38:04 +01:00
|
|
|
|
#include "lib/format-string.hpp"
|
2010-11-23 03:40:11 +01:00
|
|
|
|
#include "lib/util.hpp"
|
|
|
|
|
|
|
2010-11-24 06:21:32 +01:00
|
|
|
|
#include <string>
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2016-01-04 01:38:04 +01:00
|
|
|
|
using util::_Fmt;
|
2010-11-23 03:40:11 +01:00
|
|
|
|
using util::isnil;
|
2010-11-24 06:21:32 +01:00
|
|
|
|
using std::string;
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2010-11-23 03:40:11 +01:00
|
|
|
|
namespace mobject {
|
2011-12-02 17:50:44 +01:00
|
|
|
|
namespace test {
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
using asset::Pipe;
|
|
|
|
|
|
using asset::PPipe;
|
2023-06-07 04:03:00 +02:00
|
|
|
|
using mobject::OutputMapping;
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2010-11-24 06:21:32 +01:00
|
|
|
|
typedef asset::ID<Pipe> PID;
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
|
/*****************************************************************************//**
|
2010-11-28 05:18:57 +01:00
|
|
|
|
* @test create a synthetic / example mapping to verify generic mapping behaviour.
|
|
|
|
|
|
* We're creating a custom mapping type here, for this test only: The
|
|
|
|
|
|
* struct DummyDef provides a "definition context" for this custom mapping
|
|
|
|
|
|
* - there is a function to retrieve the actual target object
|
|
|
|
|
|
* for any target pipe stored in the mapping. In this case,
|
|
|
|
|
|
* we just extract the name-ID string from the pipe as result
|
|
|
|
|
|
* - as an additional sideeffect, this DummyDef::output functor
|
|
|
|
|
|
* also defines the Target type of this custom mapping to be std::string
|
|
|
|
|
|
* - DummyDef::buildQuery provides a template query, to be issued whenever
|
|
|
|
|
|
* a yet nonexistent mapping is requested. In this special case here
|
|
|
|
|
|
* we query for a pipe with the name "master_XXX", where XXX denotes
|
|
|
|
|
|
* the stream-type of the source pipe to be mapped.
|
2010-11-23 03:40:11 +01:00
|
|
|
|
*
|
|
|
|
|
|
* @see mobject::OutputDesignation
|
|
|
|
|
|
* @see mobject::session::Binding
|
|
|
|
|
|
*/
|
|
|
|
|
|
class OutputMapping_test : public Test
|
|
|
|
|
|
{
|
|
|
|
|
|
struct DummyDef
|
|
|
|
|
|
{
|
2010-11-24 06:21:32 +01:00
|
|
|
|
string
|
|
|
|
|
|
output (PID target)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Pipe::lookup(target)->ident.name;
|
|
|
|
|
|
}
|
2010-11-28 02:16:39 +01:00
|
|
|
|
|
|
|
|
|
|
Query<Pipe>
|
2010-11-28 05:18:57 +01:00
|
|
|
|
buildQuery (PID sourcePipeID, uint seqNr =0)
|
2010-11-28 02:16:39 +01:00
|
|
|
|
{
|
2010-11-28 05:18:57 +01:00
|
|
|
|
PPipe srcP = Pipe::lookup (sourcePipeID);
|
2016-01-04 01:38:04 +01:00
|
|
|
|
_Fmt queryPattern{"id(master_%1%), stream(%1%), ord(%2%)"};
|
|
|
|
|
|
return Query<Pipe> (queryPattern % srcP->getStreamID().getSym() % seqNr);
|
2010-11-28 02:16:39 +01:00
|
|
|
|
}
|
2010-11-23 03:40:11 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef OutputMapping<DummyDef> Mapping;
|
|
|
|
|
|
|
|
|
|
|
|
virtual void
|
2017-12-02 03:03:56 +01:00
|
|
|
|
run (Arg)
|
2010-11-23 03:40:11 +01:00
|
|
|
|
{
|
|
|
|
|
|
map_and_retrieve();
|
|
|
|
|
|
instance_copy();
|
|
|
|
|
|
default_mapping();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
map_and_retrieve()
|
|
|
|
|
|
{
|
|
|
|
|
|
Mapping map;
|
|
|
|
|
|
CHECK (isnil (map));
|
|
|
|
|
|
|
2012-12-26 02:20:11 +01:00
|
|
|
|
PPipe p1 = Pipe::query("id(hairy)");
|
|
|
|
|
|
PPipe p2 = Pipe::query("id(furry)");
|
|
|
|
|
|
PPipe pX = Pipe::query("id(curly)");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
map[p1] = p2;
|
|
|
|
|
|
CHECK (!isnil (map));
|
|
|
|
|
|
CHECK (1 == map.size());
|
|
|
|
|
|
CHECK (map[p1] == "furry");
|
2010-11-27 03:59:07 +01:00
|
|
|
|
CHECK (map[p1].isValid());
|
|
|
|
|
|
CHECK (map[p1]);
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (!map.contains (pX));
|
|
|
|
|
|
CHECK (!map.contains (p2));
|
|
|
|
|
|
|
|
|
|
|
|
// create an unconnected mapping
|
|
|
|
|
|
map[pX].disconnect();
|
|
|
|
|
|
CHECK (map.contains (pX));
|
|
|
|
|
|
CHECK (!map[pX].isValid());
|
2010-11-27 03:59:07 +01:00
|
|
|
|
CHECK (!map[pX]);
|
2010-11-23 03:40:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
instance_copy()
|
|
|
|
|
|
{
|
|
|
|
|
|
Mapping m1;
|
|
|
|
|
|
|
2012-12-26 02:20:11 +01:00
|
|
|
|
PPipe p1 = Pipe::query("id(hairy)");
|
|
|
|
|
|
PPipe p2 = Pipe::query("id(furry)");
|
|
|
|
|
|
PPipe pi = Pipe::query("id(nappy)");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2010-11-24 06:21:32 +01:00
|
|
|
|
m1[pi] = p1;
|
2010-11-23 03:40:11 +01:00
|
|
|
|
Mapping m2(m1);
|
|
|
|
|
|
CHECK (!isnil (m2));
|
|
|
|
|
|
CHECK (1 == m2.size());
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (m1[pi] == "hairy");
|
|
|
|
|
|
CHECK (m2[pi] == "hairy");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2010-11-24 06:21:32 +01:00
|
|
|
|
m1[pi] = p2;
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (m1[pi] == "furry");
|
|
|
|
|
|
CHECK (m2[pi] == "hairy");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
m2 = m1;
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (m1[pi] == "furry");
|
|
|
|
|
|
CHECK (m2[pi] == "furry");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
m1.clear();
|
|
|
|
|
|
CHECK (isnil(m1));
|
|
|
|
|
|
CHECK (!isnil(m2));
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (m2[pi] == "furry");
|
|
|
|
|
|
CHECK (!m1.contains (pi));
|
2010-11-23 03:40:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
default_mapping()
|
|
|
|
|
|
{
|
|
|
|
|
|
Mapping map;
|
|
|
|
|
|
CHECK (isnil (map));
|
|
|
|
|
|
|
2012-12-26 02:20:11 +01:00
|
|
|
|
PPipe p1 = Pipe::query("stream(hairy)");
|
|
|
|
|
|
PPipe p2 = Pipe::query("stream(furry)");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (map[p1] == "master_hairy");
|
|
|
|
|
|
CHECK (map[p2] == "master_furry");
|
|
|
|
|
|
|
|
|
|
|
|
// create new mapping to an explicitly queried target
|
|
|
|
|
|
Query<Pipe> some_pipe ("pipe(super_curly)");
|
|
|
|
|
|
CHECK (map[some_pipe] == "super_curly");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
2010-11-28 05:18:57 +01:00
|
|
|
|
// create a new mapping to the 2nd master for "furry" data
|
2010-11-23 03:40:11 +01:00
|
|
|
|
Query<Pipe> special_bus ("stream(furry), ord(2)");
|
2010-11-28 05:18:57 +01:00
|
|
|
|
CHECK (map[special_bus] == "master_furry.2");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
2023-06-07 04:03:00 +02:00
|
|
|
|
LAUNCHER (OutputMapping_test, "unit session");
|
2010-11-23 03:40:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}} // namespace steam::mobject::test
|