Lumiera  0.pre.03
»edit your freedom«
render-configurator.cpp
Go to the documentation of this file.
1 /*
2  RenderConfigurator - strategy to help building an actual render calculation stream
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 
23 
31 #include "lib/error.hpp"
35 //#include "lib/itertools.hpp"
36 
37 //#include <string>
38 //#include <memory>
39 #include <memory>
40 #include <functional>
41 
42 
43 
44 namespace steam {
45 namespace play {
46 
47  namespace error = lumiera::error;
48 // using std::string;
49 // using lumiera::Subsys;
50  using std::shared_ptr;
51  using std::bind;
52  using std::placeholders::_1;
53  using engine::EngineService;
54 
55  typedef EngineService::QoS_Definition RenderQuality;
56 
57 
58  namespace { // Implementation details...
59 
60 // using std::bind;
61 // using std::function;
62 // using std::placeholders::_1;
63 // using lib::transform;
64 
66  : public RenderConfigurator
67  {
68 
69  POutputManager outputResolver_;
70  Timings playbackTimings_;
71  RenderQuality renderQuality_;
72 
73 
74  OutputSlot&
76  {
77  REQUIRE (outputResolver_);
78  OutputSlot& slot = outputResolver_->getOutputFor (port);
79  if (!slot.isFree())
80  throw error::State{"unable to acquire a suitable output slot"
81  , LERR_(CANT_PLAY)};
82  return slot;
83  }
84 
85 
86  engine::CalcStreams
88  {
89  OutputSlot::Allocation& activeOutputConnection = output.allocate();
90  Timings nominalTimings = activeOutputConnection.getTimingConstraints()
91  .constrainedBy(playbackTimings_);
92 
93  return activateEngine (port, nominalTimings, activeOutputConnection, renderQuality_);
94  }
95 
96 
97  engine::CalcStreams
98  activateEngine (ModelPort port, Timings timings, OutputSlot::Allocation& activeOutputConnection, RenderQuality quality)
99  {
100  return EngineService::instance().calculate (port, timings, activeOutputConnection, quality);
101  }
102 
103 
104  public:
105  LumieraRenderProcessBuilder (POutputManager outputManager, Timings playbackSpeed)
106  : outputResolver_(outputManager)
107  , playbackTimings_(playbackSpeed)
108  , renderQuality_(EngineService::QoS_DEFAULT)
109  { }
110 
111  };
112 
113 
114 
117  inline RenderConfigurator*
118  how_to_render (POutputManager outputPossibilities, Timings playTimings)
119  {
120  return new LumieraRenderProcessBuilder (outputPossibilities, playTimings);
121  }
122 
123 
124  } // (End) hidden service impl details
125 
126 
127 
128 
129  RenderConfigurator::~RenderConfigurator() { } // emit VTable here...
130 
131 
136  Feed
138  {
139  OutputSlot& slot = getOutputFor (port);
140  return Feed (buildCalculationStreams (port,slot));
141  }
142 
143 
144 
145 
160  RenderConfigurator::ConnectFunction
161  buildRenderConfiguration (POutputManager outputPossibilities, Timings playTimings)
162  {
163  shared_ptr<RenderConfigurator> specialConfig{how_to_render (outputPossibilities,playTimings)};
164 
165  return [specialConfig](ModelPort port)
166  {
167  return specialConfig->buildActiveFeed(port);
168  };
169  }
170 
171 
172 
173 }} // namespace steam::play
Access point for the (core) calculation service of the render engine.
virtual ~RenderConfigurator()
this is an interface
Strategy to hold all the detail knowledge necessary to establish a running render CalculationStream...
Generic frame timing specification.
Definition: timings.hpp:95
RenderConfigurator * how_to_render(POutputManager outputPossibilities, Timings playTimings)
engine::CalcStreams buildCalculationStreams(ModelPort port, OutputSlot &output)
build active rendering connections, thereby delivering each channel of the given model port into the ...
Steam-Layer implementation namespace root.
static lib::Depend< EngineService > instance
access point to the Engine Interface.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
Feed buildActiveFeed(ModelPort)
Template Method: how to build an active render feed, pulling from the given exit point of the model a...
bool isFree() const
can this OutputSlot be allocated?
Definition: output-slot.cpp:61
RenderConfigurator::ConnectFunction buildRenderConfiguration(POutputManager outputPossibilities, Timings playTimings)
Factory function to build a RenderConfigurator specifically tailored for a PlayProcess, about to be started.
Lumiera error handling (C++ interface).
Handle designating a point within the model, where actually output data can be pulled.
Definition: model-port.hpp:104
Interface: Generic output sink.
Allocation & allocate()
claim this slot for exclusive use
Definition: output-slot.cpp:82
A global service to handle all external output connections.
Rendering data feed, corresponding to a single global pipe and to be delivered into a single OutputSl...
OutputSlot & getOutputFor(ModelPort port)
retrieve a suitable output sink for the data to be produced at the given model exit point...
Strategy for configuring the render process.