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