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 #ifndef _OSGSTATECHUNK_H_ 00041 #define _OSGSTATECHUNK_H_ 00042 #ifdef __sgi 00043 #pragma once 00044 #endif 00045 00046 #include <OSGConfig.h> 00047 #include <OSGDrawActionBase.h> 00048 #include <OSGStateChunkBase.h> 00049 00050 #include <string> 00051 00052 OSG_BEGIN_NAMESPACE 00053 00054 class TextureTransformChunk; 00055 00060 class OSG_SYSTEMLIB_DLLMAPPING StateChunkClass 00061 { 00062 /*========================== PUBLIC =================================*/ 00063 public: 00064 /*---------------------------------------------------------------------*/ 00068 StateChunkClass( Char8 *name, UInt32 numslots = 1 ); 00069 00071 /*---------------------------------------------------------------------*/ 00075 UInt32 getId (void) const; 00076 const Char8 *getName (void) const; 00077 Int32 getNumSlots (void) const; 00078 00080 /*---------------------------------------------------------------------*/ 00084 static const Char8 * getName (UInt32 index); 00085 static Int32 getNumSlots (UInt32 index); 00086 inline static UInt32 getUsedSlots(void) ; 00087 00088 typedef std::vector<std::string>::const_iterator iterator; 00089 00090 static iterator begin(); 00091 static iterator end(); 00094 /*========================== PRIVATE ================================*/ 00095 00096 protected: 00097 00098 friend class TextureTransformChunk; 00099 00100 void swap(StateChunkClass &other); 00101 00102 private: 00103 00104 UInt32 _classId; 00105 static std::vector<std::string>* _classNames; 00106 static std::vector<UInt32>* _numslots; 00107 }; 00108 00113 class OSG_SYSTEMLIB_DLLMAPPING StateChunk : public StateChunkBase 00114 { 00115 /*========================== PUBLIC =================================*/ 00116 public: 00117 00118 /*---------------------------------------------------------------------*/ 00122 UInt32 getClassId (void) const; 00123 virtual const StateChunkClass *getClass (void) const; 00124 00126 /*---------------------------------------------------------------------*/ 00130 inline static UInt32 getStaticClassId(void); 00131 inline static const StateChunkClass *getStaticClass (void); 00132 00134 /*---------------------------------------------------------------------*/ 00138 virtual void changed(BitVector whichField, 00139 UInt32 origin ); 00140 00142 /*---------------------------------------------------------------------*/ 00146 virtual void dump( UInt32 uiIndent = 0, 00147 const BitVector bvFlags = 0) const; 00148 00150 /*---------------------------------------------------------------------*/ 00154 virtual void update ( DrawActionBase * action ); 00155 00156 virtual void activate ( DrawActionBase * action, UInt32 index = 0 ); 00157 00158 virtual void changeFrom ( DrawActionBase * action, StateChunk * old, 00159 UInt32 index = 0 ); 00160 00161 virtual void deactivate ( DrawActionBase * action, UInt32 index = 0 ); 00162 00163 virtual bool isTransparent (void) const; 00164 00166 /*---------------------------------------------------------------------*/ 00170 virtual Real32 switchCost ( StateChunk * chunk ); 00171 00172 virtual bool operator < (const StateChunk &other) const; 00173 00174 virtual bool operator == (const StateChunk &other) const; 00175 virtual bool operator != (const StateChunk &other) const; 00176 00179 /*========================= PROTECTED ===============================*/ 00180 protected: 00181 00182 /*---------------------------------------------------------------------*/ 00186 StateChunk(void); 00187 StateChunk(const StateChunk &source); 00188 00190 /*---------------------------------------------------------------------*/ 00194 virtual ~StateChunk(void); 00195 00198 static void initMethod(void); 00199 00200 /*========================== PRIVATE ================================*/ 00201 private: 00202 00203 typedef StateChunkBase Inherited; 00204 00205 friend class FieldContainer; 00206 friend class StateChunkBase; 00207 00208 static char cvsid[]; 00209 00210 // prohibit default functions (move to 'public' if you need one) 00211 void operator =(const StateChunk &source); 00212 }; 00213 00214 typedef StateChunk *StateChunkP; 00215 00216 OSG_END_NAMESPACE 00217 00218 #include <OSGStateChunk.inl> 00219 #include <OSGStateChunkBase.inl> 00220 00221 #endif /* _OSGSTATECHUNK_H_ */
1.5.5