blob: d57ccfc2b3b04aaee41de43d9adce2a013664e54 (
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
|
#pragma once
#include "common.hpp"
#include <any>
#include <map>
#include <vector>
namespace intellect {
namespace level0 {
struct concept
{
// a concept is made of concept-typed links to other concepts
std::multimap<concept*,concept*> links;
// and optional associated arbitrary data
std::any data;
using array = std::vector<concept*>;
concept* id();
void link(concept* type, concept* target);
void unlink(concept* type, concept* target);
void unlink(concept* type);
bool linked(concept* type) const;
bool linked(concept* type, concept* target) const;
array getAll(concept* type) const;
// get and set enforce that only 1 link of a given type is present
concept* get(concept* type) const;
void set(concept* type, concept* target);
template <typename T>
T & vget(concept* type) const { return get(type)->val<T>(); }
template <typename T>
T & val() { return std::any_cast<T&>(data); }
};
}
}
|