diff options
Diffstat (limited to 'src/object.h')
| -rw-r--r-- | src/object.h | 76 |
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 |
