summaryrefslogtreecommitdiff
path: root/test/testStructures.h
blob: 4eb4764bcf502fbeb531bc340f13154a9bd9d554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include "config/types.h"
#include <persistence.h>

struct AbsObject : public Persistence::Persistable {
	std::string base;

	bool persist(Persistence::PersistenceStore & store) override;

	virtual void dummy() const = 0;
};

struct SubObject : public AbsObject {
	std::string sub;

	bool persist(Persistence::PersistenceStore & store) override;

	void dummy() const override;

	[[nodiscard]] std::string getId() const override;
};

struct SubObject2 : public AbsObject {
	bool persist(Persistence::PersistenceStore & store) override;
	void dummy() const override;
};

struct TestObject : public Persistence::Persistable {
	TestObject() = default;

	float flt {};
	std::string str {};
	bool bl {};
	RelativePosition3D pos {};
	GlobalPosition3D gpos {};
	std::vector<float> flts;
	std::vector<RelativePosition3D> poss;
	std::vector<std::vector<std::vector<std::string>>> nest;
	std::unique_ptr<TestObject> ptr;
	std::unique_ptr<AbsObject> aptr;
	std::vector<std::unique_ptr<TestObject>> vptr;

	unsigned int postLoadCalled {};

	bool persist(Persistence::PersistenceStore & store) override;
	void postLoad() override;
};

struct SharedTestObject : public Persistence::Persistable {
	SharedTestObject() = default;

	std::shared_ptr<AbsObject> sptr;
	std::shared_ptr<SubObject> ssptr;

	bool persist(Persistence::PersistenceStore & store) override;
};