⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wait_8h-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: wait.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="namespaces.html"><span>Namespaces</span></a></li>    <li><a href="classes.html"><span>Classes</span></a></li>    <li class="current"><a href="files.html"><span>Files</span></a></li>  </ul></div><div class="tabs">  <ul>    <li><a href="files.html"><span>File&nbsp;List</span></a></li>    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>  </ul></div><h1>wait.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_WAIT_H</span><a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_WAIT_H</span><a name="l00003"></a>00003 <span class="preprocessor"></span><a name="l00004"></a>00004 <span class="preprocessor">#include "config.h"</span><a name="l00005"></a>00005 <a name="l00006"></a>00006 <span class="preprocessor">#ifdef SOCKETS_AVAILABLE</span><a name="l00007"></a>00007 <span class="preprocessor"></span><a name="l00008"></a>00008 <span class="preprocessor">#include "misc.h"</span><a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="cryptlib_8h.html">cryptlib.h</a>"</span><a name="l00010"></a>00010 <span class="preprocessor">#include &lt;vector&gt;</span><a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="preprocessor">#ifdef USE_WINDOWS_STYLE_SOCKETS</span><a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#include &lt;winsock2.h&gt;</span><a name="l00014"></a>00014 <span class="preprocessor">#else</span><a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#include &lt;sys/types.h&gt;</span><a name="l00016"></a>00016 <span class="preprocessor">#endif</span><a name="l00017"></a>00017 <span class="preprocessor"></span><a name="l00018"></a>00018 <span class="preprocessor">#include "hrtimer.h"</span><a name="l00019"></a>00019 <a name="l00020"></a>00020 NAMESPACE_BEGIN(CryptoPP)<a name="l00021"></a>00021 <a name="l00022"></a><a class="code" href="class_tracer.html">00022</a> class <a class="code" href="class_tracer.html">Tracer</a><a name="l00023"></a>00023 {<a name="l00024"></a>00024 <span class="keyword">public</span>:<a name="l00025"></a><a class="code" href="class_tracer.html#07a52099be1d105b1cac45c65e5c9d43">00025</a>         Tracer(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level) : m_level(level) {}<a name="l00026"></a><a class="code" href="class_tracer.html#75af5a50ac97e257e3ddcd04a3e48841">00026</a>         <span class="keyword">virtual</span> ~Tracer() {}<a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="keyword">protected</span>:<span class="comment"></span><a name="l00029"></a>00029 <span class="comment">        //! Override this in your most-derived tracer to do the actual tracing.</span><a name="l00030"></a>00030 <span class="comment"></span>        <span class="keyword">virtual</span> <span class="keywordtype">void</span> Trace(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n, std::string <span class="keyword">const</span>&amp; s) = 0;<a name="l00031"></a>00031 <span class="comment"></span><a name="l00032"></a>00032 <span class="comment">        /*! By default, tracers will decide which trace messages to trace according to a trace level</span><a name="l00033"></a>00033 <span class="comment">                mechanism. If your most-derived tracer uses a different mechanism, override this to</span><a name="l00034"></a>00034 <span class="comment">                return false. If this method returns false, the default TraceXxxx(void) methods will all</span><a name="l00035"></a>00035 <span class="comment">                return 0 and must be overridden explicitly by your tracer for trace messages you want. */</span><a name="l00036"></a><a class="code" href="class_tracer.html#597288884db569634725da529869239b">00036</a>         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> UsingDefaults()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">true</span>; }<a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keyword">protected</span>:<a name="l00039"></a><a class="code" href="class_tracer.html#3d8de9648adbedb2224fd6d44a8171fa">00039</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_level;<a name="l00040"></a>00040 <a name="l00041"></a><a class="code" href="class_tracer.html#8be0f7b5bcdf614e8da200ad3432bb8a">00041</a>         <span class="keywordtype">void</span> TraceIf(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n, std::string <span class="keyword">const</span>&amp;s)<a name="l00042"></a>00042                 { <span class="keywordflow">if</span> (n) Trace(n, s); }<a name="l00043"></a>00043 <span class="comment"></span><a name="l00044"></a>00044 <span class="comment">        /*! Returns nr if, according to the default log settings mechanism (using log levels),</span><a name="l00045"></a>00045 <span class="comment">            the message should be traced. Returns 0 if the default trace level mechanism is not</span><a name="l00046"></a>00046 <span class="comment">                in use, or if it is in use but the event should not be traced. Provided as a utility</span><a name="l00047"></a>00047 <span class="comment">                method for easier and shorter coding of default TraceXxxx(void) implementations. */</span><a name="l00048"></a><a class="code" href="class_tracer.html#1be51f205354b91c71a214166590a6ab">00048</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Tracing(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nr, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> minLevel)<span class="keyword"> const</span><a name="l00049"></a>00049 <span class="keyword">                </span>{ <span class="keywordflow">return</span> (UsingDefaults() &amp;&amp; m_level &gt;= minLevel) ? nr : 0; }<a name="l00050"></a>00050 };<a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">// Your Tracer-derived class should inherit as virtual public from Tracer or another</span><a name="l00053"></a>00053 <span class="comment">// Tracer-derived class, and should pass the log level in its constructor. You can use the</span><a name="l00054"></a>00054 <span class="comment">// following methods to begin and end your Tracer definition.</span><a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="comment">// This constructor macro initializes Tracer directly even if not derived directly from it;</span><a name="l00057"></a>00057 <span class="comment">// this is intended, virtual base classes are always initialized by the most derived class.</span><a name="l00058"></a>00058 <span class="preprocessor">#define CRYPTOPP_TRACER_CONSTRUCTOR(DERIVED) \</span><a name="l00059"></a>00059 <span class="preprocessor">        public: DERIVED(unsigned int level = 0) : Tracer(level) {}</span><a name="l00060"></a>00060 <span class="preprocessor"></span><a name="l00061"></a>00061 <span class="preprocessor">#define CRYPTOPP_BEGIN_TRACER_CLASS_1(DERIVED, BASE1) \</span><a name="l00062"></a>00062 <span class="preprocessor">        class DERIVED : virtual public BASE1 { CRYPTOPP_TRACER_CONSTRUCTOR(DERIVED)</span><a name="l00063"></a>00063 <span class="preprocessor"></span><a name="l00064"></a>00064 <span class="preprocessor">#define CRYPTOPP_BEGIN_TRACER_CLASS_2(DERIVED, BASE1, BASE2) \</span><a name="l00065"></a>00065 <span class="preprocessor">        class DERIVED : virtual public BASE1, virtual public BASE2 { CRYPTOPP_TRACER_CONSTRUCTOR(DERIVED)</span><a name="l00066"></a>00066 <span class="preprocessor"></span><a name="l00067"></a>00067 <span class="preprocessor">#define CRYPTOPP_END_TRACER_CLASS };</span><a name="l00068"></a>00068 <span class="preprocessor"></span><a name="l00069"></a>00069 <span class="comment">// In your Tracer-derived class, you should define a globally unique event number for each</span><a name="l00070"></a>00070 <span class="comment">// new event defined. This can be done using the following macros.</span><a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="preprocessor">#define CRYPTOPP_BEGIN_TRACER_EVENTS(UNIQUENR)  enum { EVENTBASE = UNIQUENR,</span><a name="l00073"></a>00073 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_TRACER_EVENT(EVENTNAME)                                EventNr_##EVENTNAME,</span><a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_END_TRACER_EVENTS                              };</span><a name="l00075"></a>00075 <span class="preprocessor"></span><a name="l00076"></a>00076 <span class="comment">// In your own Tracer-derived class, you must define two methods per new trace event type:</span><a name="l00077"></a>00077 <span class="comment">// - unsigned int TraceXxxx() const</span><a name="l00078"></a>00078 <span class="comment">//   Your default implementation of this method should return the event number if according</span><a name="l00079"></a>00079 <span class="comment">//   to the default trace level system the event should be traced, or 0 if it should not.</span><a name="l00080"></a>00080 <span class="comment">// - void TraceXxxx(string const&amp; s)</span><a name="l00081"></a>00081 <span class="comment">//   This method should call TraceIf(TraceXxxx(), s); to do the tracing.</span><a name="l00082"></a>00082 <span class="comment">// For your convenience, a macro to define these two types of methods are defined below.</span><a name="l00083"></a>00083 <span class="comment">// If you use this macro, you should also use the TRACER_EVENTS macros above to associate</span><a name="l00084"></a>00084 <span class="comment">// event names with numbers.</span><a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="preprocessor">#define CRYPTOPP_TRACER_EVENT_METHODS(EVENTNAME, LOGLEVEL) \</span><a name="l00087"></a>00087 <span class="preprocessor">        virtual unsigned int Trace##EVENTNAME() const { return Tracing(EventNr_##EVENTNAME, LOGLEVEL); } \</span><a name="l00088"></a>00088 <span class="preprocessor">        virtual void Trace##EVENTNAME(std::string const&amp; s) { TraceIf(Trace##EVENTNAME(), s); }</span><a name="l00089"></a>00089 <span class="preprocessor"></span><a name="l00090"></a>00090 <span class="comment"></span><a name="l00091"></a>00091 <span class="comment">/*! A simple unidirectional linked list with m_prev == 0 to indicate the final entry.</span><a name="l00092"></a>00092 <span class="comment">    The aim of this implementation is to provide a very lightweight and practical</span><a name="l00093"></a>00093 <span class="comment">        tracing mechanism with a low performance impact. Functions and methods supporting</span><a name="l00094"></a>00094 <span class="comment">        this call-stack mechanism would take a parameter of the form "CallStack const&amp; callStack",</span><a name="l00095"></a>00095 <span class="comment">        and would pass this parameter to subsequent functions they call using the construct:</span><a name="l00096"></a>00096 <span class="comment"></span><a name="l00097"></a>00097 <span class="comment">        SubFunc(arg1, arg2, CallStack("my func at place such and such", &amp;callStack));</span>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -