adapt the TimeGrid meta asset, so it can be published as Quantiser
This commit is contained in:
parent
484c771d2a
commit
02653621f6
4 changed files with 54 additions and 34 deletions
|
|
@ -73,10 +73,9 @@ namespace time {
|
|||
* the Lumiera session. Time quantisation and timecode handling explicitly
|
||||
* relies on this Quantiser interface.
|
||||
*
|
||||
* @todo WIP-WIP-WIP
|
||||
*/
|
||||
class Quantiser
|
||||
: public Grid
|
||||
: public virtual Grid
|
||||
{
|
||||
protected:
|
||||
format::Supported supportedFormats_;
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@
|
|||
#include "lib/time/quantiser.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "lib/time/display.hpp"
|
||||
#include "lib/advice.hpp"
|
||||
#include "lib/util.hpp"
|
||||
//#include "include/logging.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <string>
|
||||
|
||||
using util::cStr;
|
||||
using util::isnil;
|
||||
using boost::format;
|
||||
using boost::str;
|
||||
|
|
@ -44,10 +46,6 @@ namespace meta {
|
|||
|
||||
namespace error = lumiera::error;
|
||||
|
||||
namespace {
|
||||
|
||||
// Implementation details (still required???)
|
||||
}
|
||||
|
||||
|
||||
/** */
|
||||
|
|
@ -63,32 +61,58 @@ namespace meta {
|
|||
using lib::time::Offset;
|
||||
using lib::time::FSecs;
|
||||
|
||||
using lib::time::PQuant;
|
||||
using lib::time::Quantiser;
|
||||
using lib::time::FixedFrameQuantiser;
|
||||
using std::tr1::dynamic_pointer_cast;
|
||||
|
||||
namespace advice = lib::advice;
|
||||
|
||||
namespace {
|
||||
|
||||
/** @internal helper to retrieve the smart-ptr
|
||||
* from the AssetManager, then attach a further
|
||||
* smart-ptr-to-Quantiser to that, which then can be
|
||||
* published via the \link advice.hpp "advice system"\endlink
|
||||
*/
|
||||
inline PGrid
|
||||
publishWrapped (TimeGrid& newGrid)
|
||||
{
|
||||
PGrid gridImplementation = AssetManager::instance().wrap (newGrid);
|
||||
PQuant quantiser (dynamic_pointer_cast<const Quantiser>(gridImplementation));
|
||||
Literal bindingID (cStr(newGrid.ident.name));
|
||||
|
||||
advice::Provision<PQuant>(bindingID).setAdvice(quantiser);
|
||||
return gridImplementation;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* TimeGrid implementation: a trivial time grid,
|
||||
* starting at a given point in time and using a
|
||||
* constant grid spacing
|
||||
* constant grid spacing.
|
||||
*
|
||||
* @note The actual implementation is mixed in,
|
||||
* together with the Quantiser API; the intended use
|
||||
* of this implementation is to publish it via the advice
|
||||
* framework, when building and registering the meta asset.
|
||||
*/
|
||||
class SimpleTimeGrid
|
||||
: public TimeGrid
|
||||
, public FixedFrameQuantiser
|
||||
{
|
||||
lib::time::FixedFrameQuantiser frameGrid_;
|
||||
|
||||
/* == grid API forwarded to embedded quantiser == */
|
||||
long gridPoint (TimeValue const& rawTime) const { return frameGrid_.gridPoint (rawTime); }
|
||||
TimeValue gridAlign (TimeValue const& rawTime) const { return frameGrid_.gridAlign (rawTime); }
|
||||
TimeValue timeOf (long gridPoint) const { return frameGrid_.timeOf (gridPoint); }
|
||||
TimeValue timeOf (FSecs gridTime, int gridOffset =0) const { return frameGrid_.timeOf (gridTime,gridOffset); }
|
||||
|
||||
|
||||
public:
|
||||
SimpleTimeGrid (Time start, Duration frameDuration, EntryID<TimeGrid> const& name)
|
||||
: TimeGrid (name)
|
||||
, frameGrid_(frameDuration,start)
|
||||
, FixedFrameQuantiser(frameDuration,start)
|
||||
{ }
|
||||
|
||||
SimpleTimeGrid (Time start, FrameRate frames_per_second, EntryID<TimeGrid> const& name)
|
||||
: TimeGrid (name)
|
||||
, frameGrid_(frames_per_second,start)
|
||||
, FixedFrameQuantiser(frames_per_second,start)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -104,7 +128,7 @@ namespace meta {
|
|||
* might raise further exception when asset registration fails.
|
||||
* @todo currently (12/2010) the AssetManager is unable to detect duplicate assets.
|
||||
* Later on the intention is that in such cases, instead of creating a new grid
|
||||
* we'll silently return the already registered exisiting and equivalent grid.
|
||||
* we'll silently return the already registered existing and equivalent grid.
|
||||
*/
|
||||
P<TimeGrid>
|
||||
Builder<TimeGrid>::commit()
|
||||
|
|
@ -116,13 +140,12 @@ namespace meta {
|
|||
|
||||
if (isnil (id_))
|
||||
{
|
||||
format gridIdFormat("grid_%f_%s");
|
||||
id_ = str(gridIdFormat % fps_ % origin_);
|
||||
format gridIdFormat("grid(%f_%d)");
|
||||
id_ = str(gridIdFormat % fps_ % _raw(origin_));
|
||||
}
|
||||
EntryID<TimeGrid> nameID (id_);
|
||||
TimeGrid& newGrid (*new SimpleTimeGrid(origin_, fps_, nameID));
|
||||
|
||||
return AssetManager::instance().wrap (newGrid);
|
||||
return publishWrapped (*new SimpleTimeGrid(origin_, fps_, nameID));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -69,23 +69,21 @@ namespace meta {
|
|||
|
||||
|
||||
/**
|
||||
* Interface: a grid and scale for time quantisation.
|
||||
* This meta-Asset describes a coordinate system or
|
||||
* reference scale for quantised time values.
|
||||
* Interface: a grid and scale definition for time quantisation.
|
||||
* This meta-Asset describes a coordinate system or reference scale
|
||||
* for quantised time values. Especially it allows to define an actual
|
||||
* implementation, which can then implicitly be used by lib::time::QuTime
|
||||
* and for conversions into timecode.
|
||||
* @note for this to work, the actual implementation classes returned
|
||||
* by the builder or the static #build function additionally expose
|
||||
* an implementation of the lib::time::Quantiser API
|
||||
*/
|
||||
class TimeGrid
|
||||
: public Meta
|
||||
, public lib::time::Grid
|
||||
, public virtual lib::time::Grid
|
||||
{
|
||||
|
||||
public:
|
||||
//--------Grid-API------------------------------------
|
||||
long gridPoint (TimeValue const& raw) const =0;
|
||||
TimeValue gridAlign (TimeValue const& raw) const =0;
|
||||
TimeValue timeOf (long gridPoint) const =0;
|
||||
TimeValue timeOf (FSecs, int =0) const =0;
|
||||
|
||||
|
||||
/* === shortcut builder functions === */
|
||||
static PGrid build (Symbol gridID, FrameRate frames_per_second);
|
||||
static PGrid build (Symbol gridID, FrameRate frames_per_second, Time origin);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,6 @@ END
|
|||
|
||||
|
||||
TEST "Simple TimeGrid" TimeGridBasics_test <<END
|
||||
out-lit: simple PAL Grid: (STRUCT/time-scales:lumi.grid_25_1_0:00:00.000 v1)
|
||||
out-lit: simple PAL Grid: (STRUCT/time-scales:lumi.grid(25_1_0) v1)
|
||||
return: 0
|
||||
END
|
||||
|
|
|
|||
Loading…
Reference in a new issue