fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGMultiPropertyUBOChunk.h
blob8d0da935b1a9f242300c6a4f4e0f177ba0cf2bac
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGMULTIPROPERTYUBOCHUNK_H_
40 #define _OSGMULTIPROPERTYUBOCHUNK_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGMultiPropertyUBOChunkBase.h"
47 OSG_BEGIN_NAMESPACE
49 /*! \brief MultiPropertyUBOChunk class. See \ref
50 PageSystemMultiPropertyUBOChunk for a description.
53 class OSG_SYSTEM_DLLMAPPING MultiPropertyUBOChunk : public MultiPropertyUBOChunkBase
55 protected:
57 /*========================== PUBLIC =================================*/
59 public:
61 typedef MultiPropertyUBOChunkBase Inherited;
62 typedef MultiPropertyUBOChunk Self;
64 /*---------------------------------------------------------------------*/
65 /*! \name Interface */
66 /*! \{ */
68 enum Types {
69 FLOAT_T = 0,
70 DOUBLE_T,
71 INT_T,
72 UINT_T,
73 BOOL_T,
74 VEC3_T,
75 VEC4_T,
76 MAT4_T
79 void clearMembers ();
80 UInt32 addMember (Types type, UInt32 cardinality = 1);
82 UInt32 getNumProperties () const;
83 UInt32 addProperty ();
84 void removeProperty (const UInt32 idx);
85 void clearProperties ();
87 Real32 getFloatProperty (UInt32 idx, UInt32 num) const;
88 Real64 getDoubleProperty(UInt32 idx, UInt32 num) const;
89 Int32 getIntProperty (UInt32 idx, UInt32 num) const;
90 UInt32 getUIntProperty (UInt32 idx, UInt32 num) const;
91 bool getBoolProperty (UInt32 idx, UInt32 num) const;
92 const Vec3f &getVec3Property (UInt32 idx, UInt32 num) const;
93 const Vec4f &getVec4Property (UInt32 idx, UInt32 num) const;
94 const Matrix &getMat4Property (UInt32 idx, UInt32 num) const;
96 void setFloatProperty (UInt32 idx, UInt32 num, Real32 value);
97 void setDoubleProperty(UInt32 idx, UInt32 num, Real64 value);
98 void setIntProperty (UInt32 idx, UInt32 num, Int32 value);
99 void setUIntProperty (UInt32 idx, UInt32 num, UInt32 value);
100 void setBoolProperty (UInt32 idx, UInt32 num, bool value);
101 void setVec3Property (UInt32 idx, UInt32 num, const Vec3f& value);
102 void setVec4Property (UInt32 idx, UInt32 num, const Vec4f& value);
103 void setMat4Property (UInt32 idx, UInt32 num, const Matrix& value);
104 /*! \} */
106 /*---------------------------------------------------------------------*/
107 /*! \name Sync */
108 /*! \{ */
110 virtual void changed(ConstFieldMaskArg whichField,
111 UInt32 origin,
112 BitVector details );
114 /*! \} */
115 /*---------------------------------------------------------------------*/
116 /*! \name Output */
117 /*! \{ */
119 virtual void dump( UInt32 uiIndent = 0,
120 const BitVector bvFlags = 0) const;
122 /*! \} */
123 /*---------------------------------------------------------------------*/
124 /*! \name State */
125 /*! \{ */
127 virtual void activate (DrawEnv *pEnv,
128 UInt32 index = 0);
130 virtual void changeFrom (DrawEnv *pEnv,
131 StateChunk *pOld,
132 UInt32 index = 0);
134 virtual void deactivate (DrawEnv *pEnv,
135 UInt32 index = 0);
137 /*! \} */
138 /*---------------------------------------------------------------------*/
139 /*! \name OpenGL handling */
140 /*! \{ */
141 /*! \} */
142 /*========================= PROTECTED ===============================*/
144 protected:
146 static const UInt8 _numTypes;
147 bool _bUpdateBuffer;
149 // Variables should all be in MultiPropertyUBOChunkBase.
151 void onCreate (const MultiPropertyUBOChunk *source = NULL);
152 void onCreateAspect(const MultiPropertyUBOChunk *createAspect,
153 const MultiPropertyUBOChunk *source = NULL);
154 void onDestroy ( UInt32 uiContainerId );
156 /*---------------------------------------------------------------------*/
157 /*! \name Constructors */
158 /*! \{ */
160 MultiPropertyUBOChunk(void);
161 MultiPropertyUBOChunk(const MultiPropertyUBOChunk &source);
163 /*! \} */
164 /*---------------------------------------------------------------------*/
165 /*! \name Destructors */
166 /*! \{ */
168 virtual ~MultiPropertyUBOChunk(void);
170 /*! \} */
171 /*---------------------------------------------------------------------*/
172 /*! \name Init */
173 /*! \{ */
175 static void initMethod(InitPhase ePhase);
177 /*! \} */
178 /*========================== PRIVATE ================================*/
180 private:
182 friend class FieldContainer;
183 friend class MultiPropertyUBOChunkBase;
185 /*---------------------------------------------------------------------*/
186 /*! \name buffer */
187 /*! \{ */
188 std::size_t calc_property_buffer_size () const;
189 std::vector<UInt8> create_property_buffer (DrawEnv* pEnv) const;
190 void create_property_state (DrawEnv* pEnv);
191 void update_property_state (DrawEnv* pEnv);
193 /*! \} */
195 bool check_invariant() const;
197 // prohibit default functions (move to 'public' if you need one)
198 void operator =(const MultiPropertyUBOChunk &source);
201 typedef MultiPropertyUBOChunk *MultiPropertyUBOChunkP;
203 OSG_END_NAMESPACE
205 #include "OSGMultiPropertyUBOChunkBase.inl"
206 #include "OSGMultiPropertyUBOChunk.inl"
208 #endif /* _OSGMULTIPROPERTYUBOCHUNK_H_ */