6#ifndef CRYPTOPP_IMPORTS
11#if CRYPTOPP_MSC_VERSION
12# pragma warning(disable: 4355)
15NAMESPACE_BEGIN(CryptoPP)
20 m_defaultRoutes.push_back(Route(&destination, channel));
23void MessageSwitch::AddRoute(
unsigned int begin,
unsigned int end,
BufferedTransformation &destination,
const std::string &channel)
25 RangeRoute route(begin, end, Route(&destination, channel));
26 RouteList::iterator it = upper_bound(m_routes.begin(), m_routes.end(), route);
27 m_routes.insert(it, route);
101void ChannelRouteIterator::Reset(
const std::string &channel)
104 std::pair<MapIterator, MapIterator> range = m_cs.m_routeMap.equal_range(channel);
105 if (range.first == range.second)
108 m_itListCurrent = m_cs.m_defaultRoutes.begin();
109 m_itListEnd = m_cs.m_defaultRoutes.end();
113 m_useDefault =
false;
114 m_itMapCurrent = range.first;
115 m_itMapEnd = range.second;
119bool ChannelRouteIterator::End()
const
121 return m_useDefault ? m_itListCurrent == m_itListEnd : m_itMapCurrent == m_itMapEnd;
124void ChannelRouteIterator::Next()
134 return m_useDefault ? *m_itListCurrent->first : *m_itMapCurrent->second.first;
137const std::string & ChannelRouteIterator::Channel()
140 return m_itListCurrent->second.get() ? *m_itListCurrent->second.get() : m_channel;
142 return m_itMapCurrent->second.second;
163 if (m_it.Destination().
ChannelPut2(m_it.Channel(), begin, length, messageEnd, blocking))
175void ChannelSwitch::IsolatedInitialize(
const NameValuePairs& parameters)
177 CRYPTOPP_UNUSED(parameters);
179 m_defaultRoutes.clear();
196 if (m_it.Destination().
ChannelFlush(m_it.Channel(), completeFlush, propagation, blocking))
208bool ChannelSwitch::ChannelMessageSeriesEnd(
const std::string &channel,
int propagation,
bool blocking)
210 CRYPTOPP_UNUSED(blocking);
234byte * ChannelSwitch::ChannelCreatePutSpace(
const std::string &channel,
size_t &size)
240 const std::string &ch = m_it.Channel();
249size_t ChannelSwitch::ChannelPutModifiable2(
const std::string &channel,
byte *inString,
size_t length,
int messageEnd,
bool blocking)
257 const std::string &targetChannel = it.Channel();
263 return ChannelPut2(channel, inString, length, messageEnd, blocking);
273 for (DefaultRouteList::iterator it = m_defaultRoutes.begin(); it != m_defaultRoutes.end(); ++it)
274 if (it->first == &destination && !it->second.get())
276 m_defaultRoutes.erase(it);
283 m_defaultRoutes.push_back(DefaultRoute(&destination, outChannel));
288 for (DefaultRouteList::iterator it = m_defaultRoutes.begin(); it != m_defaultRoutes.end(); ++it)
289 if (it->first == &destination && (it->second.get() && *it->second == outChannel))
291 m_defaultRoutes.erase(it);
296void ChannelSwitch::AddRoute(
const std::string &inChannel,
BufferedTransformation &destination,
const std::string &outChannel)
298 m_routeMap.insert(RouteMap::value_type(inChannel, Route(&destination, outChannel)));
301void ChannelSwitch::RemoveRoute(
const std::string &inChannel,
BufferedTransformation &destination,
const std::string &outChannel)
303 typedef ChannelSwitch::RouteMap::iterator MapIterator;
304 std::pair<MapIterator, MapIterator> range = m_routeMap.equal_range(inChannel);
306 for (MapIterator it = range.first; it != range.second; ++it)
307 if (it->second.first == &destination && it->second.second == outChannel)
309 m_routeMap.erase(it);
Classes for multiple named channels.
size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing on a channel.
bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output on a channel.
Interface for retrieving values given their names.
Abstract base classes that provide a uniform interface to this library.