From eb8954726589cb5c7ca662b95f574441b230a1e5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 15 Jan 2011 00:52:02 +0100 Subject: [PATCH] get rid of the QuantiserRef this is going to become soooo complicated better just bite the bullet and use a shared_ptr --- src/lib/time/formats.hpp | 40 +++++++---------------- src/lib/time/quantiser.cpp | 4 +-- src/lib/time/timecode.cpp | 11 ++----- src/lib/time/timecode.hpp | 8 ++--- src/lib/time/timequant.hpp | 10 +++--- tests/lib/time/time-quantisation-test.cpp | 2 +- 6 files changed, 27 insertions(+), 48 deletions(-) diff --git a/src/lib/time/formats.hpp b/src/lib/time/formats.hpp index ca92b048c..0bd6f7788 100644 --- a/src/lib/time/formats.hpp +++ b/src/lib/time/formats.hpp @@ -27,6 +27,7 @@ #include "lib/time/timevalue.hpp" //#include +#include #include @@ -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 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); }; diff --git a/src/lib/time/quantiser.cpp b/src/lib/time/quantiser.cpp index 9b81d40a2..ac0df16a8 100644 --- a/src/lib/time/quantiser.cpp +++ b/src/lib/time/quantiser.cpp @@ -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) { } diff --git a/src/lib/time/timecode.cpp b/src/lib/time/timecode.cpp index 978739635..c4831785d 100644 --- a/src/lib/time/timecode.cpp +++ b/src/lib/time/timecode.cpp @@ -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) diff --git a/src/lib/time/timecode.hpp b/src/lib/time/timecode.hpp index fdfe5f303..978b3c503 100644 --- a/src/lib/time/timecode.hpp +++ b/src/lib/time/timecode.hpp @@ -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; diff --git a/src/lib/time/timequant.hpp b/src/lib/time/timequant.hpp index be5e82b71..161d28bfb 100644 --- a/src/lib/time/timequant.hpp +++ b/src/lib/time/timequant.hpp @@ -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 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 diff --git a/tests/lib/time/time-quantisation-test.cpp b/tests/lib/time/time-quantisation-test.cpp index 50d9d9127..ea5a6ed96 100644 --- a/tests/lib/time/time-quantisation-test.cpp +++ b/tests/lib/time/time-quantisation-test.cpp @@ -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());