summaryrefslogtreecommitdiff
path: root/channels.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2002-10-04 17:31:41 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2002-10-04 17:31:41 +0000
commitb21162cf8e06f40baa1f58be6a8c17435cebc34d (patch)
tree8b045309c238226c32a563b1df6b9c30a2f0e0b3 /channels.h
downloadcryptopp-b21162cf8e06f40baa1f58be6a8c17435cebc34d.tar.gz
Initial revision
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@2 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'channels.h')
-rw-r--r--channels.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/channels.h b/channels.h
new file mode 100644
index 0000000..4b12ce6
--- /dev/null
+++ b/channels.h
@@ -0,0 +1,91 @@
+#ifndef CRYPTOPP_CHANNELS_H
+#define CRYPTOPP_CHANNELS_H
+
+#include "simple.h"
+#include "smartptr.h"
+#include <map>
+#include <list>
+
+NAMESPACE_BEGIN(CryptoPP)
+
+#if 0
+//! Route input on default channel to different and/or multiple channels based on message sequence number
+class MessageSwitch : public Sink
+{
+public:
+ void AddDefaultRoute(BufferedTransformation &destination, const std::string &channel);
+ void AddRoute(unsigned int begin, unsigned int end, BufferedTransformation &destination, const std::string &channel);
+
+ void Put(byte inByte);
+ void Put(const byte *inString, unsigned int length);
+
+ void Flush(bool completeFlush, int propagation=-1);
+ void MessageEnd(int propagation=-1);
+ void PutMessageEnd(const byte *inString, unsigned int length, int propagation=-1);
+ void MessageSeriesEnd(int propagation=-1);
+
+private:
+ typedef std::pair<BufferedTransformation *, std::string> Route;
+ struct RangeRoute
+ {
+ RangeRoute(unsigned int begin, unsigned int end, const Route &route)
+ : begin(begin), end(end), route(route) {}
+ bool operator<(const RangeRoute &rhs) const {return begin < rhs.begin;}
+ unsigned int begin, end;
+ Route route;
+ };
+
+ typedef std::list<RangeRoute> RouteList;
+ typedef std::list<Route> DefaultRouteList;
+
+ RouteList m_routes;
+ DefaultRouteList m_defaultRoutes;
+ unsigned int m_nCurrentMessage;
+};
+#endif
+
+//! Route input to different and/or multiple channels based on channel ID
+class ChannelSwitch : public Multichannel<Sink>
+{
+public:
+ ChannelSwitch() {}
+ ChannelSwitch(BufferedTransformation &destination)
+ {
+ AddDefaultRoute(destination);
+ }
+ ChannelSwitch(BufferedTransformation &destination, const std::string &outChannel)
+ {
+ AddDefaultRoute(destination, outChannel);
+ }
+
+ unsigned int ChannelPut2(const std::string &channel, const byte *begin, unsigned int length, int messageEnd, bool blocking);
+ unsigned int ChannelPutModifiable2(const std::string &channel, byte *begin, unsigned int length, int messageEnd, bool blocking);
+
+ void ChannelInitialize(const std::string &channel, const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1);
+ bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true);
+ bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true);
+
+ byte * ChannelCreatePutSpace(const std::string &channel, unsigned int &size);
+
+ void AddDefaultRoute(BufferedTransformation &destination);
+ void RemoveDefaultRoute(BufferedTransformation &destination);
+ void AddDefaultRoute(BufferedTransformation &destination, const std::string &outChannel);
+ void RemoveDefaultRoute(BufferedTransformation &destination, const std::string &outChannel);
+ void AddRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel);
+ void RemoveRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel);
+
+private:
+ typedef std::pair<BufferedTransformation *, std::string> Route;
+ typedef std::multimap<std::string, Route> RouteMap;
+ RouteMap m_routeMap;
+
+ typedef std::pair<BufferedTransformation *, value_ptr<std::string> > DefaultRoute;
+ typedef std::list<DefaultRoute> DefaultRouteList;
+ DefaultRouteList m_defaultRoutes;
+
+ friend class ChannelRouteIterator;
+};
+
+NAMESPACE_END
+
+#endif