00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-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 /*---------------------------------------------------------------------------*\ 00014 * License * 00015 * * 00016 * This library is free software; you can redistribute it and/or modify it * 00017 * under the terms of the GNU Library General Public License as published * 00018 * by the Free Software Foundation, version 2. * 00019 * * 00020 * This library is distributed in the hope that it will be useful, but * 00021 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00023 * Library General Public License for more details. * 00024 * * 00025 * You should have received a copy of the GNU Library General Public * 00026 * License along with this library; if not, write to the Free Software * 00027 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00028 * * 00029 \*---------------------------------------------------------------------------*/ 00030 00031 /*---------------------------------------------------------------------------*\ 00032 * Changes * 00033 * * 00034 * * 00035 * * 00036 * * 00037 * * 00038 * * 00039 \*---------------------------------------------------------------------------*/ 00040 OSG_BEGIN_NAMESPACE 00041 00042 /*-------------------------------------------------------------------------*/ 00043 inline UInt32 StatCollector::getNumOfElems(void) const 00044 { 00045 return _elemVec.size(); 00046 } 00047 00048 /*-------------------------------------------------------------------------*/ 00049 inline bool StatCollector::isValidID(Int32 elemId) const 00050 { 00051 return (elemId >= 0) && (elemId < Int32(_elemVec.size())); 00052 } 00053 00054 /*-------------------------------------------------------------------------*/ 00055 00065 inline StatElem *StatCollector::getElem(Int32 elemId, bool create) 00066 { 00067 if(create) 00068 { 00069 // This only happens when dynamically adding StatElems 00070 // but it's really nasty if it happens. 00071 if(elemId >= int(_elemVec.size())) 00072 refitElemNum(); 00073 00074 StatElem *elem = _elemVec[elemId]; 00075 if(elem == NULL) 00076 { 00077 StatElemDescBase *desc = StatElemDescBase::getDesc(elemId); 00078 elem = _elemVec[elemId] = desc->createElem(); 00079 } 00080 return elem; 00081 } 00082 00083 return isValidID(elemId) ? _elemVec[elemId] : NULL; 00084 } 00085 00090 inline StatElem *StatCollector::getElem(Int32 elemId) const 00091 { 00092 return isValidID(elemId) ? _elemVec[elemId] : NULL; 00093 } 00094 00095 /*-------------------------------------------------------------------------*/ 00096 inline StatElem *StatCollector::getElem(StatElemDescBase &desc, bool create) 00097 { 00098 return getElem(desc.getID(), create); 00099 } 00100 00101 /*-------------------------------------------------------------------------*/ 00102 template<class T> 00103 inline T *StatCollector::getElem(StatElemDesc<T> &desc, bool create) 00104 { 00105 return reinterpret_cast < T * > (getElem(desc.getID(), create)); 00106 } 00107 00108 OSG_END_NAMESPACE 00109 #define OSGSTATCOLLECTOR_INLINE_CVSID \ 00110 "@(#)$Id: OSGStatCollector.inl,v 1.6 2002/01/24 22:55:05 dirk Exp $"
1.5.5