• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

CharacterProxy.h

Go to the documentation of this file.
00001 // CharacterProxy.h - rebindable DisplayObject reference, for Gnash
00002 //
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00004 //   Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program 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 General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef GNASH_CHARACTER_PROXY_H
00021 #define GNASH_CHARACTER_PROXY_H
00022 
00023 #include <string>
00024 
00025 // Forward declarations
00026 namespace gnash {
00027         class DisplayObject;
00028 }
00029 
00030 namespace gnash {
00031 
00033 //
00038 class CharacterProxy {
00039 
00040         mutable DisplayObject* _ptr;
00041 
00042         mutable std::string _tgt;
00043 
00044         static DisplayObject* findDisplayObjectByTarget(const std::string& target);
00045 
00048         void checkDangling() const;
00049 
00050 public:
00051 
00053         CharacterProxy(DisplayObject* sp)
00054                 :
00055                 _ptr(sp)
00056         {
00057                 checkDangling();
00058         }
00059 
00061         //
00070         CharacterProxy(const CharacterProxy& sp)
00071         {
00072                 sp.checkDangling();
00073                 _ptr=sp._ptr;
00074                 if ( ! _ptr ) _tgt=sp._tgt;
00075         }
00076 
00078         //
00087         CharacterProxy& operator=(const CharacterProxy& sp)
00088         {
00089                 sp.checkDangling();
00090                 _ptr=sp._ptr;
00091                 if ( ! _ptr ) _tgt=sp._tgt;
00092                 return *this;
00093         }
00094 
00096         //
00099         DisplayObject* get(bool skipRebinding=false) const
00100         {
00101                 if ( skipRebinding ) return _ptr;
00102 
00103         // set _ptr to NULL and _tgt to original target if destroyed
00104                 checkDangling(); 
00105                 if ( _ptr ) return _ptr;
00106                 else return findDisplayObjectByTarget(_tgt);
00107         }
00108 
00111         std::string getTarget() const;
00112 
00114         //
00120         bool isDangling() const
00121         {
00122                 checkDangling();
00123                 return !_ptr;
00124         }
00125 
00130         bool operator==(const CharacterProxy& sp) const
00131         {
00132                 return get() == sp.get();
00133         }
00134 
00136         //
00140         void setReachable() const;
00141 };
00142 
00143 } // end namespace gnash
00144 
00145 #endif // GNASH_CHARACTER_PROXY_H
00146 

Generated on Thu Sep 30 2010 14:34:56 for Gnash by  doxygen 1.7.1