Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGFieldContainerPtrDepImpl.inl

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *           Copyright (C) 2000-2002,2002 by the OpenSG Forum                *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGFIELDCONTAINERPTRDEPIMPL_INL_
00040 #define _OSGFIELDCONTAINERPTRDEPIMPL_INL_
00041 
00042 #ifdef OSG_DOC_FILES_IN_MODULE
00043 
00046 #endif
00047 
00048 OSG_BEGIN_NAMESPACE
00049 
00050 template <class BasePtrTypeT, class FieldContainerTypeT> inline
00051 std::ostream &operator <<(
00052           std::ostream                             &os,
00053     const FCPtr<BasePtrTypeT, FieldContainerTypeT> &fc)
00054 {
00055     if(fc == NullFC)
00056     {
00057         os << std::hex << "FCPtr 0x" << &fc << std::dec << ":NullFC";
00058     }
00059     else
00060     {
00061         os << std::hex 
00062            << "FCPtr 0x"
00063            << &fc 
00064            << std::dec 
00065            << ":" 
00066            << fc->getType().getName() 
00067            << "Ptr(0x"
00068            << std::hex 
00069            << (&(*fc)) 
00070            << std::dec 
00071            << ")";
00072     }
00073 
00074     return os;
00075 }
00076 
00077 inline
00078 void FieldContainerPtrBase::deleteContainers(void) const
00079 {
00080 //    dump(0, FCDumpFlags::RefCount);
00081 
00082     Thread::getCurrentChangeList()->addDestroyed(*getIdP());
00083     
00084     if (FieldContainerFactory::the()->unregisterFieldContainer(
00085             *((const FieldContainerPtr *) this)))
00086     {
00087         return;
00088     }
00089     
00090     UInt8 *pTmp = getFirstElemP();
00091     
00092     ((FieldContainer *) pTmp)->onDestroy();
00093     
00094 #if defined(OSG_GV_BETA) && defined(OSG_DBG_MEM)
00095 
00096     fprintf(stderr, "GV_MEM_FC_DBG : (%u) d (%p|%u)\n", 
00097             Thread::getAspect(),
00098             pTmp,
00099 //            ((FieldContainer *) pTmp)->getType().getCName(),
00100             ((FieldContainer *) pTmp)->getType().getId());
00101 #endif
00102     
00103     for(UInt32 i = 0; i < ThreadManager::getNumAspects(); i++)
00104     {
00105 #if defined(OSG_FIXED_MFIELDSYNC)
00106         ((FieldContainer *) pTmp)->onDestroyAspect(*(getIdP()), i);
00107 #endif
00108 
00109         ((FieldContainer *) pTmp)->~FieldContainer();
00110         
00111         pTmp += _containerSize;
00112     }
00113     
00114     operator delete(_storeP + getRefCountOff());
00115 }
00116 
00117 inline
00118 void FieldContainerPtrBase::subRef(void) const
00119 {
00120     _pRefCountLock->aquire(_storeP);
00121 
00122     (*getRefCountP())--;
00123 
00124     if((*getRefCountP()) <= 0)
00125     {
00126         _pRefCountLock->release(_storeP);
00127 
00128         deleteContainers();
00129         
00130          // Clean up a little.
00131         const_cast<FieldContainerPtrBase*>(this)->_storeP = NULL;
00132     }
00133     else
00134     {
00135         _pRefCountLock->release(_storeP);
00136 
00137         Thread::getCurrentChangeList()->addSubRefd(
00138             *(static_cast<const FieldContainerPtr *>(this)));
00139     }
00140 }
00141 
00142 OSG_END_NAMESPACE
00143 
00144 #define OSGFIELDCONTAINERPTRDEPIMPL_INLINE_CVSID "@(#)$Id: $"
00145 
00146 #endif /* _OSGFIELDCONTAINERPTRDEPIMPL_INL_ */

Generated on Thu Aug 25 04:04:46 2005 for OpenSG by  doxygen 1.4.3