PageRenderTime 25ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Core_Serialization/Stream.cpp

http://github.com/Akranar/daguerreo
C++ | 44 lines | 35 code | 9 blank | 0 comment | 4 complexity | 3df2dff7a517086dabaf8a21ed1e01d0 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
 1#include "Stream.h"
 2#include <Core_Assert.h>
 3
 4
 5
 6Stream & Stream::operator << (const Serializable * val)
 7{
 8	Save(val);
 9	return *this;
10}
11
12
13
14bool Stream::ShouldSerialize(const Serializable * val_address)
15{
16	if (!val_address) return false;
17
18	std::pair<std::set<const Serializable *>::iterator, bool> result = serialized_pointed_objects.insert(val_address);
19	return result.second;
20}
21
22bool Stream::ShouldUnserialize(const Serializable * old_address, Serializable *& rtn_new_address)
23{
24	if (!old_address)
25	{
26		rtn_new_address = 0;
27		return false;
28	}
29	std::map<const Serializable *, Serializable *>::iterator result = old_map_new.find(old_address);
30	if (result != old_map_new.end())
31	{
32		rtn_new_address = result->second;
33		return false;
34	}
35	else
36	{
37		return true;
38	}
39}
40
41void Stream::SetOldToNew(const Serializable * old_address, Serializable * new_address)
42{
43	old_map_new[old_address] = new_address;
44}