-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotation.hpp
More file actions
39 lines (29 loc) · 1.3 KB
/
Copy pathannotation.hpp
File metadata and controls
39 lines (29 loc) · 1.3 KB
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
#ifndef ANNOTATION_HEADER
#define ANNOTATION_HEADER
#include <typeindex>
#include <unordered_set>
#include <unordered_map>
#include "base_class.hpp"
class annotation : public base_class {};
using annotation_wrapper = clone_wrapper<annotation>;
class annotatable {
protected:
using specific_annotations_type = std::unordered_multiset<annotation_wrapper>;
using const_specific_annotations_iterator = typename specific_annotations_type::const_iterator;
using annotations_type = std::unordered_map<std::type_index, specific_annotations_type>;
using annotations_iterator = typename annotations_type::iterator;
using const_annotations_iterator = typename annotations_type::const_iterator;
static const specific_annotations_type
no_specific_annotations;
// Annotation changes are considered semantically const.
mutable annotations_type annotations;
public:
virtual ~annotatable() {}
bool has_annotation(const ::annotation&annotation) const;
const annotation*get_annotation(const ::annotation&annotation) const;
// Annotation changes are considered semantically const.
virtual void add_annotation(const ::annotation&annotation) const;
virtual void remove_annotation(const ::annotation&annotation) const;
const specific_annotations_type&get_annotations(std::type_index type) const;
};
#endif