Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TimeDefs.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef __TIME_DEFS_H 00025 #define __TIME_DEFS_H 1 00026 00027 #include <stdio.h> 00028 00029 #include "mnstream.h" 00030 #include "MNString.h" 00031 #include "MNValid.h" 00032 00033 /*********************************************************************** 00034 * ParseTimeBase 00035 ***********************************************************************/ 00036 00037 class ParseTimeBase 00038 { 00039 public: 00040 enum Kind 00041 { 00042 SMPTE, 00043 UTC, 00044 NPT 00045 }; 00046 00047 private: 00048 Kind _kind; 00049 00050 DECLARE_VALID 00051 00052 public: 00053 ParseTimeBase( Kind k ); 00054 ParseTimeBase( const ParseTimeBase& orig ); 00055 virtual ~ParseTimeBase( ); 00056 00057 const Kind& kind() const; 00058 00059 virtual ParseTimeBase* clone( ) const = 0; 00060 virtual int getAsNptSeconds( ) const = 0; 00061 00062 virtual void dump( ostream& out ) const = 0; 00063 virtual MNString toString() const = 0; 00064 }; 00065 00066 /*********************************************************************** 00067 * ParseTimeRange 00068 ***********************************************************************/ 00069 00070 class ParseTimeRange 00071 { 00072 ParseTimeBase* _start; 00073 ParseTimeBase* _end; 00074 ParseTimeBase* _defer; 00075 00076 DECLARE_VALID 00077 00078 public: 00079 ParseTimeRange( ParseTimeBase* start, ParseTimeBase* end ); 00080 ParseTimeRange( const ParseTimeRange& orig ); 00081 ~ParseTimeRange( ); 00082 00083 void setDeferred( ParseTimeBase* d ); 00084 ParseTimeBase* getDeferred( ) const; 00085 00086 bool hasStart(); 00087 bool hasEnd(); 00088 bool bDeferred(); 00089 00090 ParseTimeBase* getStart() const; 00091 ParseTimeBase* getEnd() const; 00092 00093 int getDurationAsSeconds( ) const; 00094 00095 void setStart( ParseTimeBase* newStart ); 00096 00097 MNString toString() const; 00098 }; 00099 00100 /*********************************************************************** 00101 * ParseTimeSmpte 00102 ***********************************************************************/ 00103 00104 class ParseTimeSmpte : public ParseTimeBase 00105 { 00106 int _hours; 00107 int _minutes; 00108 int _seconds; 00109 int _frames; 00110 int _subframes; 00111 public: 00121 ParseTimeSmpte( const char* text ); 00122 00125 ParseTimeSmpte( int hours, 00126 int minutes, 00127 int seconds, 00128 int frames, 00129 int subframes ); 00130 00132 ParseTimeSmpte( const ParseTimeSmpte& orig ); 00133 00134 virtual ~ParseTimeSmpte() { }; 00135 00136 virtual ParseTimeBase* clone( ) const; 00137 00142 virtual int getAsNptSeconds( ) const; 00143 00144 virtual void dump( ostream& out ) const; 00145 virtual MNString toString( ) const; 00146 }; 00147 00148 /*********************************************************************** 00149 * ParseTimeUtc 00150 ***********************************************************************/ 00151 00152 class ParseTimeUtc : public ParseTimeBase 00153 { 00154 int _year; 00155 int _month; 00156 int _day; 00157 int _hours; 00158 int _minutes; 00159 int _seconds; 00160 int _fraction; 00161 00162 bool _good; 00163 public: 00164 ParseTimeUtc( const char* text ); 00165 ParseTimeUtc( const ParseTimeUtc& orig ); 00166 virtual ~ParseTimeUtc() { }; 00167 00168 virtual ParseTimeBase* clone( ) const; 00169 virtual int getAsNptSeconds( ) const; 00170 virtual void dump( ostream& out ) const; 00171 00172 int year() const; 00173 int month() const; 00174 int day() const; 00175 int hours() const; 00176 int minutes() const; 00177 int seconds() const; 00178 int fraction() const; 00179 00180 bool good() const; 00181 virtual MNString toString( ) const; 00182 }; 00183 00184 /*********************************************************************** 00185 * ParseTimeNpt 00186 ***********************************************************************/ 00187 00188 class ParseTimeNpt : public ParseTimeBase 00189 { 00190 public: 00191 enum Type { 00192 T_SEC, 00193 T_TIME, 00194 T_NOW 00195 }; 00196 00197 private: 00198 int _hi; 00199 int _low; 00200 bool _now; 00201 00202 public: 00203 ParseTimeNpt( Type t, const char* text = NULL ); 00204 ParseTimeNpt( const ParseTimeNpt& orig ); 00205 virtual ~ParseTimeNpt() { }; 00206 00207 virtual ParseTimeBase* clone( ) const; 00208 virtual int getAsNptSeconds( ) const; 00209 virtual void dump( ostream& out ) const; 00210 virtual MNString toString( ) const; 00211 }; 00212 00213 /*********************************************************************** 00214 * operator<< 00215 ***********************************************************************/ 00216 00217 ostream& operator<<( ostream& ostr, const ParseTimeBase& t ); 00218 00219 /* This is only needed to be compatible with some older functions */ 00220 00221 struct SMPTE_TIME 00222 { 00223 int hours; 00224 int minutes; 00225 int seconds; 00226 int frames; 00227 int subframes; 00228 }; 00229 00230 struct SMPTE_RANGE 00231 { 00232 int type; 00233 bool bStart; 00234 bool bEnd; 00235 struct SMPTE_TIME Start; 00236 struct SMPTE_TIME End; 00237 }; 00238 00239 #define SMPTE_TYPE 1 00240 #define SMPTE_30_DROP_TYPE 2 00241 #define SMPTE_25 4 00242 #endif 00243

Generated on Sun Mar 6 13:35:50 2005 for Komssys by doxygen 1.3.8