00001 #ifndef CRYPTOPP_CHANNELS_H
00002 #define CRYPTOPP_CHANNELS_H
00003
00004 #include "cryptlib.h"
00005 #include "smartptr.h"
00006 #include <map>
00007 #include <list>
00008
00009 NAMESPACE_BEGIN(CryptoPP)
00010
00012 class ChannelSwitch : public BufferedTransformation
00013 {
00014 public:
00015 ChannelSwitch() {}
00016 ChannelSwitch(BufferedTransformation &destination)
00017 {
00018 AddDefaultRoute(destination);
00019 }
00020 ChannelSwitch(BufferedTransformation &destination, const std::string &outChannel)
00021 {
00022 AddDefaultRoute(destination, outChannel);
00023 }
00024
00025 void Put(byte inByte);
00026 void Put(const byte *inString, unsigned int length);
00027
00028 void Flush(bool completeFlush, int propagation=-1);
00029 void MessageEnd(int propagation=-1);
00030 void PutMessageEnd(const byte *inString, unsigned int length, int propagation=-1);
00031 void MessageSeriesEnd(int propagation=-1);
00032
00033 void ChannelPut(const std::string &channel, byte inByte);
00034 void ChannelPut(const std::string &channel, const byte *inString, unsigned int length);
00035
00036 void ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1);
00037 void ChannelMessageEnd(const std::string &channel, int propagation=-1);
00038 void ChannelPutMessageEnd(const std::string &channel, const byte *inString, unsigned int length, int propagation=-1);
00039 void ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1);
00040
00041 void AddDefaultRoute(BufferedTransformation &destination);
00042 void RemoveDefaultRoute(BufferedTransformation &destination);
00043 void AddDefaultRoute(BufferedTransformation &destination, const std::string &outChannel);
00044 void RemoveDefaultRoute(BufferedTransformation &destination, const std::string &outChannel);
00045 void AddRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel);
00046 void RemoveRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel);
00047
00048 private:
00049 typedef std::pair<BufferedTransformation *, std::string> Route;
00050 typedef std::multimap<std::string, Route> RouteMap;
00051 RouteMap m_routeMap;
00052
00053 typedef std::pair<BufferedTransformation *, value_ptr<std::string> > DefaultRoute;
00054 typedef std::list<DefaultRoute> DefaultRouteList;
00055 DefaultRouteList m_defaultRoutes;
00056
00057 friend class RouteIterator;
00058 };
00059
00060 NAMESPACE_END
00061
00062 #endif