<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Crypto++: mqueue.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.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 List</span></a></li> <li><a href="globals.html"><span>File 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 <deque></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><<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a>> <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>00016 <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> &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#a3ca42e60e7de1cfada145609cb3eb5e9">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>00029 <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>00030 <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#a636d1842ab46a50cdb8517aec0df6c5d">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#a8d1efa74c89f571b3bc9f00a947fbaa9">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() > 0;} <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keywordtype">size_t</span> TransferTo2(BufferedTransformation &target, lword &transferBytes, <span class="keyword">const</span> std::string &channel=DEFAULT_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 &target, lword &begin, lword end=LWORD_MAX, <span class="keyword">const</span> std::string &channel=DEFAULT_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>00041 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#a00b443a9dd55d2b8c6e38b544dee189b">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>00047 <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>00049 <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 &target, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> count=UINT_MAX, <span class="keyword">const</span> std::string &channel=DEFAULT_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> &contiguousSize) <span class="keyword">const</span>; <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="keywordtype">void</span> swap(<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &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<lword> m_lengths; <a name="l00061"></a>00061 std::deque<unsigned int> 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><Multichannel<Filter> > <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">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#a488c095db121999ba40c936573701d10">00072</a> <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a>(BufferedTransformation *attachment=NULL, <span class="keywordtype">bool</span> throwIfNotEqual=<span class="keyword">true</span>, <span class="keyword">const</span> std::string &firstChannel=<span class="stringliteral">"0"</span>, <span class="keyword">const</span> std::string &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 &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 &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 &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 <span class="preprocessor">#ifndef __BORLANDC__</span> <a name="l00092"></a>00092 <span class="preprocessor"></span>NAMESPACE_BEGIN(std) <a name="l00093"></a>00093 template<> inline <span class="keywordtype">void</span> swap(CryptoPP::<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &a, CryptoPP::<a class="code" href="class_message_queue.html" title="Message Queue.">MessageQueue</a> &b) <a name="l00094"></a>00094 { <a name="l00095"></a>00095 a.swap(b); <a name="l00096"></a>00096 } <a name="l00097"></a>00097 NAMESPACE_END <a name="l00098"></a>00098 <span class="preprocessor">#endif</span> <a name="l00099"></a>00099 <span class="preprocessor"></span> <a name="l00100"></a>00100 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>