summaryrefslogtreecommitdiffstats
path: root/src/object.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.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.h')
-rw-r--r--src/object.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/object.h b/src/object.h
new file mode 100644
index 000000000..a5ad5692e
--- /dev/null
+++ b/src/object.h
@@ -0,0 +1,76 @@
+/*
+ * Temporary file
+ *
+ * Authors:
+ * Adrian Boguszewski
+ *
+ * Copyright (C) 2016 Adrian Boguszewski
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef INKSCAPE_PROTOTYPE_OBJECT_H
+#define INKSCAPE_PROTOTYPE_OBJECT_H
+
+#include <string>
+#include <sigc++/signal.h>
+#include <sigc++/connection.h>
+#include <boost/intrusive/list.hpp>
+
+// this causes some warning, but it's only for this prototype
+class Object;
+struct delete_disposer
+{
+ void operator()(Object *delete_this) {
+ delete delete_this;
+ }
+};
+
+class Object {
+private:
+ std::string name;
+ Object* parent;
+
+ typedef boost::intrusive::list_member_hook<
+ boost::intrusive::link_mode<
+ boost::intrusive::auto_unlink
+ >> list_hook;
+ list_hook child_hook;
+
+ typedef boost::intrusive::list<
+ Object,
+ boost::intrusive::constant_time_size<false>,
+ boost::intrusive::member_hook<
+ Object,
+ list_hook,
+ &Object::child_hook
+ >> list;
+ list children;
+
+ sigc::signal<bool, Object*> release_signal;
+
+public:
+ Object(std::string name);
+ virtual ~Object();
+
+ list &getChildren() {
+ return children;
+ }
+
+ const std::string &getName() const;
+ Object * getParent() ;
+
+ sigc::connection connectRelease(sigc::slot<bool, Object*> slot);
+ void addChild(Object* o);
+ bool isDescendantOf(Object* o);
+
+ bool operator==(Object o) {
+ return name == o.name;
+ }
+
+ bool operator!=(Object o) {
+ return name != o.name;
+ }
+};
+
+#endif //INKSCAPE_PROTOTYPE_OBJECT_H