papyrus logo

drawablewatcher.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2009 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
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

Generated on Fri Apr 16 12:40:10 2010 for papyrus by doxygen 1.6.1