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) 00044 { 00045 return _elemVec.size(); 00046 } 00047 00048 /*-------------------------------------------------------------------------*/ 00049 inline bool StatCollector::isValidID(Int32 id) 00050 { 00051 return (id >= 0) && (id < Int32(_elemVec.size())); 00052 } 00053 00054 /*-------------------------------------------------------------------------*/ 00055 00065 inline StatElem *StatCollector::getElem(Int32 id, 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(id >= int(_elemVec.size())) 00072 refitElemNum(); 00073 00074 StatElem *elem = _elemVec[id]; 00075 if(elem == NULL) 00076 { 00077 StatElemDescBase *desc = StatElemDescBase::getDesc(id); 00078 elem = _elemVec[id] = desc->createElem(); 00079 } 00080 return elem; 00081 } 00082 00083 return _elemVec[id]; 00084 } 00085 00086 /*-------------------------------------------------------------------------*/ 00087 inline StatElem *StatCollector::getElem(StatElemDescBase &desc, bool create) 00088 { 00089 return getElem(desc.getID(), create); 00090 } 00091 00092 /*-------------------------------------------------------------------------*/ 00093 template<class T> 00094 inline T *StatCollector::getElem(StatElemDesc<T> &desc, bool create) 00095 { 00096 return reinterpret_cast < T * > (getElem(desc.getID(), create)); 00097 } 00098 00099 OSG_END_NAMESPACE 00100 #define OSGSTATCOLLECTOR_INLINE_CVSID \ 00101 "@(#)$Id: OSGStatCollector.inl,v 1.6 2002/01/24 22:55:05 dirk Exp $"
1.4.3