1 /* 2 * SFInt32.h 3 * 4 * Copyright (C) 1999 Stephen F. White 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program (see the file "COPYING" for details); if 18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave, 19 * Cambridge, MA 02139, USA. 20 */ 21 22 #pragma once 23 24 #include "FieldValue.h" 25 26 class SFInt32 : public FieldValue { 27 public: 28 SFInt32(int value); SFInt32(void)29 SFInt32(void) { m_value = 0; } // silly default 30 getType()31 virtual int getType() const { return SFINT32; } getTypeName()32 virtual const char *getTypeName() const { return "SFInt32"; } 33 virtual MyString getString(int index, int stride) const; 34 35 virtual int writeData(int filedes, int i) const; 36 getTypeC(int languageFlag)37 virtual const char *getTypeC(int languageFlag) const { return "int"; } getDefaultC(int languageFlag)38 virtual const char *getDefaultC(int languageFlag) const { return "0"; } 39 40 virtual bool readLine(int index, char *line); 41 getNumbersPerType(void)42 virtual int getNumbersPerType(void) const { return 1; } 43 44 virtual bool equals(const FieldValue *value) const; 45 virtual void clamp(const FieldValue *min, const FieldValue *max); copy()46 virtual FieldValue *copy() { return new SFInt32(*this); } 47 getValue()48 int getValue() const 49 { 50 #ifdef HAVE_NULL_COMPARE 51 if (this == NULL) 52 return 0; 53 #endif 54 return m_value; 55 } 56 57 MyString getEcmaScriptComment(MyString name, int flags) const; 58 59 // VRML 200x IntegerSequencer not implemented yet supportAnimation(bool x3d)60 bool supportAnimation(bool x3d) const { return false; } 61 getRandom(Scene * scene,int nodetype)62 FieldValue *getRandom(Scene *scene, int nodetype) 63 { return new SFInt32(INT_RAND()); } 64 65 private: 66 int m_value; 67 }; 68 69