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 * 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 * This library is distributed in the hope that it will be useful, but * 00019 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Library General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Library General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00026 * * 00027 \*---------------------------------------------------------------------------*/ 00028 /*---------------------------------------------------------------------------*\ 00029 * Changes * 00030 * * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 \*---------------------------------------------------------------------------*/ 00037 00038 //--------------------------------------------------------------------------- 00039 // Includes 00040 //--------------------------------------------------------------------------- 00041 00042 #include <stdlib.h> 00043 #include <stdio.h> 00044 00045 #include "OSGConfig.h" 00046 00047 #include "OSGStatElemDesc.h" 00048 00049 #include "OSGLog.h" 00050 00051 OSG_USING_NAMESPACE 00052 00053 /***************************************************************************\ 00054 * Types * 00055 \***************************************************************************/ 00056 00057 /***************************************************************************\ 00058 * Class variables * 00059 \***************************************************************************/ 00060 00061 std::vector<StatElemDescBase*> *StatElemDescBase::_descVec = 0; 00062 00063 char StatElemDescBase::cvsid[] = "@(#)$Id: $"; 00064 00065 /***************************************************************************\ 00066 * Class methods * 00067 \***************************************************************************/ 00068 00069 00070 00071 /*-------------------------------------------------------------------------*\ 00072 - public - 00073 \*-------------------------------------------------------------------------*/ 00074 StatElemDescBase *StatElemDescBase::findDescByName (const Char8 *name) 00075 { 00076 Int32 i,n = _descVec ? _descVec->size() : 0; 00077 StatElemDescBase *desc = 0; 00078 00079 if (name && *name && n) 00080 for (i = 0; i < n; i++) 00081 if (!strcmp(name,(*_descVec)[i]->_name.str())) { 00082 desc = (*_descVec)[i]; 00083 break; 00084 } 00085 00086 return desc; 00087 } 00088 00089 /*-------------------------------------------------------------------------*\ 00090 - protected - 00091 \*-------------------------------------------------------------------------*/ 00092 00093 00094 /*-------------------------------------------------------------------------*\ 00095 - private - 00096 \*-------------------------------------------------------------------------*/ 00097 00098 00099 00100 /***************************************************************************\ 00101 * Instance methods * 00102 \***************************************************************************/ 00103 00104 /*-------------------------------------------------------------------------*\ 00105 - public - 00106 \*-------------------------------------------------------------------------*/ 00107 00108 /*------------- constructors & destructors --------------------------------*/ 00109 00112 StatElemDescBase::StatElemDescBase(const Char8 *name, const Char8 *description) 00113 :_id(-1), _name(name), _description(description) 00114 { 00115 StatElemDescBase *desc = 0; 00116 00117 if (_descVec) 00118 desc = findDescByName (name); 00119 else 00120 _descVec = new std::vector<StatElemDescBase*>; 00121 00122 if (desc) { 00123 FFATAL (( "Try to register the StatElemDescBase name %s a second time\n", 00124 name )); 00125 } 00126 else { 00127 _id = _descVec->size(); 00128 _descVec->push_back(this); 00129 } 00130 } 00131 00132 //StatElemDescBase::StatElemDescBase(const StatElemDescBase &source) : 00133 // Inherited(source), 00134 // // TODO: initialize members 00135 //{ 00136 //} 00137 00141 StatElemDescBase::~StatElemDescBase(void) 00142 { 00143 } 00144 00145 void StatElemDescBase::printAll(void) 00146 { 00147 Int32 i,n = _descVec ? _descVec->size() : 0; 00148 00149 for (i = 0; i < n; i++) 00150 (*_descVec)[i]->print(); 00151 } 00152 00153 void StatElemDescBase::print(void) 00154 { 00155 FLOG (( "StatElemDescBase: ID/Name/Description: %d/%s/%s\n", 00156 _id, _name.str(), _description.str() )); 00157 } 00158 00159 /*------------------------------ access -----------------------------------*/ 00160 00161 /*---------------------------- properties ---------------------------------*/ 00162 00163 /*-------------------------- your_category---------------------------------*/ 00164 00165 /*-------------------------- assignment -----------------------------------*/ 00166 00170 StatElemDescBase& StatElemDescBase::operator = (const StatElemDescBase &source) 00171 { 00172 if (this == &source) 00173 return *this; 00174 00175 // copy parts inherited from parent 00176 //*(static_cast<Inherited *>(this)) = source; 00177 00178 // free mem alloced by members of 'this' 00179 00180 // alloc new mem for members 00181 00182 // copy 00183 00184 return *this; 00185 } 00186 00187 /*-------------------------- comparison -----------------------------------*/ 00188 00192 bool StatElemDescBase::operator < (const StatElemDescBase &other) const 00193 { 00194 return this < &other; 00195 } 00196 00197 00198 /*-------------------------------------------------------------------------*/ 00199 /* cvs id's */ 00200 00201 #ifdef __sgi 00202 #pragma set woff 1174 00203 #endif 00204 00205 #ifdef OSG_LINUX_ICC 00206 #pragma warning( disable : 177 ) 00207 #endif 00208 00209 namespace 00210 { 00211 static Char8 cvsid_cpp[] = "@(#)$Id: $"; 00212 static Char8 cvsid_hpp[] = OSGSTATELEMDESC_HEADER_CVSID; 00213 static Char8 cvsid_inl[] = OSGSTATELEMDESC_INLINE_CVSID; 00214 }
1.4.3