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) Lumiera.org
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
46 #ifndef STEAM_PLAY_DUMMY_BUILDER_CONTEXT_H
47 #define STEAM_PLAY_DUMMY_BUILDER_CONTEXT_H
48 
49 
54 #include "steam/asset/timeline.hpp"
55 #include "steam/asset/pipe.hpp"
56 #include "common/query.hpp"
57 
58 #include "lib/iter-source.hpp"
59 #include "lib/nocopy.hpp"
60 #include "lib/util.hpp"
61 
62 #include <vector>
63 
64 
65 namespace steam{
66 namespace play {
67 namespace test {
68 
69  using fixture::ModelPortRegistry;
70 
71 
77  {
78  BuffHandle claimBufferFor(FrameID) override { UNIMPLEMENTED ("claimBufferFor(FrameID)"); }
79  bool isTimely (FrameID, TimeValue) override { return true; }
80  void transfer (BuffHandle const&) override { UNIMPLEMENTED ("transfer (BuffHandle const&)"); }
81  void pushout (BuffHandle const&) override { UNIMPLEMENTED ("pushout (BuffHandle const&)"); }
82  void discard (BuffHandle const&) override { UNIMPLEMENTED ("discard (BuffHandle const&)"); }
83  void shutDown () override { UNIMPLEMENTED ("shutDown() Connection"); }
84 
85  public:
87  UnimplementedConnection() = default;
88  };
89 
90 
91  using asset::Pipe;
92  using asset::PPipe;
93  using asset::Struct;
94  using asset::Timeline;
95  using asset::PTimeline;
96  using mobject::ModelPort;
98  using util::contains;
99  using lumiera::Query;
100 
101 
102  using PID = asset::ID<Pipe>;
103  using TID = asset::ID<Struct>;
104 
106  using DummyOutputLink = std::pair<mobject::ModelPort, play::DataSink>;
107 
108 
109  inline PID
110  getPipe (string id)
111  {
112  return Pipe::query ("id("+id+")");
113  }
114 
115  inline TID
116  getTimeline (string id)
117  {
118  return asset::Struct::retrieve (Query<Timeline> ("id("+id+")"))->getID();
119  }
120 
121  const uint NUMBER_OF_PORTS = 2;
122  const string namePortA("bus-A");
123  const string namePortB("bus-B");
124 
132  {
133  ModelPortRegistry registry_;
134  ModelPortRegistry* existingRegistry_;
135 
136  std::vector<ModelPort> modelPorts_;
137  std::vector<DataSink> dataSinks_;
138 
141  : registry_()
142  , existingRegistry_(ModelPortRegistry::setActiveInstance (registry_))
143  {
144  performMockBuild();
145  }
146 
149  {
150  if (existingRegistry_)
151  ModelPortRegistry::setActiveInstance (*existingRegistry_);
152  else
154  }
155 
156  void
157  performMockBuild()
158  {
159  PID pipeA = getPipe (namePortA);
160  PID pipeB = getPipe (namePortB);
161  TID someTimeline = getTimeline ("dummy_Timeline");
162 
163  // start out with defining some new model ports......
164  registry_.definePort (pipeA, someTimeline);
165  registry_.definePort (pipeB, someTimeline);
166 
167  registry_.commit();
168 
169  // now "bus-A" and "bus-B" are known as model ports
170  modelPorts_.push_back (ModelPort(pipeA));
171  modelPorts_.push_back (ModelPort(pipeB));
172 
173  // prepare corresponding placeholder DataSink (a fake active output connection)
174  dataSinks_.emplace_back().activate(std::make_shared<UnimplementedConnection>());
175  dataSinks_.emplace_back().activate(std::make_shared<UnimplementedConnection>());
176  }
177 
178 
179  ModelPorts
180  getAllModelPorts()
181  {
182  return lib::iter_source::eachEntry (modelPorts_.begin(), modelPorts_.end());
183  }
184 
185  DummyOutputLink
186  getModelPort (uint index)
187  {
188  REQUIRE (index < modelPorts_.size());
189  return {modelPorts_[index]
190  ,dataSinks_[index]
191  };
192  }
193  };
194 
195 
196 }}} // namespace steam::play::test
197 #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:49
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:79
static StructFactory retrieve
storage for the static StructFactory instance
Definition: struct.hpp:116
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:66
Handle designating a point within the model, where actually output data can be pulled.
Definition: model-port.hpp:104
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:115
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:80
key abstraction: structural asset Created automatically as a sideeffect of building the structure of ...
Definition: struct.hpp:113
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
basic constant internal time value.
Definition: timevalue.hpp:142
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
Definition: query.hpp:279
Top level structural element within the session.