7 #ifndef __surface_SurfaceAccessorCached_h__ 8 #define __surface_SurfaceAccessorCached_h__ 10 #define FE_SACH_DEBUG FALSE 11 #define FE_SACH_USE_INSTANCE FALSE 31 using SurfaceAccessorBase::set;
32 using SurfaceAccessorBase::append;
33 using SurfaceAccessorBase::spatialVector;
36 virtual String type(
void)
const 37 {
return m_spAccessorChain->type(); }
39 virtual U32 count(
void)
const 40 {
return m_spAccessorChain->count(); }
41 virtual U32 subCount(U32 a_index)
const 42 {
return m_spAccessorChain->subCount(a_index); }
44 virtual void set(U32 a_index,U32 subIndex,
String a_string)
46 if(!m_changed[a_index])
48 #if FE_SACH_USE_INSTANCE 49 m_value[a_index].create<
String>(typeMaster());
51 m_changed[a_index]=TRUE;
52 if(m_attrType==e_none)
55 #if !FE_SACH_USE_INSTANCE 56 m_string.resize(m_size);
59 FEASSERT(m_attrType==e_string);
61 #if FE_SACH_USE_INSTANCE 62 m_value[a_index].cast<
String>()=a_string;
64 m_string[a_index]=a_string;
67 virtual String string(U32 a_index,U32 a_subIndex=0)
69 if(m_changed[a_index])
71 FEASSERT(m_attrType==e_string);
72 #if FE_SACH_USE_INSTANCE 73 return m_value[a_index].cast<
String>();
75 return m_string[a_index];
78 return m_spAccessorChain->string(
82 virtual void set(U32 a_index,U32 a_subIndex,I32 a_integer)
84 if(!m_changed[a_index])
86 #if FE_SACH_USE_INSTANCE 87 m_value[a_index].create<I32>(typeMaster());
89 m_changed[a_index]=TRUE;
90 if(m_attrType==e_none)
93 #if !FE_SACH_USE_INSTANCE 94 m_integer.resize(m_size);
97 FEASSERT(m_attrType==e_integer);
99 #if FE_SACH_USE_INSTANCE 100 m_value[a_index].cast<I32>()=a_integer;
102 m_integer[a_index]=a_integer;
105 virtual I32 integer(U32 a_index,U32 a_subIndex=0)
110 SurfaceAccessibleI::e_primitiveGroup &&
112 SurfaceAccessibleI::e_vertices &&
114 SurfaceAccessibleI::e_properties &&
117 FEASSERT(m_attrType==e_integer);
118 #if FE_SACH_USE_INSTANCE 119 return m_value[a_index].cast<I32>();
121 return m_integer[a_index];
124 return m_spAccessorChain->integer(
128 virtual I32 duplicate(U32 a_index,U32 a_subIndex=0)
129 {
return m_spAccessorChain->duplicate(
130 a_index,a_subIndex); }
132 virtual void append(U32 a_index,I32 a_integer)
133 { m_spAccessorChain->append(a_index,a_integer); }
135 virtual void remove(U32 a_index,I32 a_integer)
136 { m_spAccessorChain->remove(a_index,a_integer); }
138 virtual void set(U32 a_index,U32 a_subIndex,Real a_real)
140 if(!m_changed[a_index])
142 #if FE_SACH_USE_INSTANCE 143 m_value[a_index].create<Real>(typeMaster());
145 m_changed[a_index]=TRUE;
146 if(m_attrType==e_none)
149 #if !FE_SACH_USE_INSTANCE 150 m_real.resize(m_size);
153 FEASSERT(m_attrType==e_real);
155 #if FE_SACH_USE_INSTANCE 156 m_value[a_index].cast<Real>()=a_real;
158 m_real[a_index]=a_real;
161 virtual Real real(U32 a_index,U32 a_subIndex=0)
163 if(m_changed[a_index])
165 FEASSERT(m_attrType==e_real);
166 #if FE_SACH_USE_INSTANCE 167 return m_value[a_index].cast<Real>();
169 return m_real[a_index];
172 return m_spAccessorChain->real(a_index,a_subIndex);
175 virtual void set(U32 a_index,U32 a_subIndex,
178 const U32 index=trueIndex(a_index,a_subIndex);
180 feLog(
"SurfaceAccessorCached::set" 181 " \"%s\" %d %d (%d) ch %d %s\n",
183 a_index,a_subIndex,index,
184 I32(m_changed[index]),
185 c_print(a_spatialVector));
187 if(!m_changed[index])
190 feLog(
" create %d\n",index);
192 m_changed[index]=TRUE;
193 if(m_attrType==e_none)
195 m_attrType=e_spatialVector;
196 #if !FE_SACH_USE_INSTANCE 197 m_spatialVector.resize(m_size);
202 SurfaceAccessibleI::e_vertices ||
204 SurfaceAccessibleI::e_properties)
206 m_integer.resize(m_size);
207 m_subIndex.resize(m_size);
210 FEASSERT(m_attrType==e_spatialVector);
211 #if FE_SACH_USE_INSTANCE 218 SurfaceAccessibleI::e_vertices ||
220 SurfaceAccessibleI::e_properties)
222 m_integer[index]=a_index;
223 m_subIndex[index]=a_subIndex;
226 #if FE_SACH_USE_INSTANCE 230 m_spatialVector[index]=a_spatialVector;
233 virtual SpatialVector spatialVector(U32 a_index,U32 a_subIndex=0)
235 const U32 index=trueIndex(a_index,a_subIndex);
237 feLog(
"SurfaceAccessorCached::spatialVector" 238 " \"%s\" %d %d (%d) ch %d\n",
240 a_index,a_subIndex,index,
241 I32(m_changed[index]));
245 FEASSERT(m_attrType==e_spatialVector);
247 feLog(
" override\n");
249 #if FE_SACH_USE_INSTANCE 252 return m_spatialVector[index];
255 return m_spAccessorChain->spatialVector(
261 m_spAccessorChain=a_spAccessorI;
262 m_element=m_spAccessorChain->element();
263 m_attribute=m_spAccessorChain->attribute();
264 m_attrName=m_spAccessorChain->attributeName();
265 m_count=m_spAccessorChain->count();
268 SurfaceAccessibleI::e_primitiveGroup ||
269 m_attribute==SurfaceAccessibleI::e_vertices
271 SurfaceAccessibleI::e_properties)
274 for(U32 index=0;index<m_count;index++)
276 m_size+=m_spAccessorChain->subCount(index);
280 m_changed.resize(m_size);
281 for(U32 m=0;m<m_size;m++)
285 #if FE_SACH_USE_INSTANCE 286 m_value.resize(m_size);
291 U32 trueIndex(U32 a_index,U32 a_subIndex)
294 SurfaceAccessibleI::e_primitiveGroup ||
295 m_attribute==SurfaceAccessibleI::e_vertices)
297 const U32 index=m_spAccessorChain->integer(
303 FEASSERT(index<m_size);
308 const U32 newSize=index*1.1+10;
310 m_value.resize(newSize);
311 m_changed.resize(newSize);
312 for(;m_size<newSize;m_size++)
314 m_changed[m_size]=FALSE;
317 feLog(
"SurfaceAccessorCached::trueIndex" 318 " \"%s\" resized %d\n",
319 m_attrName.c_str(),m_size);
337 {
return registry()->
master()->typeMaster(); }
346 #if FE_SACH_USE_INSTANCE Surface Element Access and Alteration.
Definition: SurfaceAccessibleI.h:22
Accessor with Deferred Writes.
Definition: SurfaceAccessorCached.h:23
kernel
Definition: namespace.dox:3
Common Functionality for Accessor Surface.
Definition: SurfaceAccessorBase.h:20
Automatically reference-counted string container.
Definition: String.h:128
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
sp< Master > master(void) const
Access the Master (ptr may not be valid)
Definition: Registry.cc:98
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192