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 
121  FBString GetTimeString(FBTimeMode pMode=kFBTimeModeDefault, ETimeFormats pFormat = eDefaultFormat);
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 
306  FBString GetTimeCodeString(FBTime::ETimeFormats pFormat = FBTime::eDefaultFormat);
307 
312  void SetTimeCodeString(const char *pTime, FBTime::ETimeFormats pFormat = FBTime::eDefaultFormat);
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 
399  FBTime& GetStart();
400  FBTime& GetStop();
401  const FBTime& GetStart() const;
402  const FBTime& GetStop() const;
404 
409  void Set( FBTime pStart, FBTime pStop );
410 
414  FBTime GetDuration();
415 
419  FBTime GetSignedDuration();
420 
425  int GetDirection();
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 
static const FBTime OneMinute
Time constant: One Minute.
Definition: fbtime.h:272
static const float FILM_24
-24.0f
Definition: fbtime.h:369
ETimeFormats
Different time format available.
Definition: fbtime.h:94
static const FBTime OneSecond
Time constant: One Second.
Definition: fbtime.h:269
Time data structure.
Definition: fbtime.h:87
static const FBTime Infinity
Time constant: Infinity, the largest time value.
Definition: fbtime.h:257
static const float FRAMES_30
-30.0f
Definition: fbtime.h:371
Basic string class.
Definition: fbstring.h:66
format as numeric frame
Definition: fbtime.h:97
static const float NTSC_FULL
-29.97f
Definition: fbtime.h:366
static const float PAL_25
-25.0f
Definition: fbtime.h:367
Default Time format.
Definition: fbtime.h:98
static const FBTime MinusInfinity
Time constant: Minus Infinity, the lowest negative time value.
Definition: fbtime.h:260
Custom framerate.
Definition: fbtime.h:81
Default Time Mode.
Definition: fbtime.h:64
~29.97 full
Definition: fbtime.h:77
static const float FRAMES_5994
-59.94f
Definition: fbtime.h:372
#define FBSDKNamespace
FBSDKNamespace define.
Definition: fbversion.h:64
static const FBTime Zero
Time constant: Zero.
Definition: fbtime.h:263
format as SMPTE
Definition: fbtime.h:96
static const FBTime OneHour
Time constant: One Hour.
Definition: fbtime.h:275
static const float MPAL_30
-29.971f Currently not supported : "1" is added just to differentiate from NTSC_FULL(-29.97f)
Definition: fbtime.h:368
TimeSpan class.
Definition: fbtime.h:383
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
FBTimeMode
Different time modes available.
Definition: fbtime.h:63
static const float FRAMES_11988
-119.88f
Definition: fbtime.h:373
1000 : 1 millisecond
Definition: fbtime.h:65
String class.
static const FBTime Epsilon
Time constant: Epsilon, the smallest time increment.
Definition: fbtime.h:266
static const float FILM_23976
-23.976f
Definition: fbtime.h:370
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbtime.h:49
static const float NTSC_DROP
Rates.
Definition: fbtime.h:365
TimeCode data structure.
Definition: fbtime.h:281