00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software 00003 // Foundation, Inc 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 // Smart (ref-counting) pointer classes. Uses "intrusive" approach: 00020 // the types pointed to must have add_ref() and drop_ref() methods. 00021 // Typically this is done by inheriting from a ref_counted class, 00022 // although the nice thing about templates is that no particular 00023 // ref-counted class is mandated. 00024 00025 00026 #ifndef SMART_PTR_H 00027 #define SMART_PTR_H 00028 00029 #include "ref_counted.h" 00030 #include <typeinfo> 00031 00032 // TODO: drop all users of this macro, we _are_ using GC now 00033 #define GNASH_USE_GC 1 00034 00035 namespace gnash { 00036 class GcResource; 00037 } 00038 00039 00040 #define COMPILER_SUPPORTS_ARGUMENT_DEPENDENT_LOOKUP 1 00041 #ifdef COMPILER_SUPPORTS_ARGUMENT_DEPENDENT_LOOKUP 00042 namespace gnash { 00043 #else 00044 namespace boost { 00045 #endif 00046 00047 inline void 00048 intrusive_ptr_add_ref(const ref_counted* o) 00049 { 00050 o->add_ref(); 00051 } 00052 00053 inline void 00054 intrusive_ptr_release(const ref_counted* o) 00055 { 00056 o->drop_ref(); 00057 } 00058 00059 // These two should not be needed when we switch all GcResource 00060 // pointers to use the gc_ptr instead of the intrusive_ptr 00061 00062 inline void intrusive_ptr_add_ref(const GcResource* ) { } 00063 inline void intrusive_ptr_release(const GcResource* ) { } 00064 00065 } // namespace boost||gnash 00066 00067 00068 #endif // SMART_PTR_H 00069 00070 00071 // Local Variables: 00072 // mode: C++ 00073 // c-basic-offset: 8 00074 // tab-width: 8 00075 // indent-tabs-mode: t 00076 // End: