WIP rework timecode format hierarchy

second try: eliminate base class,
work with concrete formats allways...
This commit is contained in:
Fischlurch 2011-01-05 02:43:29 +01:00
parent 336264a6be
commit e7f5ce9e33
12 changed files with 195 additions and 99 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -92,10 +92,10 @@ namespace time {
* @todo WIP-WIP-WIP
*/
class Digxel
: public boost::totally_ordered<Digxel,
boost::totally_ordered<Digxel, int,
boost::totally_ordered<Digxel, double
> > >
// : public boost::totally_ordered<Digxel,
// boost::totally_ordered<Digxel, int,
// boost::totally_ordered<Digxel, double
// > > >
{
typedef const char* CBuf;
@ -103,29 +103,23 @@ namespace time {
virtual ~Digxel (); ///< this is an ABC
operator int() const { return getIntValue(); }
operator double() const { return getDoubleValue(); }
CBuf show() { return getFormatted(); }
void operator= (int i) { return changeTo(i); }
void operator= (double d){ return changeTo(d); }
// Supporting totally_ordered
bool operator< (Digxel const& o) const { return double(*this) < double(o); }
bool operator== (Digxel const& o) const { return double(*this) == double(o); }
bool operator== (int i) const { return int(*this) == i ; }
bool operator< (int i) const { return int(*this) < i ; }
bool operator> (int i) const { return int(*this) > i ; }
bool operator== (double d) const { return double(*this) == d ; }
bool operator< (double d) const { return double(*this) < d ; }
bool operator> (double d) const { return double(*this) > d ; }
// // Supporting totally_ordered
// bool operator< (Digxel const& o) const { return double(*this) < double(o); }
// bool operator== (Digxel const& o) const { return double(*this) == double(o); }
// bool operator== (int i) const { return int(*this) == i ; }
// bool operator< (int i) const { return int(*this) < i ; }
// bool operator> (int i) const { return int(*this) > i ; }
// bool operator== (double d) const { return double(*this) == d ; }
// bool operator< (double d) const { return double(*this) < d ; }
// bool operator> (double d) const { return double(*this) > d ; }
protected:
virtual int getIntValue() const =0;
virtual double getDoubleValue() const =0;
virtual CBuf getFormatted() =0;
virtual void changeTo (int i) =0;
virtual void changeTo (double d) =0;
};
namespace digxel {
@ -225,29 +219,23 @@ namespace time {
return ValTrait<NUM>::asInt (value_);
}
double
getDoubleValue() const
{
return ValTrait<NUM>::asDouble (value_);
}
CBuf
getFormatted()
{
UNIMPLEMENTED("call formatting or cache");
}
void
changeTo (int i)
{
UNIMPLEMENTED("mutate INT");
}
void
changeTo (double d)
{
UNIMPLEMENTED("mutate FLOAT");
}
//
// void
// changeTo (int i)
// {
// UNIMPLEMENTED("mutate INT");
// }
//
// void
// changeTo (double d)
// {
// UNIMPLEMENTED("mutate FLOAT");
// }
public:

View file

@ -118,7 +118,46 @@ namespace time {
static const Frames FRAMES;
static const Smpte SMPTE;
static const Hms HMS;
}
// ====== forward declarationss of concrete Timecode types
class FrameNr;
class SmpteTC;
class HmsTC;
class Secs;
namespace format {
template<class FMT>
struct Traits;
template<>
struct Traits<Frames>
{
typedef FrameNr TimeCode;
};
template<>
struct Traits<Smpte>
{
typedef SmpteTC TimeCode;
};
template<>
struct Traits<Hms>
{
typedef HmsTC TimeCode;
};
template<>
struct Traits<Seconds>
{
typedef Secs TimeCode;
};
}}} // lib::time::format
#endif

View file

@ -34,6 +34,7 @@ namespace time {
Format::~Format() { } // emit VTable here....
TCode::~TCode() { }
/** */

View file

@ -38,20 +38,19 @@ namespace time {
/**
* fixed format time specification.
* @param FMT the actual timecode format to use
* Interface: fixed format timecode specification.
* @see time::Format
* @todo WIP-WIP-WIP
*/
template<class FMT>
class TCode
{
public:
virtual ~TCode();
string describe() const;
virtual string show() const =0;
virtual string describe() const =0;
virtual Time getTime() const =0;
};
@ -65,12 +64,11 @@ namespace time {
* FrameNr values interchangeable with integral numbers.
*/
class FrameNr
: public TCode<format::Frames>
: public TCode
{
public:
FrameNr (QuTime const& quantisedTime);
FrameNr (TCode<format::Frames> const&);
operator long() const;
};
@ -81,12 +79,11 @@ namespace time {
*
*/
class SmpteTC
: public TCode<format::Smpte>
: public TCode
{
public:
SmpteTC (QuTime const& quantisedTime);
SmpteTC (TCode<format::Smpte> const&);
int getSecs () const;
int getMins () const;
@ -96,5 +93,38 @@ namespace time {
/**
*
*/
class HmsTC
: public TCode
{
public:
HmsTC (QuTime const& quantisedTime);
double getMillis () const;
int getSecs () const;
int getMins () const;
int getHours () const;
};
/**
*
*/
class Secs
: public TCode
{
public:
Secs (QuTime const& quantisedTime);
operator FSecs() const;
};
}} // lib::time
#endif

View file

@ -56,7 +56,8 @@ namespace time {
bool supports() const;
template<class FMT>
TCode<FMT> formatAs() const;
typename format::Traits<FMT>::TimeCode
formatAs() const;
};

View file

@ -95,21 +95,27 @@ namespace test{
CHECK ( qVal.supports<format::Frames>());
CHECK ( qVal.supports<format::Smpte>());
TCode<format::Smpte> smpteTCode = qVal.formatAs<format::Smpte>();
SmpteTC smpteTCode = qVal.formatAs<format::Smpte>();
showTimeCode (smpteTCode);
TCode<format::Frames> frameTCode = qVal.formatAs<format::Frames>();
HmsTC pureTimeCode = qVal.formatAs<format::Hms>();
showTimeCode (pureTimeCode);
FrameNr frameTCode = qVal.formatAs<format::Frames>();
showTimeCode (frameTCode);
FrameNr count(frameTCode);
// CHECK (string(count) == frameTCode.part[0]));
Secs seconds = qVal.formatAs<format::Seconds>();
showTimeCode (seconds);
}
template<class TC>
void
showTimeCode (TC timecodeValue)
{
// cout << timecodeValue.describe() << " = " << join (timecodeValue.part(), ":") << endl;
cout << timecodeValue.describe()
<< " time = "<< timecodeValue.getTime()
<< " code = "<< timecodeValue.show()
<< endl;
}
@ -140,7 +146,7 @@ namespace test{
TimeGrid::build("special_funny_grid", 1); // provide the grid's definition (1 frame per second)
int cnt = 0;//////funny.formatAs<format::Frames>().part["count"];
int cnt = funny.formatAs<format::Frames>();
// and now performing quantisation is OK
SmpteTC smpte (funny); // also converting into SMPTE (which implies frame quantisation)
CHECK (0 == smpte.getFrames()); // we have 1fps, thus the frame part is always zero!

View file

@ -1,6 +1,6 @@
format 58
"CommonLib" // CommonLib
revision 23
revision 24
modified_by 5 "hiv"
// class settings
//class diagram settings
@ -956,14 +956,23 @@ ${inlines}
b parent class_ref 134917 // Time
end
classrelation 208901 // <unidirectional association>
relation 198021 --->
classrelation 212613 // <unidirectional association>
relation 201733 --->
a role_name "" protected
cpp default " ${comment}${static}${mutable}${volatile}${const}${type}* ${name}${value};
"
classrelation_ref 212613 // <unidirectional association>
b parent class_ref 170885 // FrameNr
end
classrelation 212741 // <unidirectional association>
relation 201861 --->
stereotype "yield"
a role_name "" protected
cpp default " ${comment}${static}${mutable}${volatile}${const}${type}* ${name}${value};
"
classrelation_ref 208901 // <unidirectional association>
b parent class_ref 170629 // TCode
classrelation_ref 212741 // <unidirectional association>
b parent class_ref 172677 // SmpteTC
end
end
@ -1099,9 +1108,6 @@ ${inlines}
class 170629 "TCode"
visibility package
nformals 1
formal name "F" type "class" explicit_default_value ""
explicit_extends ""
cpp_decl "${comment}${template}class ${name}${inherit}
{
${members} };
@ -1121,13 +1127,6 @@ ${inlines}
b parent class_ref 170629 // TCode
end
classrelation 208773 // <dependency>
relation 197893 -_->
a default
cpp default "#include in source"
classrelation_ref 208773 // <dependency>
b parent class_ref 170757 // Format
end
end
class 170757 "Format"
@ -1147,9 +1146,6 @@ ${inlines}
class 170885 "FrameNr"
visibility package
nactuals 1
actual class class_ref 170629 // TCode
rank 0 explicit_value ""
cpp_decl "${comment}${template}class ${name}${inherit}
{
${members} };
@ -1282,9 +1278,6 @@ ${inlines}
class 172677 "SmpteTC"
visibility package
nactuals 1
actual class class_ref 170629 // TCode
rank 0 explicit_value ""
cpp_decl "${comment}${template}class ${name}${inherit}
{
${members} };
@ -1303,6 +1296,30 @@ ${inlines}
classrelation_ref 211461 // <generalisation>
b parent class_ref 170629 // TCode
end
classrelation 212869 // parts (<directional composition>)
relation 201989 *-->
a role_name "parts" multiplicity "4" protected
cpp default " ${comment}${static}${mutable}${volatile}${const}${type} ${name}${value};
"
classrelation_ref 212869 // parts (<directional composition>)
b parent class_ref 173829 // Digxel
end
end
class 173829 "Digxel"
visibility package
cpp_decl "${comment}${template}class ${name}${inherit}
{
${members} };
${inlines}
"
java_decl ""
php_decl ""
python_2_2 python_decl ""
idl_decl ""
explicit_switch_type ""
end
end

View file

@ -38,7 +38,7 @@ classcanvas 131589 class_ref 170501 // QuTimeSpan
end
classcanvas 131973 class_ref 170629 // TCode
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 248 450 2000
xyz 319 434 2000
end
classcanvas 132101 class_ref 170757 // Format
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
@ -46,7 +46,7 @@ classcanvas 132101 class_ref 170757 // Format
end
classcanvas 132997 class_ref 170885 // FrameNr
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 243 545 2000
xyz 314 507 2000
end
classcanvas 133253 class_ref 171013 // CompoundGrid
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
@ -58,25 +58,29 @@ classcanvas 133509 class_ref 172165 // Offset
end
classcanvas 135045 class_ref 137093 // Meta
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 514 237 2000
xyz 514 237 2005
end
note 135429 "Asset System"
xyzwh 504 197 2000 66 47
classcanvas 135557 class_ref 172293 // Frames
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 392 507 1995
xyz 392 507 1979
end
classcanvas 135685 class_ref 172421 // Smpte
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 446 533 2010
xyz 446 533 1994
end
classcanvas 136069 class_ref 172549 // Hms
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 421 523 2005
xyz 421 523 1984
end
classcanvas 136325 class_ref 172677 // SmpteTC
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 308 546 2000
xyz 242 507 2000
end
classcanvas 137349 class_ref 173829 // Digxel
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 191 548 2000
end
relationcanvas 128517 relation_ref 195205 // <generalisation>
geometry VHV unfixed
@ -120,20 +124,9 @@ relationcanvas 131717 relation_ref 197637 // <generalisation>
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 132485 relation_ref 197893 // <dependency>
from ref 131973 z 1999 to point 290 450
line 132869 z 1999 to ref 132101
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 132613 relation_ref 198021 // <unidirectional association>
from ref 129669 z 1999 stereotype "<<yield>>" xyz 275 415 3000 to ref 131973
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 132741 relation_ref 198149 // <directional aggregation>
decenter_end 595
from ref 130181 z 1999 stereotype "<<provide>>" xyz 360 414 3000 to ref 132101
from ref 130181 z 1999 stereotype "<<provide>>" xyz 360 413 3000 to ref 132101
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
@ -194,10 +187,29 @@ relationcanvas 136197 relation_ref 200453 // <generalisation>
end
relationcanvas 136453 relation_ref 200581 // <generalisation>
geometry VHV
from ref 136325 z 1999 to point 334 522
line 136581 z 1999 to point 268 522
from ref 136325 z 1999 to point 268 487
line 136581 z 1999 to point 339 487
line 136709 z 1999 to ref 131973
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 136837 relation_ref 201733 // <unidirectional association>
from ref 129669 z 1999 to ref 132997
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 136965 relation_ref 201861 // <unidirectional association>
decenter_end 754
from ref 129669 z 1999 stereotype "<<yield>>" xyz 244 416 3000 to point 295 437
line 137093 z 1999 to ref 136325
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 137477 relation_ref 201989 // <directional composition>
geometry HVr
from ref 136325 z 1999 to point 268 565
line 137605 z 1999 to ref 137349
role_a_pos 245 554 3000 no_role_b
multiplicity_a_pos 245 573 3000 no_multiplicity_b
end
end

View file

@ -5,7 +5,7 @@ diagrams
objectdiagram_ref 138885 // ModelAssetRelations
730 488 100 4 0 0
active classdiagram_ref 142725 // Time flavours
595 629 100 4 0 0
595 646 100 4 0 0
end
show_stereotypes
selected

View file

@ -1,6 +1,6 @@
format 58
"lumiera"
revision 67
revision 68
modified_by 5 "hiv"
cpp_root_dir "../../src/"

View file

@ -6561,7 +6561,7 @@ Thus no server and no network connection is needed. Simply open the file in your
* see [[Homepage|http://tiddlywiki.com]], [[Wiki-Markup|http://tiddlywiki.org/wiki/TiddlyWiki_Markup]]
</pre>
</div>
<div title="TimeQuant" modifier="Ichthyostega" modified="201012230154" created="201012181753" tags="Concepts Player spec discuss draft" changecount="45">
<div title="TimeQuant" modifier="Ichthyostega" modified="201101050143" created="201012181753" tags="Concepts Player spec discuss draft" changecount="47">
<pre>The term &amp;raquo;Time&amp;laquo; spans a variety of vastly different entities. Within a NLE we get to deal with various //flavours of time values.//
;continuous time
:without any additional assumptions, ''points in time'' can be specified with arbitrary precision.
@ -6616,6 +6616,8 @@ __delayed quantisation__: with this approach, the information loss is delayed as
!!!discussion
For Lumiera, the static typing approach is of limited value -- it excels when values belonging to different scales are actually treated differently. There are such cases, but rather on the data handling level, e.g. sound samples are always handled block wise. But regarding time values, the unifying aspect is more important, which leads to prefering a dynamic (run time typed) approach, while //erasing// the special differences most of the time. Yet the dynamic and open nature of the Lumiera high-level model favours the delayed quantisation pattern; the same values may require different quantisation depending on the larger model context an object is encountered in. This solution might be to general and heavy weight at times though. Thus, for important special cases, the accessors should return tagged values, preferably even with differing static type. Time codes can be integrated this way, but most notably the ''frame numbers'' used for addressing throughout the backend, can be implemented as such specifically typed tagged values; the tag here denotes the quantiser and thus the underlying grid -- it should be implemented as hash-ID for smooth integration with code written in plain C.
At the level of individual timecode formats, we're lacking a common denominator; thus it is preferrable to work with different concrete timecode classes through //generic programming.// This way, each timecode format can expose operations specific only to the given format. Especially, different timecode formats expose different //component fields,// modelled by the generic ''Digxel'' concept. There is a common baseclass ~TCode though, which can be used for //type erasure.//
&amp;rarr; more on [[usage situations|TimeUsage]]
</pre>
</div>