blob: 3bd16090c13b4d7e3752a1e4e800fe50d40acbc4 (
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
|
#pragma once
#include "common.hpp"
#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;
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>
value<T>* vget(concept* type) const { return static_cast<value<T>*>(get(type)); }
template <typename T>
value<T>* val() { return this; }
};
}
}
|