blob: a3962356b7746f39a393405dee101cf1afde71b6 (
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
|
/*
* Multiindex container for selection
*
* Authors:
* Adrian Boguszewski
*
* Copyright (C) 2016 Adrian Boguszewski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifndef INKSCAPE_PROTOTYPE_OBJECTSET_H
#define INKSCAPE_PROTOTYPE_OBJECTSET_H
#include "object.h"
#include <string>
#include <unordered_map>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <sigc++/connection.h>
struct hashed{};
typedef boost::multi_index_container<
Object*,
boost::multi_index::indexed_by<
boost::multi_index::sequenced<>,
boost::multi_index::hashed_unique<
boost::multi_index::tag<hashed>,
boost::multi_index::identity<Object*>>
>> multi_index_container;
class ObjectSet {
public:
ObjectSet() {};
~ObjectSet();
bool add(Object* object);
bool remove(Object* object);
bool contains(Object* object);
void clear();
int size();
private:
void _add(Object* object);
void _remove(Object* object);
bool _anyAncestorIsInSet(Object *object);
void _removeDescendantsFromSet(Object *object);
void _removeAncestorsFromSet(Object *object);
Object *_getMutualAncestor(Object *object);
multi_index_container container;
std::unordered_map<Object*, sigc::connection> releaseConnections;
};
#endif //INKSCAPE_PROTOTYPE_OBJECTSET_H
|