blob: cebb3bc4b2048ce2707d2b4f7ebed998cef5af54 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#pragma once
namespace saw {
/**
* ID class which is tied to it's representing class
*/
template<typename T>
class id {
private:
/**
* Alias for the value type representing the ID
*/
using type = uint64_t;
/**
* The low level value
*/
type value_;
public:
/**
* Basic constructor for the id class
*/
id(type val):
value_{val}
{}
SAW_DEFAULT_COPY(id);
SAW_DEFAULT_MOVE(id);
/**
* Equal operator for the id.
* Returns true if equal, false otherwise.
*/
bool operator==(const id<T>& rhs) const {
return value_ == rhs.value_;
}
/**
* Unequal operator for the id.
* Returns false if equal, true otherwise.
*/
bool operator!=(const id<T>& rhs) const {
return !(*this == rhs);
}
/**
* Returns a const ref of the underlying base type.
* Mostly used for internal purposes.
*/
const type& get_value() const {
return value_;
}
};
/**
* @experimental
* Container for a class which has relations to the provided id classes.
* Meant as an idea for a generic class which uses this
*/
template<typename T, typename... Ids>
class obj_owns_ids {
private:
std::tuple<Ids...> children_;
T obj_;
public:
obj_owns_ids(T obj, Ids... children):
obj_{std::move(obj)},
children_{std::move(children)}
{}
};
}
|