fbsdk/fbtime.h Source File
 
 
 
fbsdk/fbtime.h
Go to the documentation of this file.
00001 #ifndef __FBTIME_H__
00002 #define __FBTIME_H__
00003 /**************************************************************************
00004  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
00005  All Rights Reserved.
00006  
00007  The coded instructions, statements, computer programs, and/or related 
00008  material (collectively the "Data") in these files contain unpublished 
00009  information proprietary to Autodesk, Inc. and/or its licensors, which is 
00010  protected by Canada and United States of America federal copyright law 
00011  and by international treaties.
00012  
00013  The Data may not be disclosed or distributed to third parties, in whole 
00014  or in part, without the prior written consent of Autodesk, Inc. 
00015  ("Autodesk").
00016  
00017  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00018  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO 
00019  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR 
00020  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES 
00021  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 
00022  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT 
00023  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR 
00024  FREE.
00025  
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS 
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR 
00028  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE 
00029  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS 
00030  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR 
00031  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF 
00032  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT 
00033  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE 
00034  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS 
00035  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
00036  
00037 **************************************************************************/
00038 
00043 #include <kaydaradef.h>
00044 
00045 #ifndef FBSDK_DLL
00046 
00049   #define FBSDK_DLL K_DLLIMPORT
00050 #endif
00051 
00052 #include <fbsdk/fbstring.h>
00053 
00054 #ifdef FBSDKUseNamespace
00055         namespace FBSDKNamespace {
00056 #endif
00057 
00059 // FBTime
00061 
00063 enum FBTimeMode {       
00064         kFBTimeModeDefault,             
00065         kFBTimeMode1000Frames,          
00066         kFBTimeMode120Frames,           
00067         kFBTimeMode100Frames,           
00068         kFBTimeMode96Frames,            
00069         kFBTimeMode72Frames,            
00070         kFBTimeMode60Frames,            
00071         kFBTimeMode5994Frames,          
00072         kFBTimeMode50Frames,            
00073         kFBTimeMode48Frames,            
00074         kFBTimeMode30Frames,            
00075         kFBTimeMode2997Frames_Drop,     
00076         kFBTimeMode2997Frames,          
00077         kFBTimeMode25Frames,            
00078         kFBTimeMode24Frames,            
00079         kFBTimeMode23976Frames,         
00080     kFBTimeModeCustom           
00081 };
00082 
00083 FB_FORWARD( FBTime );
00084 
00086 class FBSDK_DLL FBTime 
00087 {
00088   private:
00089         kLongLong       mTime;                  
00090   public:
00091 
00093         enum ETimeFormats
00094         {
00095                 eSMPTE,                 
00096                 eFrame,                 
00097                 eDefaultFormat  
00098         };
00099  
00100         /*      Constructor.
00101         *       \param  pTime   Time to initialize with(default=0).
00102         */
00103     FBTime( kLongLong pTime=0);
00104 
00113         FBTime (int pHour,int pMinute,int pSecond=0,int pFrame=0,int pField=0, FBTimeMode pTimeMode=kFBTimeModeDefault);
00114 
00120         FBString GetTimeString(FBTimeMode pMode=kFBTimeModeDefault, ETimeFormats pFormat = eDefaultFormat);
00121 
00125     void SetTimeString(const char *pTime);
00126 
00137         bool            GetTime(int &pHour,  int &pMinute, int &pSecond, int &pFrame, int &pField,  int &pMilliSecond, FBTimeMode pTimeMode=kFBTimeModeDefault );
00141         kLongLong       GetMilliSeconds();
00142 
00146         void            SetMilliSeconds(kLongLong pMilliSeconds);
00147 
00151     kLongLong&  Get();
00152 
00156     const kLongLong& Get() const;
00157 
00161     void                Set( kLongLong pTime );
00162 
00166         double          GetSecondDouble();
00167 
00171         void            SetSecondDouble(double pTime);
00172 
00181         void            SetTime (int pHour,int pMinute=0,int pSecond=0,int pFrame=0,int pField=0, FBTimeMode pTimeMode=kFBTimeModeDefault);
00182 
00184 
00188         FBTime& operator=       (const FBTime& pTime);
00189         FBTime& operator+=      (const FBTime& pTime);
00190         FBTime& operator-=      (const FBTime& pTime);
00191         FBTime& operator*=      (const FBTime& pTime);
00192         FBTime& operator/=      (const FBTime& pTime);
00194 
00196 
00200         FBTime& operator=       (double pConstant);
00201         FBTime& operator+=      (double pConstant);
00202         FBTime& operator-=      (double pConstant);
00203         FBTime& operator*=      (double pConstant);
00204         FBTime& operator/=      (double pConstant);
00206 
00208 
00212     FBTime      operator- (const FBTime &pTime);
00213     FBTime      operator+ (const FBTime &pTime);
00214         FBTime  operator/ (const FBTime &pTime);
00215         FBTime  operator* (const FBTime &pTime);
00217 
00219 
00223     FBTime      operator- (double pConstant);
00224     FBTime      operator+ (double pConstant);
00225         FBTime  operator/ (double pConstant);
00226         FBTime  operator* (double pConstant);
00228 
00230 
00234         bool    operator==      (const FBTime& pTime);
00235         bool    operator!=      (const FBTime& pTime);
00236         bool    operator>=      (const FBTime& pTime);
00237         bool    operator<=      (const FBTime& pTime);
00238         bool    operator>       (const FBTime& pTime);
00239         bool    operator<       (const FBTime& pTime);
00241 
00247         kLongLong       GetFrame(FBTimeMode pTimeMode=kFBTimeModeDefault);
00248 
00253         void SetFrame(kLongLong pFrames, FBTimeMode pTimeMode=kFBTimeModeDefault);
00254 
00256         static const FBTime Infinity;
00257 
00259         static const FBTime MinusInfinity;
00260 
00262         static const FBTime Zero;
00263 
00265         static const FBTime Epsilon;
00266 
00268         static const FBTime OneSecond;
00269 
00271         static const FBTime OneMinute;
00272 
00274         static const FBTime OneHour;
00275 };
00276 
00277 FB_FORWARD( FBTimeCode );
00278 
00280 class FBSDK_DLL FBTimeCode 
00281 {
00282   private:
00283         double mSecond; 
00284         double mFrame;  
00285         double mRate;   
00286   public:
00287 
00291         FBTimeCode(float pRate=NTSC_DROP);
00292 
00299         void SetTimeCode(int pHour,int pMinute=0,int pSecond=0,float pFrame=0);
00300 
00305         FBString GetTimeCodeString(FBTime::ETimeFormats pFormat = FBTime::eDefaultFormat);
00306 
00310     void SetTimeCodeString(const char *pTime);
00311 
00314         FBTime GetTime() const;
00315 
00319         void SetTime(FBTime pTime);
00320 
00323         double GetFrame() const;
00324 
00328         void SetFrame(double pFrame);
00329 
00332         float GetFrameRate() const;
00333 
00337         double GetRawSecond() const;
00338 
00342         double GetRawFrame() const;
00343 
00347         double GetRawRate() const;
00348 
00353         bool operator==(const FBTimeCode& pTimeCode)const;
00354 
00359         bool operator!=(const FBTimeCode& pTimeCode)const;
00360 
00361 
00363         static const float NTSC_DROP;   
00364         static const float NTSC_FULL;   
00365         static const float PAL_25;              
00366         static const float MPAL_30;             
00367         static const float FILM_24;             
00368         static const float FILM_23976;  
00369         static const float FRAMES_30;   
00370         static const float FRAMES_5994; 
00371 };
00372 
00374 // FBTimeSpan
00376 
00377 FB_FORWARD( FBTimeSpan );
00378 
00380 class FBSDK_DLL FBTimeSpan 
00381 {
00382   private:
00383     FBTime       mStart;                
00384     FBTime       mStop;                 
00385   public:
00390     FBTimeSpan( FBTime pStart=0,FBTime pStop=0);
00391 
00393 
00396         FBTime& GetStart();
00397         FBTime& GetStop();
00398         const FBTime& GetStart() const;
00399         const FBTime& GetStop() const;
00401 
00406         void    Set( FBTime pStart, FBTime pStop );
00407 
00411         FBTime  GetDuration();          
00412 
00416         FBTime  GetSignedDuration(); 
00417 
00422         int             GetDirection();
00423 
00428         bool    operator& (FBTime &pTime);
00429         
00433         FBTimeSpan operator& (FBTimeSpan &pTimeSpan);   
00434 };
00436 // Global
00438 #ifdef FBSDKUseNamespace
00439         }
00440 #endif
00441 
00442 #endif
00443