Lumiera  0.pre.03
»edit your freedom«
dummy-builder-context.hpp
Go to the documentation of this file.
1 /*
2  DUMMY-BUILDER-CONTEXT.hpp - fake simulated builder result for player tests
3 
4  Copyright (C)
5  2011, 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 
37 #ifndef STEAM_PLAY_DUMMY_BUILDER_CONTEXT_H
38 #define STEAM_PLAY_DUMMY_BUILDER_CONTEXT_H
39 
40 
45 #include "steam/asset/timeline.hpp"
46 #include "steam/asset/pipe.hpp"
47 #include "common/query.hpp"
48 
49 #include "lib/iter-source.hpp"
50 #include "lib/nocopy.hpp"
51 #include "lib/util.hpp"
52 
53 #include <vector>
54 
55 
56 namespace steam{
57 namespace play {
58 namespace test {
59 
60  using fixture::ModelPortRegistry;
61 
62 
68  {
69  BuffHandle claimBufferFor(FrameID) override { UNIMPLEMENTED ("claimBufferFor(FrameID)"); }
70  bool isTimely (FrameID, TimeValue) override { return true; }
71  void transfer (BuffHandle const&) override { UNIMPLEMENTED ("transfer (BuffHandle const&)"); }
72  void pushout (BuffHandle const&) override { UNIMPLEMENTED ("pushout (BuffHandle const&)"); }
73  void discard (BuffHandle const&) override { UNIMPLEMENTED ("discard (BuffHandle const&)"); }
74  void shutDown () override { UNIMPLEMENTED ("shutDown() Connection"); }
75 
76  public:
78  UnimplementedConnection() = default;
79  };
80 
81 
82  using asset::Pipe;
83  using asset::PPipe;
84  using asset::Struct;
85  using asset::Timeline;
86  using asset::PTimeline;
87  using mobject::ModelPort;
89  using util::contains;
90  using lumiera::Query;
91 
92 
93  using PID = asset::ID<Pipe>;
94  using TID = asset::ID<Struct>;
95 
97  using DummyOutputLink = std::pair<mobject::ModelPort, play::DataSink>;
98 
99 
100  inline PID
101  getPipe (string id)
102  {
103  return Pipe::query ("id("+id+")");
104  }
105 
106  inline TID
107  getTimeline (string id)
108  {
109  return asset::Struct::retrieve (Query<Timeline> ("id("+id+")"))->getID();
110  }
111 
112  const uint NUMBER_OF_PORTS = 2;
113  const string namePortA("bus-A");
114  const string namePortB("bus-B");
115 
123  {
124  ModelPortRegistry registry_;
125  ModelPortRegistry* existingRegistry_;
126 
127  std::vector<ModelPort> modelPorts_;
128  std::vector<DataSink> dataSinks_;
129 
132  : registry_()
133  , existingRegistry_(ModelPortRegistry::setActiveInstance (registry_))
134  {
135  performMockBuild();
136  }
137 
140  {
141  if (existingRegistry_)
142  ModelPortRegistry::setActiveInstance (*existingRegistry_);
143  else
145  }
146 
147  void
148  performMockBuild()
149  {
150  PID pipeA = getPipe (namePortA);
151  PID pipeB = getPipe (namePortB);
152  TID someTimeline = getTimeline ("dummy_Timeline");
153 
154  // start out with defining some new model ports......
155  registry_.definePort (pipeA, someTimeline);
156  registry_.definePort (pipeB, someTimeline);
157 
158  registry_.commit();
159 
160  // now "bus-A" and "bus-B" are known as model ports
161  modelPorts_.push_back (ModelPort(pipeA));
162  modelPorts_.push_back (ModelPort(pipeB));
163 
164  // prepare corresponding placeholder DataSink (a fake active output connection)
165  dataSinks_.emplace_back().activate(std::make_shared<UnimplementedConnection>());
166  dataSinks_.emplace_back().activate(std::make_shared<UnimplementedConnection>());
167  }
168 
169 
170  ModelPorts
171  getAllModelPorts()
172  {
173  return lib::iter_source::eachEntry (modelPorts_.begin(), modelPorts_.end());
174  }
175 
176  DummyOutputLink
177  getModelPort (uint index)
178  {
179  REQUIRE (index < modelPorts_.size());
180  return {modelPorts_[index]
181  ,dataSinks_[index]
182  };
183  }
184  };
185 
186 
187 }}} // namespace steam::play::test
188 #endif /*STEAM_PLAY_DUMMY_BUILDER_CONTEXT_H*/
Organising the output data calculation possibilities.
ModelPortDescriptor const & definePort(PID pipe, StID element_exposing_this_port)
create and register a new model port entry, within the pending transaction
A "processing pipe" represented as Asset.
Basic and generic representation of an internal query.
void commit()
activate pending model port changes.
Definition: run.hpp:40
Mutation and management facility for model ports within the builder.
Steam-Layer implementation namespace root.
structural asset corresponding to the part of the model forming a processing pipe for generating medi...
Definition: pipe.hpp:70
static StructFactory retrieve
storage for the static StructFactory instance
Definition: struct.hpp:107
static ModelPortRegistry * setActiveInstance(ModelPortRegistry &newRegistry)
switch the implicit link to the global ModelPort registry to point to the given implementation instan...
static void shutdown()
globally deactivate access to model ports
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Management facility for tracking model ports.
helper for dummy render engine: Simulate the result of a build process, without actually running the ...
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Interface for concrete output implementations to talk to the OutputSlot frontend. ...
static PPipe query(string const &properties)
convenience shortcut for retrieving default configured pipes
Definition: pipe.cpp:57
Handle designating a point within the model, where actually output data can be pulled.
Definition: model-port.hpp:95
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
A global service to handle all external output connections.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:71
key abstraction: structural asset Created automatically as a sideeffect of building the structure of ...
Definition: struct.hpp:104
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
basic constant internal time value.
Definition: timevalue.hpp:133
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition: query.hpp:270
Top level structural element within the session.