summaryrefslogtreecommitdiffstats
path: root/src/object-set.h
diff options
context:
space:
mode:
authorAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-06-05 21:20:55 +0000
committerAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-06-05 21:20:55 +0000
commit9abb5e658d005b3ac82afeec13fd59384a8e65eb (patch)
treea6bdcceacd73ff829dd54d891ac7dc3cf70273ee /src/object-set.h
parent[Bug #1545333] Convenience option (default: ON) for cmake builds to enable SV... (diff)
downloadinkscape-9abb5e658d005b3ac82afeec13fd59384a8e65eb.tar.gz
inkscape-9abb5e658d005b3ac82afeec13fd59384a8e65eb.zip
Added object set
(bzr r14954.1.1)
Diffstat (limited to 'src/object-set.h')
-rw-r--r--src/object-set.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/object-set.h b/src/object-set.h
new file mode 100644
index 000000000..a3962356b
--- /dev/null
+++ b/src/object-set.h
@@ -0,0 +1,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