Open Reality Reference Guide
fbtime.h
Go to the documentation of this file.
1 #ifndef __FBTIME_H__
2 #define __FBTIME_H__
3 /**************************************************************************
4  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5  All Rights Reserved.
6 
7  The coded instructions, statements, computer programs, and/or related
8  material (collectively the "Data") in these files contain unpublished
9  information proprietary to Autodesk, Inc. and/or its licensors, which is
10  protected by Canada and United States of America federal copyright law
11  and by international treaties.
12 
13  The Data may not be disclosed or distributed to third parties, in whole
14  or in part, without the prior written consent of Autodesk, Inc.
15  ("Autodesk").
16 
17  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24  FREE.
25 
26  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36 
37 **************************************************************************/
38 
43 #include <kaydaradef.h>
44 
45 #ifndef FBSDK_DLL
46 
49  #define FBSDK_DLL K_DLLIMPORT
50 #endif
51 
52 #include <fbsdk/fbstring.h>
53 
54 #ifdef FBSDKUseNamespace
55  namespace FBSDKNamespace {
56 #endif
57 
59 // FBTime
61 
63 enum FBTimeMode {
82 };
83 
85 
88 {
89  private:
90  kLongLong mTime;
91  public:
92 
95  {
98  eDefaultFormat
99  };
100 
101  /* Constructor.
102  * \param pTime Time to initialize with(default=0).
103  */
104  FBTime( kLongLong pTime=0);
105 
114  FBTime (int pHour,int pMinute,int pSecond=0,int pFrame=0,int pField=0, FBTimeMode pTimeMode=kFBTimeModeDefault);
115 
122 
126  void SetTimeString(const char *pTime);
127 
138  bool GetTime(int &pHour, int &pMinute, int &pSecond, int &pFrame, int &pField, int &pMilliSecond, FBTimeMode pTimeMode=kFBTimeModeDefault );
142  kLongLong GetMilliSeconds();
143 
147  void SetMilliSeconds(kLongLong pMilliSeconds);
148 
152  kLongLong& Get();
153 
157  const kLongLong& Get() const;
158 
162  void Set( kLongLong pTime );
163 
167  double GetSecondDouble();
168 
172  void SetSecondDouble(double pTime);
173 
182  void SetTime (int pHour,int pMinute=0,int pSecond=0,int pFrame=0,int pField=0, FBTimeMode pTimeMode=kFBTimeModeDefault);
183 
185 
189  FBTime& operator= (const FBTime& pTime);
190  FBTime& operator+= (const FBTime& pTime);
191  FBTime& operator-= (const FBTime& pTime);
192  FBTime& operator*= (const FBTime& pTime);
193  FBTime& operator/= (const FBTime& pTime);
195 
197 
201  FBTime& operator= (double pConstant);
202  FBTime& operator+= (double pConstant);
203  FBTime& operator-= (double pConstant);
204  FBTime& operator*= (double pConstant);
205  FBTime& operator/= (double pConstant);
207 
209 
213  FBTime operator- (const FBTime &pTime);
214  FBTime operator+ (const FBTime &pTime);
215  FBTime operator/ (const FBTime &pTime);
216  FBTime operator* (const FBTime &pTime);
218 
220 
224  FBTime operator- (double pConstant);
225  FBTime operator+ (double pConstant);
226  FBTime operator/ (double pConstant);
227  FBTime operator* (double pConstant);
229 
231 
235  bool operator== (const FBTime& pTime);
236  bool operator!= (const FBTime& pTime);
237  bool operator>= (const FBTime& pTime);
238  bool operator<= (const FBTime& pTime);
239  bool operator> (const FBTime& pTime);
240  bool operator< (const FBTime& pTime);
242 
248  kLongLong GetFrame(FBTimeMode pTimeMode=kFBTimeModeDefault);
249 
254  void SetFrame(kLongLong pFrames, FBTimeMode pTimeMode=kFBTimeModeDefault);
255 
257  static const FBTime Infinity;
258 
260  static const FBTime MinusInfinity;
261 
263  static const FBTime Zero;
264 
266  static const FBTime Epsilon;
267 
269  static const FBTime OneSecond;
270 
272  static const FBTime OneMinute;
273 
275  static const FBTime OneHour;
276 };
277 
279 
282 {
283  private:
284  double mSecond;
285  double mFrame;
286  double mRate;
287  public:
288 
292  FBTimeCode(float pRate=FRAMES_30);
293 
300  void SetTimeCode(int pHour,int pMinute=0,int pSecond=0,float pFrame=0);
301 
307 
313 
316  FBTime GetTime() const;
317 
321  void SetTime(FBTime pTime);
322 
325  double GetFrame() const;
326 
330  void SetFrame(double pFrame);
331 
334  float GetFrameRate() const;
335 
339  double GetRawSecond() const;
340 
344  double GetRawFrame() const;
345 
349  double GetRawRate() const;
350 
355  bool operator==(const FBTimeCode& pTimeCode)const;
356 
361  bool operator!=(const FBTimeCode& pTimeCode)const;
362 
363 
365  static const float NTSC_DROP;
366  static const float NTSC_FULL;
367  static const float PAL_25;
368  static const float MPAL_30;
369  static const float FILM_24;
370  static const float FILM_23976;
371  static const float FRAMES_30;
372  static const float FRAMES_5994;
373  static const float FRAMES_11988;
374 };
375 
377 // FBTimeSpan
379 
381 
384 {
385  private:
386  FBTime mStart;
387  FBTime mStop;
388  public:
393  FBTimeSpan( FBTime pStart=0,FBTime pStop=0);
394 
396 
400  FBTime& GetStop();
401  const FBTime& GetStart() const;
402  const FBTime& GetStop() const;
404 
409  void Set( FBTime pStart, FBTime pStop );
410 
415 
420 
426 
431  bool operator& (FBTime &pTime);
432 
436  FBTimeSpan operator& (FBTimeSpan &pTimeSpan);
437 };
439 // Global
441 #ifdef FBSDKUseNamespace
442  }
443 #endif
444 
445 #endif
446 
FBTimeCode::GetFrameRate
float GetFrameRate() const
Return the rate of the timecode.
FBTime::eSMPTE
@ eSMPTE
format as SMPTE
Definition: fbtime.h:96
FBTime::SetTimeString
void SetTimeString(const char *pTime)
Set time from string.
FBTime::ETimeFormats
ETimeFormats
Different time format available.
Definition: fbtime.h:95
FBTime::GetTime
bool GetTime(int &pHour, int &pMinute, int &pSecond, int &pFrame, int &pField, int &pMilliSecond, FBTimeMode pTimeMode=kFBTimeModeDefault)
Get time (filling separate values)
kFBTimeMode48Frames
@ kFBTimeMode48Frames
48
Definition: fbtime.h:74
FBTimeCode::FILM_24
static const float FILM_24
-24.0f
Definition: fbtime.h:369
kFBTimeMode2997Frames_Drop
@ kFBTimeMode2997Frames_Drop
~29.97 drop
Definition: fbtime.h:76
kFBTimeMode96Frames
@ kFBTimeMode96Frames
96
Definition: fbtime.h:69
kFBTimeModeDefault
@ kFBTimeModeDefault
Default Time Mode.
Definition: fbtime.h:64
FBTimeCode::GetTime
FBTime GetTime() const
Return a Time corresponding to the timecode.
FBTimeSpan
TimeSpan class.
Definition: fbtime.h:384
kFBTimeMode100Frames
@ kFBTimeMode100Frames
100
Definition: fbtime.h:68
FBTimeCode::FRAMES_30
static const float FRAMES_30
-30.0f
Definition: fbtime.h:371
FBTimeCode::GetTimeCodeString
FBString GetTimeCodeString(FBTime::ETimeFormats pFormat=FBTime::eDefaultFormat)
Get time as a string.
FBSDK_DLL
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbtime.h:49
FBTime::Infinity
static const FBTime Infinity
Time constant: Infinity, the largest time value.
Definition: fbtime.h:257
FBTime::SetTime
void SetTime(int pHour, int pMinute=0, int pSecond=0, int pFrame=0, int pField=0, FBTimeMode pTimeMode=kFBTimeModeDefault)
Set time (from separate values)
FBTime::FBTime
FBTime(int pHour, int pMinute, int pSecond=0, int pFrame=0, int pField=0, FBTimeMode pTimeMode=kFBTimeModeDefault)
Constructor.
FBTimeCode::operator==
bool operator==(const FBTimeCode &pTimeCode) const
Equality operator.
FBTimeSpan::GetDirection
int GetDirection()
Get the direction of the timespan.
FBTime::Get
const kLongLong & Get() const
Get time value (long)
FBTime::Set
void Set(kLongLong pTime)
Set time value from a long.
FBTime
Time data structure.
Definition: fbtime.h:88
FBTime::GetMilliSeconds
kLongLong GetMilliSeconds()
Get milliseconds for time.
FBTimeCode
TimeCode data structure.
Definition: fbtime.h:282
FBTime::Zero
static const FBTime Zero
Time constant: Zero.
Definition: fbtime.h:263
FBTimeSpan::Set
void Set(FBTime pStart, FBTime pStop)
Set the TimeSpan.
FBTimeCode::GetRawSecond
double GetRawSecond() const
Get the raw value for the second.
FBTimeSpan::GetSignedDuration
FBTime GetSignedDuration()
Get the signed duration value of a timespan.
FBTimeCode::FRAMES_5994
static const float FRAMES_5994
-59.94f
Definition: fbtime.h:372
FBTimeSpan::GetDuration
FBTime GetDuration()
Get the unsigned duration value of a timespan.
FBTimeCode::PAL_25
static const float PAL_25
-25.0f
Definition: fbtime.h:367
FBTime::Epsilon
static const FBTime Epsilon
Time constant: Epsilon, the smallest time increment.
Definition: fbtime.h:266
FBTimeCode::SetTimeCode
void SetTimeCode(int pHour, int pMinute=0, int pSecond=0, float pFrame=0)
Set timecode.
FBString
Basic string class.
Definition: fbstring.h:67
FBTimeCode::GetRawFrame
double GetRawFrame() const
Get the raw value for the frame.
kFBTimeMode5994Frames
@ kFBTimeMode5994Frames
~59.94
Definition: fbtime.h:72
FBTime::MinusInfinity
static const FBTime MinusInfinity
Time constant: Minus Infinity, the lowest negative time value.
Definition: fbtime.h:260
FBTimeCode::NTSC_FULL
static const float NTSC_FULL
-29.97f
Definition: fbtime.h:366
FBTime::OneMinute
static const FBTime OneMinute
Time constant: One Minute.
Definition: fbtime.h:272
FBTimeCode::SetFrame
void SetFrame(double pFrame)
Set Frame according to the given time.
FBTimeCode::GetRawRate
double GetRawRate() const
Get the raw value for the rate.
FBTime::OneSecond
static const FBTime OneSecond
Time constant: One Second.
Definition: fbtime.h:269
kFBTimeMode24Frames
@ kFBTimeMode24Frames
24
Definition: fbtime.h:79
kFBTimeMode25Frames
@ kFBTimeMode25Frames
25
Definition: fbtime.h:78
FBTime::SetFrame
void SetFrame(kLongLong pFrames, FBTimeMode pTimeMode=kFBTimeModeDefault)
Set time in frame format.
FBTime::GetFrame
kLongLong GetFrame(FBTimeMode pTimeMode=kFBTimeModeDefault)
Get the frame count.
kFBTimeModeCustom
@ kFBTimeModeCustom
Custom framerate.
Definition: fbtime.h:81
FBTime::eDefaultFormat
@ eDefaultFormat
Default Time format.
Definition: fbtime.h:98
FBTimeCode::SetTime
void SetTime(FBTime pTime)
Set TimeCode according to the given time.
fbstring.h
String class.
FBTimeCode::SetTimeCodeString
void SetTimeCodeString(const char *pTime, FBTime::ETimeFormats pFormat=FBTime::eDefaultFormat)
Set time from string.
FBTime::eFrame
@ eFrame
format as numeric frame
Definition: fbtime.h:97
FBTimeCode::MPAL_30
static const float MPAL_30
-29.971f Currently not supported : "1" is added just to differentiate from NTSC_FULL(-29....
Definition: fbtime.h:368
FBTime::SetSecondDouble
void SetSecondDouble(double pTime)
Set seconds from double.
FBTimeCode::FRAMES_11988
static const float FRAMES_11988
-119.88f
Definition: fbtime.h:373
kFBTimeMode50Frames
@ kFBTimeMode50Frames
50
Definition: fbtime.h:73
kFBTimeMode1000Frames
@ kFBTimeMode1000Frames
1000 : 1 millisecond
Definition: fbtime.h:65
FBTimeCode::GetFrame
double GetFrame() const
Return a frame number corresponding to the timecode.
FBTimeCode::operator!=
bool operator!=(const FBTimeCode &pTimeCode) const
Inequality operator.
FBTime::OneHour
static const FBTime OneHour
Time constant: One Hour.
Definition: fbtime.h:275
FB_FORWARD
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
FBTime::GetTimeString
FBString GetTimeString(FBTimeMode pMode=kFBTimeModeDefault, ETimeFormats pFormat=eDefaultFormat)
Get time as a string.
FBTimeCode::FBTimeCode
FBTimeCode(float pRate=FRAMES_30)
Constructor.
FBTimeMode
FBTimeMode
Different time modes available.
Definition: fbtime.h:63
kFBTimeMode60Frames
@ kFBTimeMode60Frames
60
Definition: fbtime.h:71
FBTimeCode::FILM_23976
static const float FILM_23976
-23.976f
Definition: fbtime.h:370
kFBTimeMode2997Frames
@ kFBTimeMode2997Frames
~29.97 full
Definition: fbtime.h:77
FBTimeSpan::GetStart
FBTime & GetStart()
Get the start/stop time.
FBTime::Get
kLongLong & Get()
Get time value (long)
FBTime::GetSecondDouble
double GetSecondDouble()
Get seconds as double.
kFBTimeMode11988Frames
@ kFBTimeMode11988Frames
~119.88
Definition: fbtime.h:67
kFBTimeMode120Frames
@ kFBTimeMode120Frames
120
Definition: fbtime.h:66
FBTimeCode::NTSC_DROP
static const float NTSC_DROP
Rates.
Definition: fbtime.h:365
FBTimeSpan::FBTimeSpan
FBTimeSpan(FBTime pStart=0, FBTime pStop=0)
Constructor.
kFBTimeMode23976Frames
@ kFBTimeMode23976Frames
~23.976
Definition: fbtime.h:80
FBTime::SetMilliSeconds
void SetMilliSeconds(kLongLong pMilliSeconds)
Set milliseconds time.
kFBTimeMode72Frames
@ kFBTimeMode72Frames
72
Definition: fbtime.h:70
kFBTimeMode30Frames
@ kFBTimeMode30Frames
30
Definition: fbtime.h:75