Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
placement.hpp
Go to the documentation of this file.
1/*
2 PLACEMENT.hpp - Key Abstraction: a way to place and locate a Media Object
3
4 Copyright (C)
5 2008, 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
14
61#ifndef MOBJECT_PLACEMENT_H
62#define MOBJECT_PLACEMENT_H
63
64#include "lib/error.hpp"
65#include "lib/hash-indexed.hpp"
68
69#include "steam/asset/pipe.hpp"
70
71#include <memory>
72
73
74namespace steam {
75namespace mobject {
76
77 namespace session{ class MObjectFactory; }
78
79 class MObject;
80 class ExplicitPlacement;
81
82 using std::shared_ptr;
83 using std::static_pointer_cast;
84 using lib::HashIndexed;
85
86
87
105 template<class MO, class B =MObject>
106 class Placement ;
107
108
113 template<>
115 : protected shared_ptr<MObject>
116 , public HashIndexed<Placement<MObject>, lib::hash::LuidH >
117 {
118 protected:
120 using _SmartPtr = shared_ptr<MObject>;
121 typedef void (*Deleter)(MObject*);
123 using Pipe = asset::shared_ptr<asset::Pipe>;
124
125
126
127 public:
132 MObject *
134 {
135 ENSURE (*this);
136 return _SmartPtr::operator->();
137 }
138
142 template<class Y>
143 bool
145 {
146 return 0 != dynamic_cast<Y*> (get());
147 }
148
152 template<class Y>
153 void
154 extendOwnershipTo (shared_ptr<Y>& target) const
155 {
156 REQUIRE (isCompatible<Y>());
157 target = static_pointer_cast<Y>(*this);
158 }
159
161 friend bool
162 isSharedPointee (Placement const& p1, Placement const& p2)
163 {
164 return static_cast<const void*> (p1.get())
165 == static_cast<const void*> (p2.get());
166 }
167
168
169 operator string() const ;
170 size_t use_count() const { return _SmartPtr::use_count(); }
171 bool isValid() const { return _SmartPtr::use_count(); }
172
173
174 virtual ~Placement() {};
175
176
177
183
188 virtual ExplicitPlacement resolve () const;
192
193
194 Placement (Placement const& ref)
195 : _SmartPtr (ref)
196 , HashInd() // creating a new ID!
197 , chain(ref.chain)
198 { }
199
203 Placement& operator= (Placement const&) = default;
204
205 protected:
206 Placement (MObject & subject, Deleter killer)
207 : _SmartPtr (&subject, killer) { };
208
210
211
213// private:
214// /** copy assignment prohibited */
215// Placement& operator= (Placement const&);
217 };
218
219
230 template<class MO, class B>
232 : public Placement<B>
233 {
234 protected:
236 using _Id = _Parent::template Id<MO> const&;
237 using Deleter = _Parent::Deleter;
238 using _SmartPtr = _Parent::_SmartPtr;
239
240
241 Placement (MO & mo, Deleter killer)
242 : _Parent (mo, killer)
243 { };
245
246 public:
247 MO*
249 {
250 ENSURE (INSTANCEOF (MO, this->get()));
251 return static_cast<MO*>
252 (_SmartPtr::operator-> ());
253 }
254
255 _Id
256 getID () const
257 {
258 return _Parent::template recastID<MO>();
259 }
260
261 };
262
263
266 using PMO = Placement<MObject>;
267
268
269
270 /* == free functions == */
271
272 string
274
275
280 bool
281 isSameDef (PlacementMO const&, PlacementMO const&);
282
283
284
285}} // namespace steam::mobject
286#endif
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor,...
Lumiera's internal time value datatype.
Special kind of Placement, where the location of the MObject has been nailed down to a fixed position...
MObject is the interface class for all "Media Objects".
Definition mobject.hpp:72
friend bool isSharedPointee(Placement const &p1, Placement const &p2)
free function to detect two placements sharing a pointee
virtual ExplicitPlacement resolve() const
combine and resolve all constraints defined by the various LocatingPin (
session::LocatingPin chain
interface for defining the kind of placement to employ, and for controlling any additional constraint...
MObject * operator->() const
smart pointer: accessing the MObject, which is subject to placement.
HashIndexed< Placement< MObject >, lib::hash::LuidH > HashInd
bool isCompatible() const
run time diagnostics: is the pointee of this placement compatible to the given type?
void extendOwnershipTo(shared_ptr< Y > &target) const
extend shared ownership to the given smart-ptr
Placement(MObject &subject, Deleter killer)
asset::shared_ptr< asset::Pipe > Pipe
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
_Parent::_SmartPtr _SmartPtr
_Parent::template Id< MO > const & _Id
_Parent::Deleter Deleter
Placement(MO &mo, Deleter killer)
Positioning specification, possibly chained to further specifications.
Lumiera error handling (C++ interface).
A template for generating hash based ID tags carrying compile-time type info.
Implementing the Placement mechanics.
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
string format_PlacementID(Placement< MObject > const &pla)
Definition placement.cpp:60
bool isSameDef(PlacementMO const &pl1, PlacementMO const &pl2)
compare the properties of placement
Definition placement.cpp:68
Steam-Layer implementation namespace root.
A "processing pipe" represented as Asset.
A Mixin to add a private ID type to the target class, together with storage to hold an instance of th...
a family of time value like entities and their relationships.
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.
Definition util.hpp:514