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

📄 mqueue_8h-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
字号:
<!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++: mqueue.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>mqueue.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_MQUEUE_H</span><a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_MQUEUE_H</span><a name="l00003"></a>00003 <span class="preprocessor"></span><a name="l00004"></a>00004 <span class="preprocessor">#include "queue.h"</span><a name="l00005"></a>00005 <span class="preprocessor">#include "filters.h"</span><a name="l00006"></a>00006 <span class="preprocessor">#include &lt;deque&gt;</span><a name="l00007"></a>00007 <a name="l00008"></a>00008 NAMESPACE_BEGIN(CryptoPP)<a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="comment">//! Message Queue</span><a name="l00011"></a><a class="code" href="class_message_queue.html">00011</a> <span class="comment"></span>class CRYPTOPP_DLL <a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> : public <a class="code" href="class_auto_signaling.html" title="_">AutoSignaling</a>&lt;<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a>&gt;<a name="l00012"></a>00012 {<a name="l00013"></a>00013 <span class="keyword">public</span>:<a name="l00014"></a>00014         <a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nodeSize=256);<a name="l00015"></a>00015 <a name="l00016"></a><a class="code" href="class_message_queue.html#26b8baf32ac98064caf0696fc37dcacf">00016</a>         <span class="keywordtype">void</span> IsolatedInitialize(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &amp;parameters)<a name="l00017"></a>00017                 {m_queue.IsolatedInitialize(parameters); m_lengths.assign(1, 0U); m_messageCounts.assign(1, 0U);}<a name="l00018"></a><a class="code" href="class_message_queue.html#3ca42e60e7de1cfada145609cb3eb5e9">00018</a>         <span class="keywordtype">size_t</span> Put2(<span class="keyword">const</span> byte *begin, <span class="keywordtype">size_t</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking)<a name="l00019"></a>00019         {<a name="l00020"></a>00020                 m_queue.Put(begin, length);<a name="l00021"></a>00021                 m_lengths.back() += length;<a name="l00022"></a>00022                 <span class="keywordflow">if</span> (messageEnd)<a name="l00023"></a>00023                 {<a name="l00024"></a>00024                         m_lengths.push_back(0);<a name="l00025"></a>00025                         m_messageCounts.back()++;<a name="l00026"></a>00026                 }<a name="l00027"></a>00027                 <span class="keywordflow">return</span> 0;<a name="l00028"></a>00028         }<a name="l00029"></a><a class="code" href="class_message_queue.html#df7c0e8cc64279572e4bfc282bcdba78">00029</a>         <span class="keywordtype">bool</span> IsolatedFlush(<span class="keywordtype">bool</span> hardFlush, <span class="keywordtype">bool</span> blocking) {<span class="keywordflow">return</span> <span class="keyword">false</span>;}<a name="l00030"></a><a class="code" href="class_message_queue.html#574f29031f2d8ae02e7ff4a03e5db8bf">00030</a>         <span class="keywordtype">bool</span> IsolatedMessageSeriesEnd(<span class="keywordtype">bool</span> blocking)<a name="l00031"></a>00031                 {m_messageCounts.push_back(0); <span class="keywordflow">return</span> <span class="keyword">false</span>;}<a name="l00032"></a>00032 <a name="l00033"></a><a class="code" href="class_message_queue.html#fc8f0d4551de7b0a19d7747420015d1c">00033</a>         lword MaxRetrievable()<span class="keyword"> const</span><a name="l00034"></a>00034 <span class="keyword">                </span>{<span class="keywordflow">return</span> m_lengths.front();}<a name="l00035"></a><a class="code" href="class_message_queue.html#1f9ba84c015a1ca041ae7765c423e711">00035</a>         <span class="keywordtype">bool</span> AnyRetrievable()<span class="keyword"> const</span><a name="l00036"></a>00036 <span class="keyword">                </span>{<span class="keywordflow">return</span> m_lengths.front() &gt; 0;}<a name="l00037"></a>00037 <a name="l00038"></a>00038         <span class="keywordtype">size_t</span> TransferTo2(BufferedTransformation &amp;target, lword &amp;transferBytes, <span class="keyword">const</span> std::string &amp;channel=NULL_CHANNEL, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>);<a name="l00039"></a>00039         <span class="keywordtype">size_t</span> CopyRangeTo2(BufferedTransformation &amp;target, lword &amp;begin, lword end=LWORD_MAX, <span class="keyword">const</span> std::string &amp;channel=NULL_CHANNEL, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>) <span class="keyword">const</span>;<a name="l00040"></a>00040 <a name="l00041"></a><a class="code" href="class_message_queue.html#d42da27546fd65f68cecb4b6bab7fb5c">00041</a>         lword TotalBytesRetrievable()<span class="keyword"> const</span><a name="l00042"></a>00042 <span class="keyword">                </span>{<span class="keywordflow">return</span> m_queue.MaxRetrievable();}<a name="l00043"></a><a class="code" href="class_message_queue.html#a4b2a11a888efea5f9ca388d8a730bba">00043</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> NumberOfMessages()<span class="keyword"> const</span><a name="l00044"></a>00044 <span class="keyword">                </span>{<span class="keywordflow">return</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)m_lengths.size()-1;}<a name="l00045"></a>00045         <span class="keywordtype">bool</span> GetNextMessage();<a name="l00046"></a>00046 <a name="l00047"></a><a class="code" href="class_message_queue.html#bc4b9d535126eff81e67ef29074a3887">00047</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> NumberOfMessagesInThisSeries()<span class="keyword"> const</span><a name="l00048"></a>00048 <span class="keyword">                </span>{<span class="keywordflow">return</span> m_messageCounts[0];}<a name="l00049"></a><a class="code" href="class_message_queue.html#2366404f56eeb93ac97d44e5abb7e940">00049</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> NumberOfMessageSeries()<span class="keyword"> const</span><a name="l00050"></a>00050 <span class="keyword">                </span>{<span class="keywordflow">return</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)m_messageCounts.size()-1;}<a name="l00051"></a>00051 <a name="l00052"></a>00052         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> CopyMessagesTo(BufferedTransformation &amp;target, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> count=UINT_MAX, <span class="keyword">const</span> std::string &amp;channel=NULL_CHANNEL) <span class="keyword">const</span>;<a name="l00053"></a>00053 <a name="l00054"></a>00054         <span class="keyword">const</span> byte * Spy(<span class="keywordtype">size_t</span> &amp;contiguousSize) <span class="keyword">const</span>;<a name="l00055"></a>00055 <a name="l00056"></a>00056         <span class="keywordtype">void</span> <a class="code" href="gf2n_8h.html#cd9c045f0b5c2a7595a8a0872dc80f59">swap</a>(<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &amp;rhs);<a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="keyword">private</span>:<a name="l00059"></a>00059         <a class="code" href="class_byte_queue.html" title="Byte Queue.">ByteQueue</a> m_queue;<a name="l00060"></a>00060         std::deque&lt;lword&gt; m_lengths;<a name="l00061"></a>00061         std::deque&lt;unsigned int&gt; m_messageCounts;<a name="l00062"></a>00062 };<a name="l00063"></a>00063 <a name="l00064"></a>00064 <span class="comment"></span><a name="l00065"></a>00065 <span class="comment">//! A filter that checks messages on two channels for equality</span><a name="l00066"></a><a class="code" href="class_equality_comparison_filter.html">00066</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_DLL <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a> : <span class="keyword">public</span> <a class="code" href="class_unflushable.html" title="_">Unflushable</a>&lt;Multichannel&lt;Filter&gt; &gt;<a name="l00067"></a>00067 {<a name="l00068"></a>00068 <span class="keyword">public</span>:<a name="l00069"></a><a class="code" href="struct_equality_comparison_filter_1_1_mismatch_detected.html#2e7c0df0d4a02db2ccdf8314f722ff57">00069</a>         <span class="keyword">struct </span><a class="code" href="struct_equality_comparison_filter_1_1_mismatch_detected.html">MismatchDetected</a> : <span class="keyword">public</span> <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a> {<a class="code" href="struct_equality_comparison_filter_1_1_mismatch_detected.html">MismatchDetected</a>() : <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a>(DATA_INTEGRITY_CHECK_FAILED, <span class="stringliteral">"EqualityComparisonFilter: did not receive the same data on two channels"</span>) {}};<a name="l00070"></a>00070 <span class="comment"></span><a name="l00071"></a>00071 <span class="comment">        /*! if throwIfNotEqual is false, this filter will output a '\\0' byte when it detects a mismatch, '\\1' otherwise */</span><a name="l00072"></a><a class="code" href="class_equality_comparison_filter.html#488c095db121999ba40c936573701d10">00072</a>         <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment=NULL, <span class="keywordtype">bool</span> throwIfNotEqual=<span class="keyword">true</span>, <span class="keyword">const</span> std::string &amp;firstChannel=<span class="stringliteral">"0"</span>, <span class="keyword">const</span> std::string &amp;secondChannel=<span class="stringliteral">"1"</span>)<a name="l00073"></a>00073                 : m_throwIfNotEqual(throwIfNotEqual), m_mismatchDetected(false)<a name="l00074"></a>00074                 , m_firstChannel(firstChannel), m_secondChannel(secondChannel)<a name="l00075"></a>00075                 {Detach(attachment);}<a name="l00076"></a>00076 <a name="l00077"></a>00077         <span class="keywordtype">size_t</span> ChannelPut2(<span class="keyword">const</span> std::string &amp;channel, <span class="keyword">const</span> byte *begin, <span class="keywordtype">size_t</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking);<a name="l00078"></a>00078         <span class="keywordtype">bool</span> ChannelMessageSeriesEnd(<span class="keyword">const</span> std::string &amp;channel, <span class="keywordtype">int</span> propagation=-1, <span class="keywordtype">bool</span> blocking=<span class="keyword">true</span>);<a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="keyword">private</span>:<a name="l00081"></a>00081         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MapChannel(<span class="keyword">const</span> std::string &amp;channel) <span class="keyword">const</span>;<a name="l00082"></a>00082         <span class="keywordtype">bool</span> HandleMismatchDetected(<span class="keywordtype">bool</span> blocking);<a name="l00083"></a>00083 <a name="l00084"></a>00084         <span class="keywordtype">bool</span> m_throwIfNotEqual, m_mismatchDetected;<a name="l00085"></a>00085         std::string m_firstChannel, m_secondChannel;<a name="l00086"></a>00086         <a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> m_q[2];<a name="l00087"></a>00087 };<a name="l00088"></a>00088 <a name="l00089"></a>00089 NAMESPACE_END<a name="l00090"></a>00090 <a name="l00091"></a>00091 NAMESPACE_BEGIN(std)<a name="l00092"></a>00092 template&lt;&gt; inline <span class="keywordtype">void</span> <a class="code" href="gf2n_8h.html#cd9c045f0b5c2a7595a8a0872dc80f59">swap</a>(CryptoPP::<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &amp;a, CryptoPP::<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &amp;b)<a name="l00093"></a>00093 {<a name="l00094"></a>00094         a.swap(b);<a name="l00095"></a>00095 }<a name="l00096"></a>00096 NAMESPACE_END<a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jun 1 11:11:22 2007 for Crypto++ by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>

⌨️ 快捷键说明

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