-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_main.cpp
88 lines (51 loc) · 2.01 KB
/
entity_main.cpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/random/mersenne_twister.hpp>
#include "entity.h"
#include "entity_custom.h"
#include "entity_member1.h"
#include "entity_member3.h"
int main2() {
entity_store es;
auto a = es.create();
return 0;
}
int main() {
// boost::uuids::random_generator uuid_generator;
// auto a(std::make_shared<entity>( uuid_generator() ));
// auto c(std::make_shared<entity>());
//std::shared_ptr<entity> a(std::make_shared<entity>());
entity_store es;
entity_ptr::global_store = &es;
auto a = es.create();
entity_ptr ap( a->id() );
auto ax = ap.lock();
// std::shared_ptr<entity> xp(es.create());
// std::weak_ptr<entity> wp( xp );
// std::cout << (wp.lock() == nullptr) << "\n";
a->add_member( make_unique<member_type1>() );
//a.add_member<ID_TYPE2>( std::make_shared<member_type2>() );
ap.lock()->make_member<member_type2>( 7, 8 );
// auto b = std::make_shared<entity>(uuid_generator());
auto b = es.create();
// a.add_member<ID_TYPE1>( std::make_shared<member_type1>() );
//b.add_member<ID_TYPE3>( std::make_shared<member_type3>() );
b->fabricate_members( {ID_TYPE1, ID_TYPE3} );
// b.add_member_unchecked( ID_TYPE3, std::make_shared<member_type2>() );
auto &x = a->member<ID_TYPE1>();
member_type2 &y = a->member<member_type2>();
//member_interaction<ID_TYPE1,ID_TYPE2>( a, a );
member_interaction<ID_TYPE1,ID_TYPE3>( *a, *b );
std::cout << &x << " " << &y << "\n";
// entity xxx[1024];
// std::cout << "size: " << sizeof( xxx ) << "\n";
a->add_interaction( ID_TYPE1, a, ID_TYPE2 );
a->add_interaction( ID_TYPE1, b, ID_TYPE3 );
a->run_interactions();
a->run_interactions();
b.reset();
a->run_interactions();
a->print_info();
return 0;
}