Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.0 KiB

  1. #ifndef CRYPTOPP_CHANNELS_H
  2. #define CRYPTOPP_CHANNELS_H
  3. #include "simple.h"
  4. #include "smartptr.h"
  5. #include <map>
  6. #include <list>
  7. NAMESPACE_BEGIN(CryptoPP)
  8. #if 0
  9. //! Route input on default channel to different and/or multiple channels based on message sequence number
  10. class MessageSwitch : public Sink
  11. {
  12. public:
  13. void AddDefaultRoute(BufferedTransformation &destination, const std::string &channel);
  14. void AddRoute(unsigned int begin, unsigned int end, BufferedTransformation &destination, const std::string &channel);
  15. void Put(byte inByte);
  16. void Put(const byte *inString, unsigned int length);
  17. void Flush(bool completeFlush, int propagation=-1);
  18. void MessageEnd(int propagation=-1);
  19. void PutMessageEnd(const byte *inString, unsigned int length, int propagation=-1);
  20. void MessageSeriesEnd(int propagation=-1);
  21. private:
  22. typedef std::pair<BufferedTransformation *, std::string> Route;
  23. struct RangeRoute
  24. {
  25. RangeRoute(unsigned int begin, unsigned int end, const Route &route)
  26. : begin(begin), end(end), route(route) {}
  27. bool operator<(const RangeRoute &rhs) const {return begin < rhs.begin;}
  28. unsigned int begin, end;
  29. Route route;
  30. };
  31. typedef std::list<RangeRoute> RouteList;
  32. typedef std::list<Route> DefaultRouteList;
  33. RouteList m_routes;
  34. DefaultRouteList m_defaultRoutes;
  35. unsigned int m_nCurrentMessage;
  36. };
  37. #endif
  38. class ChannelSwitchTypedefs
  39. {
  40. public:
  41. typedef std::pair<BufferedTransformation *, std::string> Route;
  42. typedef std::multimap<std::string, Route> RouteMap;
  43. typedef std::pair<BufferedTransformation *, value_ptr<std::string> > DefaultRoute;
  44. typedef std::list<DefaultRoute> DefaultRouteList;
  45. // SunCC workaround: can't use const_iterator here
  46. typedef RouteMap::iterator MapIterator;
  47. typedef DefaultRouteList::iterator ListIterator;
  48. };
  49. class ChannelSwitch;
  50. class ChannelRouteIterator : public ChannelSwitchTypedefs
  51. {
  52. public:
  53. ChannelSwitch& m_cs;
  54. std::string m_channel;
  55. bool m_useDefault;
  56. MapIterator m_itMapCurrent, m_itMapEnd;
  57. ListIterator m_itListCurrent, m_itListEnd;
  58. ChannelRouteIterator(ChannelSwitch &cs) : m_cs(cs) {}
  59. void Reset(const std::string &channel);
  60. bool End() const;
  61. void Next();
  62. BufferedTransformation & Destination();
  63. const std::string & Channel();
  64. };
  65. //! Route input to different and/or multiple channels based on channel ID
  66. class CRYPTOPP_DLL ChannelSwitch : public Multichannel<Sink>, public ChannelSwitchTypedefs
  67. {
  68. public:
  69. ChannelSwitch() : m_it(*this), m_blocked(false) {}
  70. ChannelSwitch(BufferedTransformation &destination) : m_it(*this), m_blocked(false)
  71. {
  72. AddDefaultRoute(destination);
  73. }
  74. ChannelSwitch(BufferedTransformation &destination, const std::string &outChannel) : m_it(*this), m_blocked(false)
  75. {
  76. AddDefaultRoute(destination, outChannel);
  77. }
  78. void IsolatedInitialize(const NameValuePairs &parameters=g_nullNameValuePairs);
  79. size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking);
  80. size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking);
  81. bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true);
  82. bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true);
  83. byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);
  84. void AddDefaultRoute(BufferedTransformation &destination);
  85. void RemoveDefaultRoute(BufferedTransformation &destination);
  86. void AddDefaultRoute(BufferedTransformation &destination, const std::string &outChannel);
  87. void RemoveDefaultRoute(BufferedTransformation &destination, const std::string &outChannel);
  88. void AddRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel);
  89. void RemoveRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel);
  90. private:
  91. RouteMap m_routeMap;
  92. DefaultRouteList m_defaultRoutes;
  93. ChannelRouteIterator m_it;
  94. bool m_blocked;
  95. friend class ChannelRouteIterator;
  96. };
  97. NAMESPACE_END
  98. #endif