feat: add Boost serialization support for SmartPointer and include standard smart pointer headers
This commit is contained in:
@@ -172,6 +172,26 @@ ULIB_SERIALIZE_OBJECT(B, Object) {
|
||||
|
||||
|
||||
|
||||
class C : public virtual Object {
|
||||
uLibTypeMacro(C, Object)
|
||||
ULIB_SERIALIZE_ACCESS
|
||||
|
||||
public:
|
||||
C() : m_c(1234566) {}
|
||||
|
||||
int m_c;
|
||||
|
||||
// reference to A (serializes through ID)
|
||||
SmartPointer<A> m_a;
|
||||
};
|
||||
|
||||
ULIB_SERIALIZABLE_OBJECT(C)
|
||||
ULIB_SERIALIZE_OBJECT(C, Object) {
|
||||
ar & "Object C : " & "--> m_c = " & AR(m_c) & "--> m_a = " & AR(m_a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int test_referece_serialization() {
|
||||
A a;
|
||||
{
|
||||
@@ -193,7 +213,25 @@ int test_referece_serialization() {
|
||||
return (b.m_a->a() == a.a() && b2.m_a->a() == a.a());
|
||||
}
|
||||
|
||||
int test_referece_smartpointer_serialization() {
|
||||
SmartPointer<A> a;
|
||||
a->init_properties();
|
||||
{
|
||||
C c, c2; c.m_a = a; c2.m_a = a;
|
||||
|
||||
std::ofstream file("test_ref_smartpointer.xml");
|
||||
Archive::xml_oarchive(file) << NVP(c) << NVP(c2);
|
||||
}
|
||||
|
||||
|
||||
C c, c2;
|
||||
{
|
||||
std::ifstream file("test_ref_smartpointer.xml");
|
||||
Archive::xml_iarchive(file) >> NVP(c) >> NVP(c2);
|
||||
}
|
||||
|
||||
return (c.m_a->a() == a->a() && c2.m_a->a() == a->a());
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
@@ -202,6 +240,7 @@ int main() {
|
||||
TEST1(test_V3f());
|
||||
TEST1(testing_xml_class());
|
||||
TEST1(test_referece_serialization());
|
||||
TEST1(test_referece_smartpointer_serialization());
|
||||
// TEST1(testing_hrt_class());
|
||||
|
||||
END_TESTING;
|
||||
|
||||
Reference in New Issue
Block a user