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) 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 
38 #ifndef STEAM_PLAY_OUTPUT_SLOT_CONNECTION_H
39 #define STEAM_PLAY_OUTPUT_SLOT_CONNECTION_H
40 
41 
42 #include "lib/error.hpp"
43 #include "lib/nocopy.hpp"
46 #include "lib/iter-adapter-stl.hpp"
47 #include "lib/iter-source.hpp"
48 #include "lib/handle.hpp"
49 //#include "lib/time/timevalue.hpp"
50 //#include "steam/engine/buffer-provider.hpp"
51 //#include "steam/play/timings.hpp"
52 //#include "lib/sync.hpp"
53 
54 //#include <string>
55 #include <functional>
56 #include <vector>
57 //#include <memory>
58 
59 
60 namespace steam {
61 namespace play {
62 
64 //using steam::engine::BufferProvider;
65 //using lib::time::Time;
66 //using std::string;
68 
69 //using std::placeholders::_1;
70 //using std::bind;
71  using std::vector;
72 //using std::shared_ptr;
73 
74 
75 
76 
99  {
100  public:
101  virtual ~Connection();
102 
103  virtual BuffHandle claimBufferFor(FrameID) =0;
104  virtual bool isTimely (FrameID, TimeValue) =0;
105  virtual void transfer (BuffHandle const&) =0;
106  virtual void pushout (BuffHandle const&) =0;
107  virtual void discard (BuffHandle const&) =0;
108  virtual void shutDown () =0;
109  };
110 
111 
112 
121  : public OutputSlot::Allocation
123  {
124  public:
125  virtual ~ConnectionState() { }
126 
127  virtual Connection& access (uint) const =0;
128  };
129 
130 
131 
132 
133  /* ===== Building blocks for OutputSlot implementation ===== */
134 
137  : public OutputSlot
138  {
139  protected:
140  template<class CON>
142  };
143 
144 
162  template<class CON>
165  {
168 
169  Connections connections_;
170 
171 
172  /* == Allocation Interface == */
173 
174  OpenedSinks
175  getOpenedSinks()
176  {
178  REQUIRE (this->isActive());
179  return lib::iter_source::transform (eachElm(connections_), connectOutputSink);
180  }
181 
182  Timings
183  getTimingConstraints()
184  {
185  UNIMPLEMENTED ("find out about timing constraints");
186  }
187 
188  bool
189  isActive() const
190  {
191  return 0 < connections_.size();
192  }
193 
194  CON&
195  access (uint chanNr) const
196  {
197  return connections_[chanNr];
198  }
199 
200 
201  protected: /* == API for OutputSlot-Impl == */
202  void
203  init()
204  {
206  connections_.populate_by (&ConnectionManager::buildConnection, this);
207  }
208 
209  typedef typename Connections::ElementHolder& ConnectionStorage;
210 
213  virtual void buildConnection(ConnectionStorage) =0;
214 
215 
216  ConnectionManager(uint numChannels)
217  : connections_(numChannels)
218  { }
219 
220  public:
221  virtual
223  { }
224 
225 
226 
227  private: // Implementation details
228 
229  static DataSink
230  connectOutputSink (CON& connection)
231  {
232  TRACE (test, "activating Con=%p", &connection );
233 
234  DataSink newSink;
235  newSink.activate(&connection, shutdownConnection);
236  return newSink;
237  }
238 
239  static void
240  shutdownConnection (OutputSlot::Connection* toClose)
241  {
242  REQUIRE (toClose);
243  toClose->shutDown();
244  }
245  };
246 
247 
248 
249 
250 }} // namespace steam::play
251 #endif
An (abstract) capability to send media data to an external output.
Definition: run.hpp:49
Generic frame timing specification.
Definition: timings.hpp:95
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
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:115
Handle & activate(IMP *impl, DEL whenDead)
Activation of the handle by the managing service.
Definition: handle.hpp:121
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:142