drawablewatcher.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PAPYRUSDRAWABLEWATCHER_H
00021 #define PAPYRUSDRAWABLEWATCHER_H
00022
00023 #include <set>
00024 #include <papyrus/drawable.h>
00025 #include <papyrus/drawableset.h>
00026
00027 namespace Papyrus
00028 {
00029
00048 class DrawableWatcher
00049 {
00050 public:
00051
00052 typedef PapyrusPointer<DrawableWatcher> pointer;
00053
00054 typedef std::set<Drawable::weak_pointer, wp_lt_compare> Watched;
00055
00056 DrawableWatcher ( );
00057
00058 virtual ~DrawableWatcher();
00059
00063 virtual bool watch ( Drawable::pointer item );
00064
00068 virtual bool remove_watch ( Drawable::pointer item );
00069
00073 virtual void remove_all_watches();
00074
00076 const Watched& watched() const;
00077
00079 bool is_watched ( Drawable::pointer item );
00080
00085 virtual void link( DrawableSet::pointer s );
00086
00088 virtual void unlink( DrawableSet::pointer s );
00089
00091 sigc::signal<void, Drawable::pointer>& signal_watch_added();
00092
00094 sigc::signal<void, Drawable::pointer>& signal_watch_removed();
00095
00097 sigc::signal<void, Drawable::pointer>& signal_watched_changed();
00098
00099 protected:
00100
00102 Watched m_watched;
00103
00105 typedef std::map<Drawable::weak_pointer, sigc::connection, wp_lt_compare> Connections;
00106 Connections m_watched_changed_connections;
00107 Connections m_watched_destroyed_connections;
00108
00109 std::map< DrawableSet::pointer, sigc::connection > m_linked_added_conn_map;
00110 std::map< DrawableSet::pointer, sigc::connection > m_linked_removed_conn_map;
00111
00112 sigc::signal<void, Drawable::pointer> m_signal_watch_added;
00113 sigc::signal<void, Drawable::pointer> m_signal_watch_removed;
00114 sigc::signal<void, Drawable::pointer> m_signal_watched_changed;
00115
00124 virtual void on_watched_changed ( Drawable::pointer watched );
00125
00126 private:
00127
00132 void on_watched_changed_proxy( Drawable::weak_pointer watched );
00133
00138 void on_watched_destroyed( Drawable::weak_pointer watched );
00139
00140 void on_linked_set_drawable_added( Drawable::pointer added );
00141
00142 void on_linked_set_drawable_removed( Drawable::pointer removed );
00143
00144 };
00145
00146 }
00147
00148 #endif