1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 3 <title>oscl_time.h Source File</title> 4 <link href="doxygen.css" rel="stylesheet" type="text/css"> 5 </head><body> 6 <!-- Generated by Doxygen 1.2.18 --> 7 <center> 8 <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> 9 <hr><h1>oscl_time.h</h1><a href="oscl__time_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">// -*- c++ -*-</span> 10 00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> 11 00003 12 00004 <span class="comment">// O S C L _ T I M E ( T I M E F U N C T I O N S )</span> 13 00005 14 00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> 15 00007 16 00022 <span class="preprocessor">#ifndef OSCL_TIME_H_INCLUDED</span> 17 00023 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TIME_H_INCLUDED</span> 18 00024 <span class="preprocessor"></span> 19 00025 <span class="comment">// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span> 20 00026 21 00027 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span> 22 00028 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span> 23 00029 <span class="preprocessor">#endif</span> 24 00030 <span class="preprocessor"></span> 25 00031 <span class="preprocessor">#ifndef OSCLCONFIG_TIME_H_INCLUDED</span> 26 00032 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__time_8h.html">osclconfig_time.h</a>"</span> 27 00033 <span class="preprocessor">#endif</span> 28 00034 <span class="preprocessor"></span> 29 00035 <span class="preprocessor">#ifndef OSCL_INT64_UTILS_INCLUDED</span> 30 00036 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__int64__utils_8h.html">oscl_int64_utils.h</a>"</span> 31 00037 <span class="preprocessor">#endif</span> 32 00038 <span class="preprocessor"></span> 33 <a name="l00039"></a><a class="code" href="group__osclbase.html#a0">00039</a> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="group__osclbase.html#a0">CTIME_BUFFER_SIZE</a> = 26; 34 00040 35 <a name="l00041"></a><a class="code" href="group__osclbase.html#a1">00041</a> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="group__osclbase.html#a1">PV8601TIME_BUFFER_SIZE</a> = 21; 36 00042 37 <a name="l00043"></a><a class="code" href="group__osclbase.html#a2">00043</a> <span class="keyword">typedef</span> <span class="keywordtype">char</span> <a class="code" href="group__osclbase.html#a2">CtimeStrBuf</a>[<a class="code" href="group__osclbase.html#a0">CTIME_BUFFER_SIZE</a>]; 38 <a name="l00044"></a><a class="code" href="group__osclbase.html#a3">00044</a> <span class="keyword">typedef</span> <span class="keywordtype">char</span> <a class="code" href="group__osclbase.html#a3">PV8601timeStrBuf</a>[<a class="code" href="group__osclbase.html#a1">PV8601TIME_BUFFER_SIZE</a>]; 39 00045 40 00046 <span class="keyword">class </span><a class="code" href="classTimeValue.html">TimeValue</a>; <span class="comment">// Forward definition</span> 41 00047 42 00048 OSCL_IMPORT_REF <span class="keywordtype">void</span> <a class="code" href="group__osclbase.html#a75">PV8601ToRFC822</a>(<a class="code" href="group__osclbase.html#a3">PV8601timeStrBuf</a> pv8601_buffer, <a class="code" href="group__osclbase.html#a2">CtimeStrBuf</a> ctime_buffer); 43 00049 OSCL_IMPORT_REF <span class="keywordtype">void</span> <a class="code" href="group__osclbase.html#a76">RFC822ToPV8601</a>(<a class="code" href="group__osclbase.html#a2">CtimeStrBuf</a> ctime_buffer, <a class="code" href="group__osclbase.html#a3">PV8601timeStrBuf</a>); 44 00050 45 00051 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span> 46 <a name="l00053"></a><a class="code" href="group__osclbase.html#a109">00053</a> <span class="comment">typedef enum { SECONDS = 0, MILLISECONDS = 1, MICROSECONDS = 2 } TimeUnits;</span> 47 00054 48 <a name="l00055"></a><a class="code" href="group__osclbase.html#a4">00055</a> <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="group__osclbase.html#a4">USEC_PER_SEC</a> = 1000000; 49 <a name="l00056"></a><a class="code" href="group__osclbase.html#a5">00056</a> <span class="keyword">const</span> <span class="keywordtype">long</span> <a class="code" href="group__osclbase.html#a5">MSEC_PER_SEC</a> = 1000; 50 00057 51 00059 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">long</span> MapToSeconds[] = {1, 1000, 1000000}; 52 00060 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">long</span> MapToUSeconds[] = {1000000, 1000, 1}; 53 00061 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">long</span> MapTo100NanoSeconds[] = {10000000, 10000, 10}; 54 <a name="l00062"></a><a class="code" href="group__osclbase.html#a9">00062</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a9">unix_ntp_offset</a> = 2208988800U; 55 00063 56 00064 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span> 57 00065 58 00067 59 <a name="l00076"></a><a class="code" href="classNTPTime.html">00076</a> <span class="keyword">class </span><a class="code" href="classNTPTime.html">NTPTime</a> 60 00077 { 61 00078 62 00079 <span class="keyword">private</span>: 63 00080 <a class="code" href="group__osclbase.html#a31">uint64</a> timevalue; 64 00081 65 00082 <span class="keyword">public</span>: 66 00084 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>(); 67 00085 68 00087 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>(<span class="keyword">const</span> <a class="code" href="classNTPTime.html">NTPTime</a>& src); 69 00088 70 00090 71 00091 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>(<span class="keyword">const</span> uint32 seconds); 72 00092 73 00094 74 00095 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>(<span class="keyword">const</span> int32 seconds); 75 00096 76 00098 77 00102 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& t); 78 00103 79 00105 80 00106 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>(<span class="keyword">const</span> <a class="code" href="group__osclbase.html#a31">uint64</a> value); 81 00107 82 00108 83 00110 84 00111 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a>& <a class="code" href="classNTPTime.html#a6">operator=</a>(uint32 newval); 85 00112 86 00114 87 00115 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a>& <a class="code" href="classNTPTime.html#a6">operator=</a>(<a class="code" href="group__osclbase.html#a31">uint64</a> newval); 88 00116 89 00118 90 00119 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a>& <a class="code" href="classNTPTime.html#a8">operator+=</a>(<a class="code" href="group__osclbase.html#a31">uint64</a> val); 91 00120 92 00122 93 00123 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a> <a class="code" href="classNTPTime.html#a9">operator-</a>(<span class="keyword">const</span> <a class="code" href="classNTPTime.html">NTPTime</a> &ntpt) <span class="keyword">const</span>; 94 00124 95 00126 96 00132 <span class="keywordtype">void</span> <a class="code" href="classNTPTime.html#a10">set_from_system_time</a>(<span class="keyword">const</span> uint32 systemtime); 97 00133 98 00135 <span class="comment">/* \return This method returns the middle 32 bits of the 32.32 representation. */</span> 99 00136 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> uint32 <a class="code" href="classNTPTime.html#a11">get_middle32</a>() <span class="keyword">const</span>; 100 00137 101 00139 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> uint32 <a class="code" href="classNTPTime.html#a12">get_upper32</a>() <span class="keyword">const</span>; 102 00140 103 00142 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> uint32 <a class="code" href="classNTPTime.html#a13">get_lower32</a>() <span class="keyword">const</span>; 104 00143 105 00145 106 00149 int32 <a class="code" href="classNTPTime.html#a14">to_system_time</a>() <span class="keyword">const</span>; 107 00150 108 00152 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="group__osclbase.html#a31">uint64</a> <a class="code" href="classNTPTime.html#a15">get_value</a>() <span class="keyword">const</span>; 109 00153 110 00155 OSCL_IMPORT_REF <span class="keywordtype">int</span> <a class="code" href="classNTPTime.html#a16">set_to_current_time</a>(); 111 00156 112 00157 }; 113 00158 114 00159 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span> 115 00161 <span class="comment"></span> 116 <a name="l00174"></a><a class="code" href="classTimeValue.html">00174</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classTimeValue.html">TimeValue</a> 117 00175 { 118 00176 119 00177 <span class="keyword">public</span>: 120 00179 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html#a0">TimeValue</a>(); 121 00180 122 00182 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html#a0">TimeValue</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& Tv); 123 00183 124 00185 125 00189 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html#a0">TimeValue</a>(<span class="keywordtype">long</span> tv, <a class="code" href="group__osclbase.html#a109">TimeUnits</a> units); 126 00190 127 00192 128 00194 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html#a0">TimeValue</a>(<span class="keyword">const</span> <a class="code" href="osclconfig__time_8h.html#a1">OsclBasicTimeStruct</a>& in_tv); 129 00195 130 00197 131 00201 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html#a0">TimeValue</a>(<a class="code" href="osclconfig__time_8h.html#a2">OsclBasicDateTimeStruct</a> in_ts); 132 00202 133 00204 134 00207 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> int32 <a class="code" href="classTimeValue.html#a5">get_local_time</a>(); 135 00208 136 00209 137 <a name="l00210"></a><a class="code" href="classTimeValue.html#l0">00210</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classNTPTime.html">NTPTime</a>; 138 00211 139 00213 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keywordtype">void</span> <a class="code" href="classTimeValue.html#a6">set_to_zero</a>(); 140 00214 141 00216 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keywordtype">void</span> <a class="code" href="classTimeValue.html#a7">set_to_current_time</a>(); 142 00217 143 00219 144 00223 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keywordtype">void</span> <a class="code" href="classTimeValue.html#a8">set_from_ntp_time</a>(<span class="keyword">const</span> uint32 ntp_offset); 145 00224 146 00226 147 00233 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> uint32 <a class="code" href="classTimeValue.html#a9">get_sec</a>() <span class="keyword">const</span> ; 148 00234 149 00235 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> int32 <a class="code" href="classTimeValue.html#a10">to_msec</a>() <span class="keyword">const</span>; 150 00236 151 00238 152 00241 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> uint32 <a class="code" href="classTimeValue.html#a11">get_usec</a>() <span class="keyword">const</span> ; 153 00242 154 00244 155 00249 OSCL_IMPORT_REF <span class="keywordtype">char</span> *<a class="code" href="classTimeValue.html#a12">get_str_ctime</a>(<a class="code" href="group__osclbase.html#a2">CtimeStrBuf</a> ctime_strbuf); 156 00250 157 00252 158 00256 OSCL_IMPORT_REF <span class="keywordtype">int</span> <a class="code" href="classTimeValue.html#a13">get_pv8601_str_time</a>(<a class="code" href="group__osclbase.html#a3">PV8601timeStrBuf</a> time_strbuf); 159 00257 160 00259 161 00265 OSCL_IMPORT_REF <span class="keywordtype">char</span> *<a class="code" href="classTimeValue.html#a14">get_rfc822_gmtime_str</a>(<span class="keywordtype">int</span> max_time_strlen, 162 00266 <span class="keywordtype">char</span> *time_str); 163 00267 164 00269 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#a15">is_zero</a>(); 165 00270 166 00271 167 00272 <span class="comment">// comparison operators</span> 168 00273 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#l1">operator ==</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 169 00274 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#l2">operator !=</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 170 00275 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#l3">operator <=</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 171 00276 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#l4">operator >=</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 172 00277 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#l5">operator <</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 173 00278 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classTimeValue.html#l6">operator ></a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 174 00279 175 00281 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html">TimeValue</a>& <a class="code" href="classTimeValue.html#a16">operator =</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a); 176 00282 177 00283 <span class="comment">// arithmetic operators</span> 178 00285 <span class="comment"> OSCL_COND_IMPORT_REF TimeValue& operator +=(const TimeValue& a);</span> 179 00287 <span class="comment"> OSCL_COND_IMPORT_REF TimeValue& operator -=(const TimeValue& a);</span> 180 00289 <span class="comment"> OSCL_COND_IMPORT_REF TimeValue& operator *=(const int scale);</span> 181 00290 182 00291 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="osclconfig__time_8h.html#a1">OsclBasicTimeStruct</a> * <a class="code" href="classTimeValue.html#a20">get_timeval_ptr</a>(); 183 00292 184 00293 <span class="keyword">private</span>: 185 00294 186 00295 <a class="code" href="osclconfig__time_8h.html#a1">OsclBasicTimeStruct</a> ts; 187 00296 <span class="keyword">const</span> <a class="code" href="osclconfig__time_8h.html#a1">OsclBasicTimeStruct</a> *getBasicTimeStruct()<span class="keyword"> const</span> 188 00297 <span class="keyword"> </span>{ 189 00298 <span class="keywordflow">return</span> &ts; 190 00299 }; 191 00300 192 00301 }; 193 00302 194 00303 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html">TimeValue</a> <a class="code" href="group__osclbase.html#a77">operator -</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>& b); 195 00304 196 00305 <span class="preprocessor">#if (!OSCL_DISABLE_INLINES)</span> 197 00306 <span class="preprocessor"></span><span class="preprocessor">#include "oscl_time.inl"</span> 198 00307 <span class="preprocessor">#endif</span> 199 00308 <span class="preprocessor"></span> 200 00309 201 00310 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span> 202 00311 203 00315 <span class="preprocessor">#endif // OSCL_TIME_H_INCLUDED</span> 204 </pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> 205 <address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> 206 </small></address> 207 </body> 208 </html> 209