Lumiera  0.pre.03
»edit your freedom«
output-slot-connection.hpp
Go to the documentation of this file.
1 /*
2  OUTPUT-SLOT-CONNECTION.hpp - implementation API for concrete output slots
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 
29 #ifndef STEAM_PLAY_OUTPUT_SLOT_CONNECTION_H
30 #define STEAM_PLAY_OUTPUT_SLOT_CONNECTION_H
31 
32 
33 #include "lib/error.hpp"
34 #include "lib/nocopy.hpp"
37 #include "lib/iter-adapter-stl.hpp"
38 #include "lib/iter-source.hpp"
39 #include "lib/handle.hpp"
40 //#include "lib/time/timevalue.hpp"
41 //#include "steam/engine/buffer-provider.hpp"
42 //#include "steam/play/timings.hpp"
43 //#include "lib/sync.hpp"
44 
45 //#include <string>
46 #include <functional>
47 #include <vector>
48 //#include <memory>
49 
50 
51 namespace steam {
52 namespace play {
53 
55 //using steam::engine::BufferProvider;
56 //using lib::time::Time;
57 //using std::string;
59 
60 //using std::placeholders::_1;
61 //using std::bind;
62  using std::vector;
63 //using std::shared_ptr;
64 
65 
66 
67 
90  {
91  public:
92  virtual ~Connection();
93 
94  virtual BuffHandle claimBufferFor(FrameID) =0;
95  virtual bool isTimely (FrameID, TimeValue) =0;
96  virtual void transfer (BuffHandle const&) =0;
97  virtual void pushout (BuffHandle const&) =0;
98  virtual void discard (BuffHandle const&) =0;
99  virtual void shutDown () =0;
100  };
101 
102 
103 
112  : public OutputSlot::Allocation
114  {
115  public:
116  virtual ~ConnectionState() { }
117 
118  virtual Connection& access (uint) const =0;
119  };
120 
121 
122 
123 
124  /* ===== Building blocks for OutputSlot implementation ===== */
125 
128  : public OutputSlot
129  {
130  protected:
131  template<class CON>
133  };
134 
135 
153  template<class CON>
156  {
159 
160  Connections connections_;
161 
162 
163  /* == Allocation Interface == */
164 
165  OpenedSinks
166  getOpenedSinks()
167  {
169  REQUIRE (this->isActive());
170  return lib::iter_source::transform (eachElm(connections_), connectOutputSink);
171  }
172 
173  Timings
174  getTimingConstraints()
175  {
176  UNIMPLEMENTED ("find out about timing constraints");
177  }
178 
179  bool
180  isActive() const
181  {
182  return 0 < connections_.size();
183  }
184 
185  CON&
186  access (uint chanNr) const
187  {
188  return connections_[chanNr];
189  }
190 
191 
192  protected: /* == API for OutputSlot-Impl == */
193  void
194  init()
195  {
197  connections_.populate_by (&ConnectionManager::buildConnection, this);
198  }
199 
200  typedef typename Connections::ElementHolder& ConnectionStorage;
201 
204  virtual void buildConnection(ConnectionStorage) =0;
205 
206 
207  ConnectionManager(uint numChannels)
208  : connections_(numChannels)
209  { }
210 
211  public:
212  virtual
214  { }
215 
216 
217 
218  private: // Implementation details
219 
220  static DataSink
221  connectOutputSink (CON& connection)
222  {
223  TRACE (test, "activating Con=%p", &connection );
224 
225  DataSink newSink;
226  newSink.activate(&connection, shutdownConnection);
227  return newSink;
228  }
229 
230  static void
231  shutdownConnection (OutputSlot::Connection* toClose)
232  {
233  REQUIRE (toClose);
234  toClose->shutDown();
235  }
236  };
237 
238 
239 
240 
241 }} // namespace steam::play
242 #endif
An (abstract) capability to send media data to an external output.
Definition: run.hpp:40
Generic frame timing specification.
Definition: timings.hpp:86
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
Maintaining a list of active connections.
denotes an opened connection ready to receive media data for output.
Steam-Layer implementation namespace root.
void populate_by(CTOR builder)
init all elements at once, invoking a builder functor for each.
Managing a collection of non-copyable polymorphic objects in compact storage.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Base for OutputSlot standard implementation.
Extension point for Implementation.
_SeqT< CON >::Range eachElm(CON &coll)
Lumiera error handling (C++ interface).
Interface: Generic output sink.
Handle for a buffer for processing data, abstracting away the actual implementation.
Definition: buffhandle.hpp:111
Handle & activate(IMP *impl, DEL whenDead)
Activation of the handle by the managing service.
Definition: handle.hpp:112
A generic opaque handle to an implementation entity, including lifecycle management.
Preconfigured adapters for some STL container standard usage situations.
Extension module to build an opaque data source, accessible as Lumiera Forward Iterator.
basic constant internal time value.
Definition: timevalue.hpp:133