Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGStatIntElem.cpp

Go to the documentation of this file.
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 "OSGStatIntElem.h"
00050 
00051 OSG_USING_NAMESPACE
00052 
00053 
00054 /***************************************************************************\
00055  *                            Description                                  *
00056 \***************************************************************************/
00057 
00065 /***************************************************************************\
00066  *                         Instance methods                                *
00067 \***************************************************************************/
00068 
00069 /*------------- constructors & destructors --------------------------------*/
00070 
00071 StatIntElem::StatIntElem(StatElemDescBase *desc)
00072   : StatElem(desc), _value(0)
00073 {
00074 }
00075 
00076 StatElem *StatIntElem::create ( StatElemDescBase *desc)
00077 {
00078   return new StatIntElem(desc);
00079 }
00080 
00081 StatIntElem::~StatIntElem(void)
00082 {
00083 }
00084 
00085 /*------------------------------ access -----------------------------------*/
00086 
00087 void StatIntElem::putToString(std::string &str, const char *format) const
00088 {
00089     if(!format)
00090     {
00091         FieldDataTraits<Int32>::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 StatIntElem::getFromString(const Char8 *&inVal)
00103 {
00104     return FieldDataTraits<Int32>::getFromString(_value, inVal);
00105 }
00106 
00107 Real64 StatIntElem::getValue(void) const
00108 {
00109     return static_cast<Real64>(get());
00110 }
00111 
00112 
00113 void StatIntElem::reset(void) 
00114 { 
00115     _value = 0; 
00116 }
00117 
00118 /*-------------------------- assignment -----------------------------------*/
00119 
00120 StatIntElem& StatIntElem::operator = (const StatIntElem &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 StatIntElem::operator < (const StatIntElem &other) const
00133 {
00134     return this->get() < other.get();
00135 }
00136 
00137 /*--------------------------- creation ------------------------------------*/
00138 
00139 StatElem *StatIntElem::clone(void) const
00140 {
00141     StatIntElem *e = new StatIntElem(getDesc());
00142     
00143     *e = *this;
00144     
00145     return e;
00146 }
00147 
00148 
00149 /*-------------------------------------------------------------------------*/
00150 /*                              cvs id's                                   */
00151 
00152 #ifdef __sgi
00153 #pragma set woff 1174
00154 #endif
00155 
00156 #ifdef OSG_LINUX_ICC
00157 #pragma warning( disable : 177 )
00158 #endif
00159 
00160 namespace
00161 {
00162     static Char8 cvsid_cpp[] = "@(#)$Id: $";
00163     static Char8 cvsid_hpp[] = OSGSTATINTELEM_HEADER_CVSID;
00164     static Char8 cvsid_inl[] = OSGSTATINTELEM_INLINE_CVSID;
00165 }

Generated on Thu Aug 25 04:10:50 2005 for OpenSG by  doxygen 1.4.3