29 : _type((size_t)HANDSHAKE_INVALID), _lifetime(0)
34 : _type((size_t)type), _lifetime(lifetime)
43 void NodeHandshake::clear()
45 for (item_set::const_iterator iter = _items.begin(); iter != _items.end(); ++iter)
56 _requests.insert(identifier);
61 return (_requests.find(identifier) != _requests.end());
66 _items.push_back(item);
71 for (item_set::const_iterator iter = _items.begin(); iter != _items.end(); ++iter)
82 for (item_set::const_iterator iter = _items.begin(); iter != _items.end(); ++iter)
103 std::stringstream ss;
107 ss <<
"HANDSHAKE_INVALID";
111 ss <<
"HANDSHAKE_REQUEST";
115 ss <<
"HANDSHAKE_RESPONSE";
127 for (request_set::const_iterator iter = _requests.begin(); iter != _requests.end(); ++iter)
135 for (item_set::const_iterator iter = _items.begin(); iter != _items.end(); ++iter)
156 stream << number_of_items;
158 for (NodeHandshake::request_set::const_iterator iter = hs._requests.begin(); iter != hs._requests.end(); ++iter)
167 stream << hs._lifetime;
171 stream << number_of_items;
173 for (NodeHandshake::item_set::const_iterator iter = hs._items.begin(); iter != hs._items.end(); ++iter)
204 stream >> number_of_items;
206 for (
size_t i = 0; number_of_items > i; ++i)
210 hs._requests.insert(req);
216 stream >> hs._lifetime;
220 stream >> number_of_items;
222 for (
size_t i = 0; number_of_items > i; ++i)
234 std::stringstream &data = hs._raw_items.get(
id);
244 NodeHandshake::StreamMap::StreamMap()
248 NodeHandshake::StreamMap::~StreamMap()
255 stream_map::iterator i = _map.find(identifier);
256 return (i != _map.end());
259 std::stringstream& NodeHandshake::StreamMap::get(
const dtn::data::Number &identifier)
261 stream_map::iterator i = _map.find(identifier);
265 std::pair<stream_map::iterator, bool> p =
266 _map.insert(std::pair<dtn::data::Number, std::stringstream* >(identifier,
new stringstream()));
270 return (*(*i).second);
275 stream_map::iterator i = _map.find(identifier);
280 _map.erase(identifier);
284 void NodeHandshake::StreamMap::clear()
286 for (stream_map::iterator iter = _map.begin(); iter != _map.end(); ++iter)
288 delete (*iter).second;