blob: c1da23df8c559e979b9ea5f380cb463190a15570 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>oscl_time.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.18 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<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>
00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00003
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>
00005
00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span>
00007
00022 <span class="preprocessor">#ifndef OSCL_TIME_H_INCLUDED</span>
00023 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TIME_H_INCLUDED</span>
00024 <span class="preprocessor"></span>
00025 <span class="comment">// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
00026
00027 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span>
00029 <span class="preprocessor">#endif</span>
00030 <span class="preprocessor"></span>
00031 <span class="preprocessor">#ifndef OSCLCONFIG_TIME_H_INCLUDED</span>
00032 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__time_8h.html">osclconfig_time.h</a>"</span>
00033 <span class="preprocessor">#endif</span>
00034 <span class="preprocessor"></span>
00035 <span class="preprocessor">#ifndef OSCL_INT64_UTILS_INCLUDED</span>
00036 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__int64__utils_8h.html">oscl_int64_utils.h</a>"</span>
00037 <span class="preprocessor">#endif</span>
00038 <span class="preprocessor"></span>
<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;
00040
<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;
00042
<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>];
<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>];
00045
00046 <span class="keyword">class </span><a class="code" href="classTimeValue.html">TimeValue</a>; <span class="comment">// Forward definition</span>
00047
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);
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>);
00050
00051 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
<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>
00054
<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;
<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;
00057
00059 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">long</span> MapToSeconds[] = {1, 1000, 1000000};
00060 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">long</span> MapToUSeconds[] = {1000000, 1000, 1};
00061 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">long</span> MapTo100NanoSeconds[] = {10000000, 10000, 10};
<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;
00063
00064 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
00065
00067
<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>
00077 {
00078
00079 <span class="keyword">private</span>:
00080 <a class="code" href="group__osclbase.html#a31">uint64</a> timevalue;
00081
00082 <span class="keyword">public</span>:
00084 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html#a0">NTPTime</a>();
00085
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>&amp; src);
00088
00090
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);
00092
00094
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);
00096
00098
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>&amp; t);
00103
00105
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);
00107
00108
00110
00111 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a>&amp; <a class="code" href="classNTPTime.html#a6">operator=</a>(uint32 newval);
00112
00114
00115 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a>&amp; <a class="code" href="classNTPTime.html#a6">operator=</a>(<a class="code" href="group__osclbase.html#a31">uint64</a> newval);
00116
00118
00119 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classNTPTime.html">NTPTime</a>&amp; <a class="code" href="classNTPTime.html#a8">operator+=</a>(<a class="code" href="group__osclbase.html#a31">uint64</a> val);
00120
00122
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> &amp;ntpt) <span class="keyword">const</span>;
00124
00126
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);
00133
00135 <span class="comment">/* \return This method returns the middle 32 bits of the 32.32 representation. */</span>
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>;
00137
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>;
00140
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>;
00143
00145
00149 int32 <a class="code" href="classNTPTime.html#a14">to_system_time</a>() <span class="keyword">const</span>;
00150
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>;
00153
00155 OSCL_IMPORT_REF <span class="keywordtype">int</span> <a class="code" href="classNTPTime.html#a16">set_to_current_time</a>();
00156
00157 };
00158
00159 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
00161 <span class="comment"></span>
<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>
00175 {
00176
00177 <span class="keyword">public</span>:
00179 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html#a0">TimeValue</a>();
00180
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>&amp; Tv);
00183
00185
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);
00190
00192
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>&amp; in_tv);
00195
00197
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);
00202
00204
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>();
00208
00209
<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>;
00211
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>();
00214
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>();
00217
00219
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);
00224
00226
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> ;
00234
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>;
00236
00238
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> ;
00242
00244
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);
00250
00252
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);
00257
00259
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,
00266 <span class="keywordtype">char</span> *time_str);
00267
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>();
00270
00271
00272 <span class="comment">// comparison operators</span>
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>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
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>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
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 &lt;=</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
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 &gt;=</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
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 &lt;</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
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 &gt;</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
00279
00281 <a class="code" href="group__osclbase.html#a84">OSCL_COND_IMPORT_REF</a> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; <a class="code" href="classTimeValue.html#a16">operator =</a>(<span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; a);
00282
00283 <span class="comment">// arithmetic operators</span>
00285 <span class="comment"> OSCL_COND_IMPORT_REF TimeValue&amp; operator +=(const TimeValue&amp; a);</span>
00287 <span class="comment"> OSCL_COND_IMPORT_REF TimeValue&amp; operator -=(const TimeValue&amp; a);</span>
00289 <span class="comment"> OSCL_COND_IMPORT_REF TimeValue&amp; operator *=(const int scale);</span>
00290
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>();
00292
00293 <span class="keyword">private</span>:
00294
00295 <a class="code" href="osclconfig__time_8h.html#a1">OsclBasicTimeStruct</a> ts;
00296 <span class="keyword">const</span> <a class="code" href="osclconfig__time_8h.html#a1">OsclBasicTimeStruct</a> *getBasicTimeStruct()<span class="keyword"> const</span>
00297 <span class="keyword"> </span>{
00298 <span class="keywordflow">return</span> &amp;ts;
00299 };
00300
00301 };
00302
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>&amp; a, <span class="keyword">const</span> <a class="code" href="classTimeValue.html">TimeValue</a>&amp; b);
00304
00305 <span class="preprocessor">#if (!OSCL_DISABLE_INLINES)</span>
00306 <span class="preprocessor"></span><span class="preprocessor">#include "oscl_time.inl"</span>
00307 <span class="preprocessor">#endif</span>
00308 <span class="preprocessor"></span>
00309
00310 <span class="comment">// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
00311
00315 <span class="preprocessor">#endif // OSCL_TIME_H_INCLUDED</span>
</pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small>
<address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small>
</small></address>
</body>
</html>