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 * * 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 //--------------------------------------------------------------------------- 00040 // Includes 00041 //--------------------------------------------------------------------------- 00042 00043 #include <stdlib.h> 00044 #include <stdio.h> 00045 00046 #include "OSGConfig.h" 00047 #include "OSGSysFieldDataType.h" 00048 00049 #include "OSGStatIntOnceElem.h" 00050 00051 OSG_USING_NAMESPACE 00052 00053 00054 /***************************************************************************\ 00055 * Description * 00056 \***************************************************************************/ 00057 00066 /***************************************************************************\ 00067 * Instance methods * 00068 \***************************************************************************/ 00069 00070 /*------------- constructors & destructors --------------------------------*/ 00071 00072 StatIntOnceElem::StatIntOnceElem(StatElemDescBase *desc) 00073 : StatElem(desc), 00074 _value(0), 00075 _ids() 00076 { 00077 } 00078 00079 StatElem *StatIntOnceElem::create(StatElemDescBase *desc) 00080 { 00081 return new StatIntOnceElem(desc); 00082 } 00083 00084 00085 StatIntOnceElem::~StatIntOnceElem(void) 00086 { 00087 } 00088 00089 /*------------------------------ access -----------------------------------*/ 00090 00091 void StatIntOnceElem::putToString(std::string &str, const char *format) const 00092 { 00093 if(!format) 00094 { 00095 FieldDataTraits<Int32>::putToString(_value, str); 00096 } 00097 else 00098 { 00099 char *temp = new char [strlen(format) + 40]; 00100 sprintf(temp, format, _value); 00101 str = temp; 00102 delete [] temp; 00103 } 00104 } 00105 00106 bool StatIntOnceElem::getFromString(const Char8 *&inVal) 00107 { 00108 return FieldDataTraits<Int32>::getFromString(_value, inVal); 00109 } 00110 00111 Real64 StatIntOnceElem::getValue(void) const 00112 { 00113 return static_cast<Real64>(get()); 00114 } 00115 00116 void StatIntOnceElem::reset(void) 00117 { 00118 _value = 0; 00119 _ids.clear(); 00120 } 00121 00122 /*-------------------------- assignment -----------------------------------*/ 00123 00124 StatIntOnceElem& StatIntOnceElem::operator = (const StatIntOnceElem &source) 00125 { 00126 if (this == &source) 00127 return *this; 00128 00129 _value = source._value; 00130 _ids = source._ids; 00131 00132 return *this; 00133 } 00134 00135 /*-------------------------- comparison -----------------------------------*/ 00136 00137 bool StatIntOnceElem::operator < (const StatIntOnceElem &other) const 00138 { 00139 return this->get() < other.get(); 00140 } 00141 00142 /*--------------------------- creation ------------------------------------*/ 00143 00144 StatElem *StatIntOnceElem::clone(void) const 00145 { 00146 StatIntOnceElem *e = new StatIntOnceElem(getDesc()); 00147 00148 *e = *this; 00149 00150 return e; 00151 } 00152 00153 00154 /*-------------------------------------------------------------------------*/ 00155 /* cvs id's */ 00156 00157 #ifdef __sgi 00158 #pragma set woff 1174 00159 #endif 00160 00161 #ifdef OSG_LINUX_ICC 00162 #pragma warning( disable : 177 ) 00163 #endif 00164 00165 namespace 00166 { 00167 static Char8 cvsid_cpp[] = "@(#)$Id: OSGStatIntOnceElem.cpp,v 1.1 2005/07/26 19:12:07 dirk Exp $"; 00168 static Char8 cvsid_hpp[] = OSGSTATINTONCEELEM_HEADER_CVSID; 00169 static Char8 cvsid_inl[] = OSGSTATINTONCEELEM_INLINE_CVSID; 00170 }
1.4.3