get rid of the QuantiserRef

this is going to become soooo complicated
better just bite the bullet and use a shared_ptr
This commit is contained in:
Fischlurch 2011-01-15 00:52:02 +01:00
parent 457d4fb7c4
commit eb89547265
6 changed files with 27 additions and 48 deletions

View file

@ -27,6 +27,7 @@
#include "lib/time/timevalue.hpp"
//#include <boost/operators.hpp>
#include <tr1/memory>
#include <string>
@ -42,27 +43,10 @@ namespace time {
class Secs;
class Quantiser; // API for grid aligning
class Quantiser; // API for grid aligning
typedef Quantiser const& QuantR;
typedef std::tr1::shared_ptr<const Quantiser> PQuant;
/**
* smart reference for accessing an existing quantiser
*/
class QuantiserRef
{
size_t hashID_;
public:
QuantiserRef (Quantiser const&);
// using standard copy;
const Quantiser *
operator-> ()
{
UNIMPLEMENTED ("how to manage and address the existing quantisers");
}
};
/**
@ -96,8 +80,8 @@ namespace time {
struct Frames
: Format
{
static void rebuild (FrameNr&, Quantiser const&, TimeValue const&);
static TimeValue evaluate (FrameNr const&, QuantiserRef);
static void rebuild (FrameNr&, QuantR, TimeValue const&);
static TimeValue evaluate (FrameNr const&, QuantR);
};
@ -110,8 +94,8 @@ namespace time {
struct Smpte
: Format
{
static void rebuild (SmpteTC&, Quantiser const&);
static TimeValue evaluate (SmpteTC const&, QuantiserRef);
static void rebuild (SmpteTC&, QuantR);
static TimeValue evaluate (SmpteTC const&, QuantR);
};
@ -125,8 +109,8 @@ namespace time {
struct Hms
: Format
{
static void rebuild (HmsTC&, Quantiser const&);
static TimeValue evaluate (HmsTC const&, QuantiserRef);
static void rebuild (HmsTC&, QuantR);
static TimeValue evaluate (HmsTC const&, QuantR);
};
@ -142,8 +126,8 @@ namespace time {
struct Seconds
: Format
{
static void rebuild (Secs&, Quantiser const&);
static TimeValue evaluate (Secs const&, QuantiserRef);
static void rebuild (Secs&, QuantR);
static TimeValue evaluate (Secs const&, QuantR);
};

View file

@ -56,9 +56,9 @@ namespace time {
/** */
QuTime::QuTime (TimeValue raw, Quantiser const& quantisation_to_use)
QuTime::QuTime (TimeValue raw, PQuant quantisation_to_use)
: Time(raw)
, quantiser_(&quantisation_to_use)
, quantiser_(quantisation_to_use)
{ }

View file

@ -45,26 +45,21 @@ namespace time {
* by quantising the given time value
*/
void
Frames::rebuild (FrameNr& framecnt, Quantiser const& quantiser, TimeValue const& rawTime)
Frames::rebuild (FrameNr& framecnt, QuantR quantiser, TimeValue const& rawTime)
{
framecnt.setValueRaw(quantiser.gridPoint (rawTime));
}
/** calculate the time point denoted by this frame count */
TimeValue
Frames::evaluate (FrameNr const& framecnt, QuantiserRef quantiser)
Frames::evaluate (FrameNr const& framecnt, QuantR quantiser)
{
return quantiser->timeOf (framecnt);
return quantiser.timeOf (framecnt);
}
}
/** */
QuantiserRef::QuantiserRef (Quantiser const&)
: hashID_(123) /////////////////////////////////////////////////TODO
{ }
/** */
FrameNr::FrameNr (QuTime const& quantisedTime)

View file

@ -59,8 +59,8 @@ namespace time {
Time getTime() const { return Time(value()); }
protected:
TCode (QuantiserRef const& qID)
: qID_(qID)
TCode (PQuant const& quant)
: quantiser_(quant)
{ }
virtual string show() const =0;
@ -68,7 +68,7 @@ namespace time {
virtual TimeValue value() const =0;
protected:
QuantiserRef qID_;
PQuant quantiser_;
};
@ -88,7 +88,7 @@ namespace time {
string show() const { return string(show())+"fr"; }
Literal tcID() const { return "Frame-count"; }
TimeValue value() const { return Format::evaluate (*this, qID_); }
TimeValue value() const { return Format::evaluate (*this, *quantiser_); }
public:
typedef format::Frames Format;

View file

@ -47,13 +47,13 @@ namespace time {
class QuTime
: public Time
{
const Quantiser *quantiser_;
PQuant quantiser_;
public:
QuTime (TimeValue raw, Symbol gridID);
QuTime (TimeValue raw, Quantiser const& quantisation_to_use);
QuTime (TimeValue raw, PQuant quantisation_to_use);
operator QuantiserRef() const;
operator PQuant() const;
template<class FMT>
bool supports() const;
@ -72,10 +72,10 @@ namespace time {
/* == implementation == */
inline
QuTime::operator QuantiserRef() const
QuTime::operator PQuant() const
{
ASSERT (quantiser_);
return QuantiserRef(*quantiser_);
return quantiser_;
}
template<class FMT>

View file

@ -90,7 +90,7 @@ namespace test{
void
check_theFullStory (TimeValue org)
{
FixedFrameQuantiser fixQ(25);
PQuant fixQ (new FixedFrameQuantiser(25));
QuTime qVal (org, fixQ);
CHECK ( qVal.supports<format::Frames>());