aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a02141.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/doxygen/nel/a02141.html997
1 files changed, 997 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a02141.html b/docs/doxygen/nel/a02141.html
new file mode 100644
index 00000000..74fb7e7b
--- /dev/null
+++ b/docs/doxygen/nel/a02141.html
@@ -0,0 +1,997 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+<title>NeL: NLNET::_CUniTime class Reference</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.3.6 -->
+<div class="qindex"> <form class="search" action="search.php" method="get">
+<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
+<h1>NLNET::_CUniTime Class Reference</h1><code>#include &lt;<a class="el" href="a06651.html">unitime.h</a>&gt;</code>
+<p>
+<p>Inheritance diagram for NLNET::_CUniTime:
+<p><center><img src="a02141.png" usemap="#NLNET::_CUniTime_map" border="0" alt=""></center>
+<map name="NLNET::_CUniTime_map">
+<area href="a02142.html" alt="NLMISC::CTime" shape="rect" coords="0,0,118,24">
+</map>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This class provide a independant universal time system. <dl compact><dt><b>Author:</b></dt><dd>Vianney Lecroart <p>
+Nevrax France </dd></dl>
+<dl compact><dt><b>Date:</b></dt><dd>2000</dd></dl>
+THIS CLASS IS DEPRECATED, DON'T USE IT
+<p>
+
+<p>
+Definition at line <a class="el" href="a06651.html#l00051">51</a> of file <a class="el" href="a06651.html">unitime.h</a>.<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>TTime&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02142.html#NLMISC_1_1CTimee0">getLocalTime</a> ()</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>TTicks&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02142.html#NLMISC_1_1CTimee1">getPerformanceTime</a> ()</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02142.html#NLMISC_1_1CTimee2">getSecondsSince1970</a> ()</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee3">getStringUniTime</a> (<a class="el" href="a05378.html#a242">NLMISC::TTime</a> ut)</td></tr>
+
+<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the time in a string format to be display. <a href="#NLNET_1_1__CUniTimee3"></a><br><br></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee4">getStringUniTime</a> ()</td></tr>
+
+<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the time in a string format to be display. <a href="#NLNET_1_1__CUniTimee4"></a><br><br></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee5">getUniTime</a> ()</td></tr>
+
+<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the time in millisecond. This time is the same on all computers at the <b>same</b> moment. <a href="#NLNET_1_1__CUniTimee5"></a><br><br></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee6">installServer</a> (<a class="el" href="a02307.html">CCallbackServer</a> *server)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee7">setUniTime</a> (<a class="el" href="a05378.html#a242">NLMISC::TTime</a> uTime)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee8">setUniTime</a> (<a class="el" href="a05378.html#a242">NLMISC::TTime</a> uTime, <a class="el" href="a05378.html#a242">NLMISC::TTime</a> lTime)</td></tr>
+
+<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">used by the time service to set the universal time the first time <a href="#NLNET_1_1__CUniTimee8"></a><br><br></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee9">simulate</a> ()</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee10">syncUniTimeFromServer</a> (<a class="el" href="a02305.html">CCallbackClient</a> *client)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimee11">syncUniTimeFromService</a> (<a class="el" href="a02306.html#NLNET_1_1CCallbackServerw8">CCallbackNetBase::TRecordingState</a> rec=CCallbackNetBase::Off, const <a class="el" href="a02665.html">CInetAddress</a> *<a class="el" href="a04223.html#a657">addr</a>=NULL)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>double&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02142.html#NLMISC_1_1CTimee3">ticksToSecond</a> (TTicks ticks)</td></tr>
+
+<tr><td colspan=2><br><h2>Static Public Attributes</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimes0">Sync</a> = false</td></tr>
+
+<tr><td colspan=2><br><h2>Static Private Attributes</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimev0">_Simulate</a> = false</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimev1">_SyncLocalTime</a> = 0</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02141.html#NLNET_1_1__CUniTimev2">_SyncUniTime</a> = 0</td></tr>
+
+</table>
+<hr><h2>Member Function Documentation</h2>
+<a class="anchor" name="NLMISC_1_1CTimee0" doxytag="NLNET::_CUniTime::getLocalTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> TTime NLMISC::CTime::getLocalTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static, inherited]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+get the time in millisecond. It's a <b>local</b> time, it means that the value is <b>different</b> on 2 differents computers. Use the CUniTime to get a universal time that is the same on all computers. <dl compact><dt><b>Warning:</b></dt><dd>On Windows, the value is on 32 bits only.</dd></dl>
+
+<p>
+Definition at line <a class="el" href="a06552.html#l00055">55</a> of file <a class="el" href="a06552.html">time_nl.cpp</a>.
+<p>
+References <a class="el" href="a06552.html#l00105">NLMISC::CTime::getPerformanceTime()</a>, <a class="el" href="a05622.html#l00154">nlerror</a>, and <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>.
+<p>
+Referenced by <a class="el" href="a05416.html#l00396">NLAIAGENT::CAgentWatchTimer::attach()</a>, <a class="el" href="a05466.html#l00565">NLSOUND::CAudioMixerUser::curTime()</a>, <a class="el" href="a06737.html#l01170">NL3D::CWaterModel::doSimpleRender()</a>, <a class="el" href="a05593.html#l00441">NLSOUND::CComplexSource::getTime()</a>, <a class="el" href="a05926.html#l00145">loadForm()</a>, <a class="el" href="a05593.html#l00577">NLSOUND::CComplexSource::onEvent()</a>, <a class="el" href="a05593.html#l00456">NLSOUND::CComplexSource::onUpdate()</a>, <a class="el" href="a05593.html#l00105">NLSOUND::CComplexSource::playStuf()</a>, <a class="el" href="a05416.html#l00140">NLAIAGENT::CAgentManagerTimer::CRunTimer::run()</a>, <a class="el" href="a05416.html#l00631">NLAIAGENT::CAgentClockTimer::runActivity()</a>, <a class="el" href="a05416.html#l00280">NLAIAGENT::CAgentWatchTimer::runActivity()</a>, <a class="el" href="a06737.html#l00831">NL3D::CWaterModel::setupMaterialNVertexShader()</a>, <a class="el" href="a06552.html#l00143">NLMISC::CTime::ticksToSecond()</a>, <a class="el" href="a06420.html#l00679">NLSOUND::CSoundDriverDSound::TimerCallback()</a>, <a class="el" href="a06420.html#l00703">NLSOUND::CSoundDriverDSound::update()</a>, <a class="el" href="a05465.html#l01268">NLSOUND::CAudioMixerUser::update()</a>, and <a class="el" href="a05471.html#l00861">NLSOUND::CBackgroundSoundManager::updateBackgroundStatus()</a>.
+<p>
+<div class="fragment"><pre>00056 {
+00057 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00058 <span class="preprocessor"></span>
+00059 <span class="keyword">static</span> <span class="keywordtype">bool</span> byperfcounter;
+00060 <span class="keyword">static</span> <span class="keywordtype">bool</span> initdone = <span class="keyword">false</span>;
+00061
+00062 <span class="comment">// Initialization</span>
+00063 <span class="keywordflow">if</span> ( ! initdone )
+00064 {
+00065 byperfcounter = (<a class="code" href="a02142.html#NLMISC_1_1CTimee1">getPerformanceTime</a>() != 0);
+00066 initdone = <span class="keyword">true</span>;
+00067 }
+00068
+00069 <span class="comment">/* Retrieve time is ms</span>
+00070 <span class="comment"> * Why do we prefer getPerformanceTime() to timeGetTime() ? Because on one dual-processor Win2k</span>
+00071 <span class="comment"> * PC, we have noticed that timeGetTime() slows down when the client is running !!!</span>
+00072 <span class="comment"> */</span>
+00073
+00074
+00075 <span class="comment">/* Now we have noticed that on all WinNT4 PC the getPerformanceTime can give us value that</span>
+00076 <span class="comment"> * are less than previous</span>
+00077 <span class="comment"> */</span>
+00078
+00079 <span class="comment">//if ( byperfcounter )</span>
+00080 <span class="comment">//{</span>
+00081 <span class="comment">// return (TTime)(ticksToSecond(getPerformanceTime()) * 1000.0f);</span>
+00082 <span class="comment">//}</span>
+00083 <span class="comment">//else</span>
+00084 <span class="comment">//{</span>
+00085 <span class="keywordflow">return</span> timeGetTime();
+00086 <span class="comment">//}</span>
+00087
+00088 <span class="preprocessor">#elif defined (NL_OS_UNIX)</span>
+00089 <span class="preprocessor"></span>
+00090 <span class="keyword">struct </span>timeval tv;
+00091
+00092 <span class="keywordflow">if</span> ( gettimeofday( &amp;tv, NULL) == -1 )
+00093 {
+00094 <a class="code" href="a04199.html#a3">nlerror</a> (<span class="stringliteral">"Cannot get time of day."</span>);
+00095 }
+00096 <span class="keywordflow">return</span> (<a class="code" href="a05378.html#a242">TTime</a>)tv.tv_sec * (<a class="code" href="a05378.html#a242">TTime</a>)1000 + (<a class="code" href="a05378.html#a242">TTime</a>)tv.tv_usec / (<a class="code" href="a05378.html#a242">TTime</a>)1000;
+00097
+00098 <span class="preprocessor">#endif</span>
+00099 <span class="preprocessor"></span>}
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLMISC_1_1CTimee1" doxytag="NLNET::_CUniTime::getPerformanceTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> TTicks NLMISC::CTime::getPerformanceTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static, inherited]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+get the time in processor ticks. Use it for profile purpose. Only implemented under windows for the time. If the performance time is not supported on this hardware, it returns 0.
+<p>
+Definition at line <a class="el" href="a06552.html#l00105">105</a> of file <a class="el" href="a06552.html">time_nl.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a06553.html#l00048">NLMISC::TTicks</a>, and <a class="el" href="a05646.html#l00236">x</a>.
+<p>
+Referenced by <a class="el" href="a06552.html#l00055">NLMISC::CTime::getLocalTime()</a>, <a class="el" href="a06479.html#l00441">NLMISC::CSystemInfo::getProcessorFrequency()</a>, <a class="el" href="a05412.html#l01628">NLAIAGENT::CAgentScript::run()</a>, <a class="el" href="a05412.html#l01284">NLAIAGENT::CAgentScript::sendMessage()</a>, and <a class="el" href="a06552.html#l00143">NLMISC::CTime::ticksToSecond()</a>.
+<p>
+<div class="fragment"><pre>00106 {
+00107 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00108 <span class="preprocessor"></span> LARGE_INTEGER ret;
+00109 <span class="keywordflow">if</span> (QueryPerformanceCounter (&amp;ret))
+00110 <span class="keywordflow">return</span> ret.QuadPart;
+00111 <span class="keywordflow">else</span>
+00112 <span class="keywordflow">return</span> 0;
+00113 <span class="preprocessor">#else // NL_OS_WINDOWS</span>
+00114 <span class="preprocessor"></span>
+00115 <span class="preprocessor">#ifdef HAVE_X86</span>
+00116 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="a04223.html#a572">x</a>;
+00117 __asm__ <span class="keyword">volatile</span> (<span class="stringliteral">".byte 0x0f, 0x31"</span> : <span class="stringliteral">"=A"</span> (<a class="code" href="a04223.html#a572">x</a>));
+00118 <span class="keywordflow">return</span> <a class="code" href="a04223.html#a572">x</a>;
+00119 <span class="preprocessor">#else // HAVE_X86</span>
+00120 <span class="preprocessor"></span> <span class="keyword">static</span> <span class="keywordtype">bool</span> firstWarn = <span class="keyword">true</span>;
+00121 <span class="keywordflow">if</span> (firstWarn)
+00122 {
+00123 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"TTicks CTime::getPerformanceTime () is not implemented for your processor, returning 0"</span>);
+00124 firstWarn = <span class="keyword">false</span>;
+00125 }
+00126 <span class="keywordflow">return</span> 0;
+00127 <span class="preprocessor">#endif // HAVE_X86</span>
+00128 <span class="preprocessor"></span>
+00129 <span class="preprocessor">#endif // NL_OS_WINDOWS</span>
+00130 <span class="preprocessor"></span>}
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLMISC_1_1CTimee2" doxytag="NLNET::_CUniTime::getSecondsSince1970" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> NLMISC::CTime::getSecondsSince1970 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static, inherited]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+returns the number of second since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock. This values is the same on all computer if computers are synchronized (with NTP for example).
+<p>
+Definition at line <a class="el" href="a06552.html#l00045">45</a> of file <a class="el" href="a06552.html">time_nl.cpp</a>.
+<p>
+References <a class="el" href="a05981.html#l00100">uint32</a>.
+<p>
+Referenced by <a class="el" href="a06033.html#l00258">NLAINIMAT::CMHiCSagent::CTemporaryPriority::CTemporaryPriority()</a>, and <a class="el" href="a06032.html#l01219">NLAINIMAT::CMHiCSagent::learningComputation()</a>.
+<p>
+<div class="fragment"><pre>00046 {
+00047 <span class="keywordflow">return</span> (<a class="code" href="a04558.html#a11">uint32</a>) time (NULL);
+00048 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee3" doxytag="NLNET::_CUniTime::getStringUniTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char * NLNET::_CUniTime::getStringUniTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>ut</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the time in a string format to be display.
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00096">96</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00416">nlstop</a>, <a class="el" href="a05646.html#l00977">s</a>, <a class="el" href="a05586.html#l00161">NLMISC::smprintf()</a>, <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00100">uint32</a>.
+<p>
+<div class="fragment"><pre>00097 {
+00098 <a class="code" href="a04199.html#a12">nlstop</a>;
+00099 <span class="keyword">static</span> <span class="keywordtype">char</span> str[512];
+00100
+00101 <a class="code" href="a04558.html#a11">uint32</a> ms = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % 1000); <span class="comment">// time in ms 1000ms dans 1s</span>
+00102 ut /= 1000;
+00103
+00104 <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a626">s</a> = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % 60); <span class="comment">// time in seconds 60s dans 1mn</span>
+00105 ut /= 60;
+00106
+00107 <a class="code" href="a04558.html#a11">uint32</a> m = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % 60); <span class="comment">// time in minutes 60m dans 1h</span>
+00108 ut /= 60;
+00109
+00110 <a class="code" href="a04558.html#a11">uint32</a> h = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % 9); <span class="comment">// time in hours 9h dans 1j</span>
+00111 ut /= 9;
+00112
+00113 <a class="code" href="a04558.html#a11">uint32</a> day = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % (8*4)); <span class="comment">// time in days 8day dans 1month</span>
+00114 ut /= 8;
+00115
+00116 <a class="code" href="a04558.html#a11">uint32</a> week = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % 4); <span class="comment">// time in weeks 4week dans 1month</span>
+00117 ut /= 4;
+00118
+00119 <a class="code" href="a04558.html#a11">uint32</a> month = (<a class="code" href="a04558.html#a11">uint32</a>) (ut % 12); <span class="comment">// time in months 12month dans 1year</span>
+00120 ut /= 12;
+00121
+00122 <a class="code" href="a04558.html#a15">uint</a> year = (<a class="code" href="a04558.html#a11">uint32</a>) ut; <span class="comment">// time in years</span>
+00123
+00124 <a class="code" href="a05378.html#a259">smprintf</a> (str, 512, <span class="stringliteral">"%02d/%02d/%04d (week %d) %02d:%02d:%02d.%03d"</span>, day+1, month+1, year+1, week+1, h, m, s, ms);
+00125 <span class="keywordflow">return</span> str;
+00126 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee4" doxytag="NLNET::_CUniTime::getStringUniTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char * NLNET::_CUniTime::getStringUniTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the time in a string format to be display.
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00089">89</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00416">nlstop</a>.
+<p>
+<div class="fragment"><pre>00090 {
+00091 <a class="code" href="a04199.html#a12">nlstop</a>;
+00092 <span class="keywordflow">return</span> <a class="code" href="a02141.html#NLNET_1_1__CUniTimee4">getStringUniTime</a>(_CUniTime::getUniTime());
+00093 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee5" doxytag="NLNET::_CUniTime::getUniTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> TTime NLNET::_CUniTime::getUniTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the time in millisecond. This time is the same on all computers at the <b>same</b> moment.
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00076">76</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00416">nlstop</a>, and <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>.
+<p>
+<div class="fragment"><pre>00077 {
+00078 <a class="code" href="a04199.html#a12">nlstop</a>;
+00079 <span class="keywordflow">return</span> 0;
+00080 <span class="comment">/* if (!Sync)</span>
+00081 <span class="comment"> {</span>
+00082 <span class="comment"> nlerror ("called getUniTime before calling syncUniTimeFromServer");</span>
+00083 <span class="comment"> }</span>
+00084 <span class="comment"> return getLocalTime () - (_SyncLocalTime - _SyncUniTime);</span>
+00085 <span class="comment">*/</span>
+00086 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee6" doxytag="NLNET::_CUniTime::installServer" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void NLNET::_CUniTime::installServer </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a02307.html">CCallbackServer</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>server</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Call this function in the init part of the front end service to enable time syncro between shard and clients.
+<p>
+Definition at line <a class="el" href="a06650.html#l00280">280</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05526.html#l00184">NLNET::CCallbackNetBase::addCallbackArray()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00416">nlstop</a>, and <a class="el" href="a06650.html#l00275">NLNET::ServerTimeServiceCallbackArray</a>.
+<p>
+<div class="fragment"><pre>00281 {
+00282 <a class="code" href="a04199.html#a12">nlstop</a>;
+00283 <span class="keyword">static</span> <span class="keywordtype">bool</span> alreadyAddedCallback = <span class="keyword">false</span>;
+00284 <a class="code" href="a04199.html#a6">nlassert</a> (server != NULL);
+00285 <a class="code" href="a04199.html#a6">nlassert</a> (!alreadyAddedCallback);
+00286
+00287 server-&gt;addCallbackArray (ServerTimeServiceCallbackArray, <span class="keyword">sizeof</span> (ServerTimeServiceCallbackArray) / <span class="keyword">sizeof</span> (ServerTimeServiceCallbackArray[0]));
+00288 alreadyAddedCallback = <span class="keyword">true</span>;
+00289 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee7" doxytag="NLNET::_CUniTime::setUniTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void NLNET::_CUniTime::setUniTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>uTime</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00068">68</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00416">nlstop</a>, and <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>.
+<p>
+<div class="fragment"><pre>00069 {
+00070 <a class="code" href="a04199.html#a12">nlstop</a>;
+00071 <span class="comment">// setUniTime (uTime, getLocalTime ());</span>
+00072 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee8" doxytag="NLNET::_CUniTime::setUniTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void NLNET::_CUniTime::setUniTime </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>uTime</em>, </td>
+ </tr>
+ <tr>
+ <td class="md" nowrap align="right"></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="a05378.html#a242">NLMISC::TTime</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>lTime</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+used by the time service to set the universal time the first time
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00049">49</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00416">nlstop</a>, and <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>.
+<p>
+<div class="fragment"><pre>00050 {
+00051 <a class="code" href="a04199.html#a12">nlstop</a>;
+00052 <span class="comment">/* if (Sync)</span>
+00053 <span class="comment"> {</span>
+00054 <span class="comment"> TTime lt = getLocalTime ();</span>
+00055 <span class="comment"> TTime delta = uTime - lTime + _SyncLocalTime - _SyncUniTime;</span>
+00056 <span class="comment"></span>
+00057 <span class="comment"> nlinfo ("_CUniTime::setUniTime(%"NL_I64"d, %"NL_I64"d): Resyncing delta %"NL_I64"dms",uTime,lTime,delta);</span>
+00058 <span class="comment"> }</span>
+00059 <span class="comment"> else</span>
+00060 <span class="comment"> {</span>
+00061 <span class="comment"> nlinfo ("_CUniTime::setUniTime(%"NL_I64"d, %"NL_I64"d)",uTime,lTime);</span>
+00062 <span class="comment"> Sync = true;</span>
+00063 <span class="comment"> }</span>
+00064 <span class="comment"> _SyncUniTime = uTime;</span>
+00065 <span class="comment"> _SyncLocalTime = lTime;</span>
+00066 <span class="comment">*/</span>}
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee9" doxytag="NLNET::_CUniTime::simulate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void NLNET::_CUniTime::simulate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [inline, static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Call this method before to prevent <a class="el" href="a02141.html#NLNET_1_1__CUniTimee11">syncUniTimeFromService()</a> from real synchronization: <a class="el" href="a02141.html#NLNET_1_1__CUniTimee11">syncUniTimeFromService()</a> will still communicate with the time service, as usual, but the local time will not be synchronized.
+<p>
+Definition at line <a class="el" href="a06651.html#l00096">96</a> of file <a class="el" href="a06651.html">unitime.h</a>.
+<p>
+References <a class="el" href="a06650.html#l00044">_Simulate</a>, and <a class="el" href="a05622.html#l00416">nlstop</a>.
+<p>
+<div class="fragment"><pre>00096 { <a class="code" href="a04199.html#a12">nlstop</a>; <a class="code" href="a02141.html#NLNET_1_1__CUniTimev0">_Simulate</a> = <span class="keyword">true</span>; }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee10" doxytag="NLNET::_CUniTime::syncUniTimeFromServer" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void NLNET::_CUniTime::syncUniTimeFromServer </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a02305.html">CCallbackClient</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>client</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Call this functions in the init part of the client side to synchronize between client and shard. client is the connection between the client and the front end. The connection must be established before calling this function.
+<p>
+Definition at line <a class="el" href="a06650.html#l00314">314</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05622.html#l00416">nlstop</a>.
+<p>
+<div class="fragment"><pre>00315 {
+00316 <a class="code" href="a04199.html#a12">nlstop</a>;
+00317 <span class="comment">/***************************************************************/</span>
+00318 <span class="comment">/******************* THE FOLLOWING CODE IS COMMENTED OUT *******/</span>
+00319 <span class="comment">/***************************************************************</span>
+00320 <span class="comment"></span>
+00321 <span class="comment"> static bool alreadyAddedCallback = false;</span>
+00322 <span class="comment"> nlassert (client != NULL);</span>
+00323 <span class="comment"></span>
+00324 <span class="comment"> if (!alreadyAddedCallback)</span>
+00325 <span class="comment"> {</span>
+00326 <span class="comment"> client-&gt;addCallbackArray (ClientUniTimeCallbackArray, sizeof (ClientUniTimeCallbackArray) / sizeof (ClientUniTimeCallbackArray[0]));</span>
+00327 <span class="comment"> alreadyAddedCallback = true;</span>
+00328 <span class="comment"> }</span>
+00329 <span class="comment"></span>
+00330 <span class="comment"> sint attempt = 0;</span>
+00331 <span class="comment"> TTime bestdelta = 60000; // 1 minute</span>
+00332 <span class="comment"></span>
+00333 <span class="comment"> if (!client-&gt;connected ()) goto error;</span>
+00334 <span class="comment"></span>
+00335 <span class="comment"> while (attempt &lt; 10)</span>
+00336 <span class="comment"> {</span>
+00337 <span class="comment"> CMessage msgout (client-&gt;getSIDA(), "AUT");</span>
+00338 <span class="comment"></span>
+00339 <span class="comment"> if (!client-&gt;connected()) goto error;</span>
+00340 <span class="comment"></span>
+00341 <span class="comment"> // send the message</span>
+00342 <span class="comment"> client-&gt;send (msgout);</span>
+00343 <span class="comment"></span>
+00344 <span class="comment"> // before time</span>
+00345 <span class="comment"> TTime before = CTime::getLocalTime ();</span>
+00346 <span class="comment"></span>
+00347 <span class="comment"> // receive the answer</span>
+00348 <span class="comment"> GetClientUniversalTime = false;</span>
+00349 <span class="comment"> while (!GetClientUniversalTime)</span>
+00350 <span class="comment"> {</span>
+00351 <span class="comment"> if (!client-&gt;connected()) goto error;</span>
+00352 <span class="comment"> </span>
+00353 <span class="comment"> client-&gt;update ();</span>
+00354 <span class="comment"> }</span>
+00355 <span class="comment"></span>
+00356 <span class="comment"> TTime after = CTime::getLocalTime (), delta = after - before;</span>
+00357 <span class="comment"></span>
+00358 <span class="comment"> if (delta &lt; 10 || delta &lt; bestdelta)</span>
+00359 <span class="comment"> {</span>
+00360 <span class="comment"> bestdelta = delta;</span>
+00361 <span class="comment"></span>
+00362 <span class="comment"> _CUniTime::setUniTime (GetClientUniversalTimeUniTime, (before+after)/2);</span>
+00363 <span class="comment"></span>
+00364 <span class="comment"> if (delta &lt; 10) break;</span>
+00365 <span class="comment"> }</span>
+00366 <span class="comment"> attempt++;</span>
+00367 <span class="comment"> }</span>
+00368 <span class="comment"> client-&gt;disconnect ();</span>
+00369 <span class="comment"> nlinfo ("Universal time is %"NL_I64"dms with a mean error of %"NL_I64"dms", _CUniTime::getUniTime(), bestdelta/2);</span>
+00370 <span class="comment"> return;</span>
+00371 <span class="comment">error:</span>
+00372 <span class="comment"> nlwarning ("there's no connection or lost or can't synchronize universal time");</span>
+00373 <span class="comment">***************************************************************/</span>
+00374 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimee11" doxytag="NLNET::_CUniTime::syncUniTimeFromService" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void NLNET::_CUniTime::syncUniTimeFromService </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a02306.html#NLNET_1_1CCallbackServerw8">CCallbackNetBase::TRecordingState</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>rec</em> = CCallbackNetBase::Off, </td>
+ </tr>
+ <tr>
+ <td class="md" nowrap align="right"></td>
+ <td></td>
+ <td class="md" nowrap>const <a class="el" href="a02665.html">CInetAddress</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>addr</em> = NULL</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"><code> [static]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+You need to call this function before calling getUniTime or an assert will occured. This function will connect to the time service and synchronize your computer. This function assumes that all services run on server that are time synchronized with NTP for example. If addr is NULL, the function will connect to the Time Service via the Naming Service. In this case, the <a class="el" href="a02980.html">CNamingClient</a> must be connected to a Naming Service. This function can be called *ONLY* by services that are inside of the shard. Don't use it for a client or a service outside of the shard.
+<p>
+Definition at line <a class="el" href="a06650.html#l00157">157</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+References <a class="el" href="a05646.html#l01127">addr</a>, and <a class="el" href="a05622.html#l00416">nlstop</a>.
+<p>
+<div class="fragment"><pre>00158 {
+00159 <a class="code" href="a04199.html#a12">nlstop</a>;
+00160 <span class="comment">/***************************************************************/</span>
+00161 <span class="comment">/******************* THE FOLLOWING CODE IS COMMENTED OUT *******/</span>
+00162 <span class="comment">/***************************************************************</span>
+00163 <span class="comment"> TTime deltaAdjust, lt;</span>
+00164 <span class="comment"> uint32 firstsecond, nextsecond;</span>
+00165 <span class="comment"> TTime before, after, delta;</span>
+00166 <span class="comment"></span>
+00167 <span class="comment"> // create a message with type in the full text format</span>
+00168 <span class="comment"> CMessage msgout ("AUT");</span>
+00169 <span class="comment"> CCallbackClient server( rec, "TS.nmr" );</span>
+00170 <span class="comment"> server.addCallbackArray (UniTimeCallbackArray, sizeof (UniTimeCallbackArray) / sizeof (UniTimeCallbackArray[0]));</span>
+00171 <span class="comment"></span>
+00172 <span class="comment"> if (addr == NULL)</span>
+00173 <span class="comment"> {</span>
+00174 <span class="comment"> CNamingClient::lookupAndConnect ("TS", server);</span>
+00175 <span class="comment"> }</span>
+00176 <span class="comment"> else</span>
+00177 <span class="comment"> {</span>
+00178 <span class="comment"> server.connect (*addr);</span>
+00179 <span class="comment"> }</span>
+00180 <span class="comment"></span>
+00181 <span class="comment"> if (!server.connected()) goto error;</span>
+00182 <span class="comment"></span>
+00183 <span class="comment"> server.send (msgout);</span>
+00184 <span class="comment"></span>
+00185 <span class="comment"> // before time</span>
+00186 <span class="comment"> before = CTime::getLocalTime ();</span>
+00187 <span class="comment"></span>
+00188 <span class="comment"> // receive the answer</span>
+00189 <span class="comment"> GetUniversalTime = false;</span>
+00190 <span class="comment"> while (!GetUniversalTime)</span>
+00191 <span class="comment"> {</span>
+00192 <span class="comment"> if (!server.connected()) goto error;</span>
+00193 <span class="comment"> </span>
+00194 <span class="comment"> server.update ();</span>
+00195 <span class="comment"></span>
+00196 <span class="comment"> nlSleep( 0 );</span>
+00197 <span class="comment"> }</span>
+00198 <span class="comment"></span>
+00199 <span class="comment"> // after, before and delta is not used. It's only for information purpose.</span>
+00200 <span class="comment"> after = CTime::getLocalTime ();</span>
+00201 <span class="comment"> delta = after - before;</span>
+00202 <span class="comment"></span>
+00203 <span class="comment"> nlinfo ("_CUniTime::syncUniTimeFromService(): ping:%"NL_I64"dms, time:%ds, unitime:%"NL_I64"dms", delta, GetUniversalTimeSecondsSince1970, GetUniversalTimeUniTime);</span>
+00204 <span class="comment"></span>
+00205 <span class="comment">// &lt;-- from here to the "--&gt;" comment, the block must be executed in less than one second or an infinite loop occurs</span>
+00206 <span class="comment"></span>
+00207 <span class="comment"> // get the second</span>
+00208 <span class="comment"> firstsecond = CTime::getSecondsSince1970 ();</span>
+00209 <span class="comment"> nextsecond = firstsecond+1;</span>
+00210 <span class="comment"> </span>
+00211 <span class="comment"> // wait the next start of the second (take 100% of CPU to be more accurate)</span>
+00212 <span class="comment"> while (nextsecond != CTime::getSecondsSince1970 ())</span>
+00213 <span class="comment"> nlassert (CTime::getSecondsSince1970 () &lt;= nextsecond);</span>
+00214 <span class="comment"></span>
+00215 <span class="comment">// --&gt;</span>
+00216 <span class="comment"></span>
+00217 <span class="comment"> // get the local time of the beginning of the next second</span>
+00218 <span class="comment"> lt = CTime::getLocalTime ();</span>
+00219 <span class="comment"></span>
+00220 <span class="comment"> if ( ! _Simulate )</span>
+00221 <span class="comment"> {</span>
+00222 <span class="comment"> if (abs((sint32)((TTime)nextsecond - (TTime)GetUniversalTimeSecondsSince1970)) &gt; 10)</span>
+00223 <span class="comment"> {</span>
+00224 <span class="comment"> nlerror ("the time delta (between me and the Time Service) is too big (more than 10s), servers aren't NTP synchronized");</span>
+00225 <span class="comment"> goto error;</span>
+00226 <span class="comment"> }</span>
+00227 <span class="comment"> </span>
+00228 <span class="comment"> // compute the delta between the other side and our side number of second since 1970</span>
+00229 <span class="comment"> deltaAdjust = ((TTime) nextsecond - (TTime) GetUniversalTimeSecondsSince1970) * 1000;</span>
+00230 <span class="comment"></span>
+00231 <span class="comment"> // adjust the unitime to the current localtime</span>
+00232 <span class="comment"> GetUniversalTimeUniTime += deltaAdjust;</span>
+00233 <span class="comment"></span>
+00234 <span class="comment"> nlinfo ("_CUniTime::syncUniTimeFromService(): rtime:%ds, runitime:%"NL_I64"ds, rlocaltime:%"NL_I64"d, deltaAjust:%"NL_I64"dms", nextsecond, GetUniversalTimeUniTime, lt, deltaAdjust);</span>
+00235 <span class="comment"> }</span>
+00236 <span class="comment"> else</span>
+00237 <span class="comment"> {</span>
+00238 <span class="comment"> nlinfo ("_CUniTime::syncUniTimeFromService(): runitime:%"NL_I64"ds, rlocaltime:%"NL_I64"d", GetUniversalTimeUniTime, lt);</span>
+00239 <span class="comment"> }</span>
+00240 <span class="comment"></span>
+00241 <span class="comment"> _CUniTime::setUniTime (GetUniversalTimeUniTime, lt);</span>
+00242 <span class="comment"></span>
+00243 <span class="comment"> server.disconnect ();</span>
+00244 <span class="comment"> return;</span>
+00245 <span class="comment"></span>
+00246 <span class="comment">error:</span>
+00247 <span class="comment"> nlerror ("Time Service is not found, lost or can't synchronize universal time");</span>
+00248 <span class="comment">***************************************************************/</span>
+00249
+00250 }
+</pre></div> </td>
+ </tr>
+</table>
+<a class="anchor" name="NLMISC_1_1CTimee3" doxytag="NLNET::_CUniTime::ticksToSecond" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> double NLMISC::CTime::ticksToSecond </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="a05378.html#a243">TTicks</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>ticks</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap><code> [static, inherited]</code></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+convert a ticks count into second. If the performance time is not supported on this hardware, it returns 0.0.
+<p>
+Definition at line <a class="el" href="a06552.html#l00143">143</a> of file <a class="el" href="a06552.html">time_nl.cpp</a>.
+<p>
+References <a class="el" href="a06552.html#l00055">NLMISC::CTime::getLocalTime()</a>, <a class="el" href="a06552.html#l00105">NLMISC::CTime::getPerformanceTime()</a>, <a class="el" href="a05981.html#l00101">sint64</a>, <a class="el" href="a06553.html#l00048">NLMISC::TTicks</a>, and <a class="el" href="a06553.html#l00047">NLMISC::TTime</a>.
+<p>
+Referenced by <a class="el" href="a06348.html#l00300">NL3D::CScene::render()</a>.
+<p>
+<div class="fragment"><pre>00144 {
+00145 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00146 <span class="preprocessor"></span> LARGE_INTEGER ret;
+00147 <span class="keywordflow">if</span> (QueryPerformanceFrequency(&amp;ret))
+00148 {
+00149 <span class="keywordflow">return</span> (<span class="keywordtype">double</span>)(<a class="code" href="a04558.html#a12">sint64</a>)ticks/(<span class="keywordtype">double</span>)ret.QuadPart;
+00150 }
+00151 <span class="keywordflow">else</span>
+00152 <span class="preprocessor">#endif // NL_OS_WINDOWS</span>
+00153 <span class="preprocessor"></span> {
+00154 <span class="keyword">static</span> <span class="keywordtype">bool</span> benchFrequency = <span class="keyword">true</span>;
+00155 <span class="keyword">static</span> <a class="code" href="a04558.html#a12">sint64</a> freq = 0;
+00156 <span class="keywordflow">if</span> (benchFrequency)
+00157 {
+00158 <span class="comment">// try to have an estimation of the cpu frequency</span>
+00159
+00160 <a class="code" href="a05378.html#a243">TTicks</a> tickBefore = <a class="code" href="a02142.html#NLMISC_1_1CTimee1">getPerformanceTime</a> ();
+00161 <a class="code" href="a05378.html#a243">TTicks</a> tickAfter = tickBefore;
+00162 <a class="code" href="a05378.html#a242">TTime</a> timeBefore = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">getLocalTime</a> ();
+00163 <a class="code" href="a05378.html#a242">TTime</a> timeAfter = timeBefore;
+00164 <span class="keywordflow">while</span> (<span class="keyword">true</span>)
+00165 {
+00166 <span class="keywordflow">if</span> (timeAfter - timeBefore &gt; 1000)
+00167 <span class="keywordflow">break</span>;
+00168 timeAfter = <a class="code" href="a02142.html#NLMISC_1_1CTimee0">getLocalTime</a> ();
+00169 tickAfter = <a class="code" href="a02142.html#NLMISC_1_1CTimee1">getPerformanceTime</a> ();
+00170 }
+00171
+00172 <a class="code" href="a05378.html#a242">TTime</a> timeDelta = timeAfter - timeBefore;
+00173 <a class="code" href="a05378.html#a243">TTicks</a> tickDelta = tickAfter - tickBefore;
+00174
+00175 freq = 1000 * tickDelta / timeDelta;
+00176 benchFrequency = <span class="keyword">false</span>;
+00177 }
+00178
+00179 <span class="keywordflow">return</span> (<span class="keywordtype">double</span>)(<a class="code" href="a04558.html#a12">sint64</a>)ticks/(<span class="keywordtype">double</span>)freq;
+00180 }
+00181 }
+</pre></div> </td>
+ </tr>
+</table>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="NLNET_1_1__CUniTimev0" doxytag="NLNET::_CUniTime::_Simulate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> bool <a class="el" href="a02141.html#NLNET_1_1__CUniTimev0">NLNET::_CUniTime::_Simulate</a> = false<code> [static, private]</code>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00044">44</a> of file <a class="el" href="a06650.html">unitime.cpp</a>.
+<p>
+Referenced by <a class="el" href="a06651.html#l00096">simulate()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimev1" doxytag="NLNET::_CUniTime::_SyncLocalTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> TTime <a class="el" href="a02141.html#NLNET_1_1__CUniTimev1">NLNET::_CUniTime::_SyncLocalTime</a> = 0<code> [static, private]</code>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00043">43</a> of file <a class="el" href="a06650.html">unitime.cpp</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimev2" doxytag="NLNET::_CUniTime::_SyncUniTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> TTime <a class="el" href="a02141.html#NLNET_1_1__CUniTimev2">NLNET::_CUniTime::_SyncUniTime</a> = 0<code> [static, private]</code>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00042">42</a> of file <a class="el" href="a06650.html">unitime.cpp</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="NLNET_1_1__CUniTimes0" doxytag="NLNET::_CUniTime::Sync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> bool <a class="el" href="a02141.html#NLNET_1_1__CUniTimes0">NLNET::_CUniTime::Sync</a> = false<code> [static]</code>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="a06650.html#l00046">46</a> of file <a class="el" href="a06650.html">unitime.cpp</a>. </td>
+ </tr>
+</table>
+<hr>The documentation for this class was generated from the following files:<ul>
+<li><a class="el" href="a06651.html">unitime.h</a><li><a class="el" href="a06650.html">unitime.cpp</a></ul>
+<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:51:20 2004 for NeL by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
+</a>1.3.6 </small></address>
+</body>
+</html>