5 #ifndef CRYPTOPP_IMPORTS
9 NAMESPACE_BEGIN(CryptoPP)
15 m_defaultRoutes.push_back(Route(&destination, channel));
18 void MessageSwitch::AddRoute(
unsigned int begin,
unsigned int end,
BufferedTransformation &destination,
const std::string &channel)
20 RangeRoute route(begin, end, Route(&destination, channel));
21 RouteList::iterator it = upper_bound(m_routes.begin(), m_routes.end(), route);
22 m_routes.insert(it, route);
96 void ChannelRouteIterator::Reset(
const std::string &channel)
99 pair<MapIterator, MapIterator> range = m_cs.m_routeMap.equal_range(channel);
100 if (range.first == range.second)
103 m_itListCurrent = m_cs.m_defaultRoutes.begin();
104 m_itListEnd = m_cs.m_defaultRoutes.end();
108 m_useDefault =
false;
109 m_itMapCurrent = range.first;
110 m_itMapEnd = range.second;
114 bool ChannelRouteIterator::End()
const
116 return m_useDefault ? m_itListCurrent == m_itListEnd : m_itMapCurrent == m_itMapEnd;
119 void ChannelRouteIterator::Next()
129 return m_useDefault ? *m_itListCurrent->first : *m_itMapCurrent->second.first;
132 const std::string & ChannelRouteIterator::Channel()
135 return m_itListCurrent->second.get() ? *m_itListCurrent->second.get() : m_channel;
137 return m_itMapCurrent->second.second;
145 size_t ChannelSwitch::ChannelPut2(
const std::string &channel,
const byte *begin,
size_t length,
int messageEnd,
bool blocking)
158 if (m_it.Destination().ChannelPut2(m_it.Channel(), begin, length, messageEnd, blocking))
170 void ChannelSwitch::IsolatedInitialize(
const NameValuePairs ¶meters)
173 m_defaultRoutes.clear();
177 bool ChannelSwitch::ChannelFlush(
const std::string &channel,
bool completeFlush,
int propagation,
bool blocking)
190 if (m_it.Destination().ChannelFlush(m_it.Channel(), completeFlush, propagation, blocking))
202 bool ChannelSwitch::ChannelMessageSeriesEnd(
const std::string &channel,
int propagation,
bool blocking)
215 if (m_it.Destination().ChannelMessageSeriesEnd(m_it.Channel(), propagation))
227 byte * ChannelSwitch::ChannelCreatePutSpace(
const std::string &channel,
size_t &size)
233 const std::string &channel = m_it.Channel();
236 return target.ChannelCreatePutSpace(channel, size);
242 size_t ChannelSwitch::ChannelPutModifiable2(
const std::string &channel, byte *inString,
size_t length,
int messageEnd,
bool blocking)
250 const std::string &targetChannel = it.Channel();
253 return target.ChannelPutModifiable2(targetChannel, inString, length, messageEnd, blocking);
256 return ChannelPut2(channel, inString, length, messageEnd, blocking);
266 for (DefaultRouteList::iterator it = m_defaultRoutes.begin(); it != m_defaultRoutes.end(); ++it)
267 if (it->first == &destination && !it->second.get())
269 m_defaultRoutes.erase(it);
276 m_defaultRoutes.push_back(DefaultRoute(&destination, outChannel));
279 void ChannelSwitch::RemoveDefaultRoute(
BufferedTransformation &destination,
const std::string &outChannel)
281 for (DefaultRouteList::iterator it = m_defaultRoutes.begin(); it != m_defaultRoutes.end(); ++it)
282 if (it->first == &destination && (it->second.get() && *it->second == outChannel))
284 m_defaultRoutes.erase(it);
289 void ChannelSwitch::AddRoute(
const std::string &inChannel,
BufferedTransformation &destination,
const std::string &outChannel)
291 m_routeMap.insert(RouteMap::value_type(inChannel, Route(&destination, outChannel)));
294 void ChannelSwitch::RemoveRoute(
const std::string &inChannel,
BufferedTransformation &destination,
const std::string &outChannel)
296 typedef ChannelSwitch::RouteMap::iterator MapIterator;
297 pair<MapIterator, MapIterator> range = m_routeMap.equal_range(inChannel);
299 for (MapIterator it = range.first; it != range.second; ++it)
300 if (it->second.first == &destination && it->second.second == outChannel)
302 m_routeMap.erase(it);
interface for retrieving values given their names