From 78cbd84a0068db09b6d08ff14a316800ad9be89a Mon Sep 17 00:00:00 2001 From: weidai Date: Tue, 15 Apr 2003 00:38:48 +0000 Subject: fix bug in Grouper add RIPEMD-???, Whirlpool, Shacal2, Camellia, Two-Track MAC (Kevin Springle) change ChannelSwitch to allow non-blocking input (denis bider) change Redirector to allow more options (denis bider) fix MaurerRandomnessTest optimize MD2 (Kevin Springle) git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@55 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- channels.h | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'channels.h') diff --git a/channels.h b/channels.h index 4b12ce6..cc9aa66 100644 --- a/channels.h +++ b/channels.h @@ -44,16 +44,48 @@ private: }; #endif +class ChannelSwitchTypedefs +{ +public: + typedef std::pair Route; + typedef std::multimap RouteMap; + + typedef std::pair > DefaultRoute; + typedef std::list DefaultRouteList; + + typedef RouteMap::const_iterator MapIterator; + typedef DefaultRouteList::const_iterator ListIterator; +}; + +class ChannelSwitch; + +class ChannelRouteIterator : public ChannelSwitchTypedefs +{ +public: + ChannelSwitch& m_cs; + std::string m_channel; + bool m_useDefault; + MapIterator m_itMapCurrent, m_itMapEnd; + ListIterator m_itListCurrent, m_itListEnd; + + ChannelRouteIterator(ChannelSwitch &cs) : m_cs(cs) {} + void Reset(const std::string &channel); + bool End() const; + void Next(); + BufferedTransformation & Destination(); + const std::string & Channel(); +}; + //! Route input to different and/or multiple channels based on channel ID -class ChannelSwitch : public Multichannel +class ChannelSwitch : public Multichannel, public ChannelSwitchTypedefs { public: - ChannelSwitch() {} - ChannelSwitch(BufferedTransformation &destination) + ChannelSwitch() : m_it(*this), m_blocked(false) {} + ChannelSwitch(BufferedTransformation &destination) : m_it(*this), m_blocked(false) { AddDefaultRoute(destination); } - ChannelSwitch(BufferedTransformation &destination, const std::string &outChannel) + ChannelSwitch(BufferedTransformation &destination, const std::string &outChannel) : m_it(*this), m_blocked(false) { AddDefaultRoute(destination, outChannel); } @@ -75,14 +107,12 @@ public: void RemoveRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel); private: - typedef std::pair Route; - typedef std::multimap RouteMap; RouteMap m_routeMap; - - typedef std::pair > DefaultRoute; - typedef std::list DefaultRouteList; DefaultRouteList m_defaultRoutes; + ChannelRouteIterator m_it; + bool m_blocked; + friend class ChannelRouteIterator; }; -- cgit v1.2.1