7 #ifndef __data_RecordArrayAV_h__ 8 #define __data_RecordArrayAV_h__ 14 { FE_UWORD operator()(
const FE_UWORD &u)
const 18 {
bool operator()(FE_UWORD u1, FE_UWORD u2)
const 19 {
return u1 == u2; } };
21 typedef HashMap<FE_UWORD, IWORD, hash_av, eq_av> t_av_map;
42 FE_UWORD idr(IWORD index);
49 Layout *rawLayout(
void)
const;
55 bool add(
const RecordAV &record, IWORD *index = NULL);
60 bool addCovert(
const RecordAV &record, IWORD *index = NULL);
64 IWORD start, IWORD size);
68 bool addCreateCovert(U32 a_count);
73 bool remove(
const RecordAV &record, IWORD *index = NULL);
80 void remove(IWORD index);
84 bool removeCovert(
const RecordAV &record,IWORD *index=NULL);
87 void removeCovert(IWORD index);
90 { m_hpRecordGroup=a_spRecordGroup; }
103 void set(
RecordAV &record, IWORD index);
116 void setWeak(BWORD weak);
119 BWORD
isWeak(
void)
const {
return m_weak; }
131 void enableDuplicates(
bool a_bool);
142 void maintainOrder(
bool a_bool);
146 T &accessAttribute(FE_UWORD aLocator,
147 FE_UWORD aIndex)
const;
150 FE_UWORD arrayindex(IWORD index)
const;
152 T &accessAttributeUnsafe(FE_UWORD aLocator,
153 FE_UWORD aIndex)
const;
158 I32 readSerialNumber(IWORD index)
const;
160 void trackBlock(U32 index);
161 void untrackBlock(U32 index);
163 void acquireAV(IWORD index);
164 void releaseAV(IWORD index);
172 FE_UWORD m_serialLocator;
174 bool m_maintainOrder;
179 const String& name(
void)
const 180 {
return m_spLayout.isValid()?
181 m_spLayout->name(): Counted::name(); }
182 const String verboseName(
void)
const 183 {
return "RecordArray " +
184 String(m_weak?
"(weak) ":
"") + name(); }
189 inline T &RecordArrayAV::accessAttribute(FE_UWORD aLocator, FE_UWORD aIndex)
const 195 return *(T *)(m_spLayout
196 ->m_attributeVector[m_spLayout->m_locatorTable[aLocator]]
197 ->raw_at(m_pArrayIndex[aIndex]));
199 return *(T *)(m_spLayout->voidAccess(aLocator, m_pArrayIndex[aIndex]));
203 inline T &RecordArrayAV::accessAttributeUnsafe(
204 FE_UWORD aLocator, FE_UWORD aIndex)
const 207 return *(T *)(m_spLayout
208 ->m_attributeVector[m_spLayout->m_locatorTable[aLocator]]
209 ->raw_at(m_pArrayIndex[aIndex]));
211 return *(T *)(m_spLayout->voidAccess(aLocator, m_pArrayIndex[aIndex]));
215 class PtrRecordArrayAVInfo :
public BaseType::Info
218 virtual IWORD output(std::ostream &ostrm,
void *instance, t_serialMode mode);
219 virtual void input(std::istream &istrm,
void *instance, t_serialMode mode);
220 virtual IWORD iosize(
void);
221 virtual bool getConstruct(
void);
222 virtual void construct(
void *instance);
223 virtual void destruct(
void *instance);
237 m_maintainOrder = a_bool;
240 inline void RecordArrayAV::set(
WeakRecordAV &record, IWORD index)
242 record.set(m_pArrayIndex[index], m_spLayout);
245 inline void RecordArrayAV::set(
RecordAV &record, IWORD index)
247 record.set(m_pArrayIndex[index], m_spLayout);
252 return m_pArrayIndex.size();
265 FE_UWORD ai=arrayindex(index);
266 if(ai != LayoutAV::arrayindexNone)
268 record.set(ai, m_spLayout);
276 FE_UWORD ai=arrayindex(index);
277 if(ai != LayoutAV::arrayindexNone)
279 record.set(ai, m_spLayout);
284 inline void RecordArrayAV::acquireAV(IWORD index)
288 m_spLayout->acquireArrayIndex(arrayindex(index));
293 inline void RecordArrayAV::releaseAV(IWORD index)
298 m_spLayout->releaseArrayIndex(arrayindex(index));
302 inline I32 RecordArrayAV::readSerialNumber(IWORD index)
const 304 if(m_serialLocator!=LayoutAV::locatorNone &&
305 m_pArrayIndex[index]!=LayoutAV::arrayindexNone)
307 #ifdef FE_AV_FASTITER_ENABLE 308 if(!m_spLayout->existenceCheck(m_serialLocator, m_pArrayIndex[index]))
313 return accessAttributeUnsafe<int>(m_serialLocator, index);
322 inline FE_UWORD RecordArrayAV::idr(IWORD index)
324 return m_spLayout->idr(arrayindex(index));
327 inline void RecordArrayAV::untrackBlock(U32 index)
334 inline void RecordArrayAV::trackBlock(U32 index)
345 #if FE_CODEGEN<=FE_DEBUG 346 if(index<0 || index >= IWORD(m_pArrayIndex.size()))
348 feX(
"fe::RecordArray::data",
"index out of range");
351 if(m_weak && m_pSN[index]>=0 && m_pSN[index]!=readSerialNumber(index))
353 feLog(
"RecordArray::data weak element %d is not valid (%d vs %d)\n",
354 index,m_pSN[index],readSerialNumber(index));
356 feLog(
" name \"%s\"\n",name().c_str());
359 *(
const_cast<FE_UWORD *
>(&(m_pArrayIndex[index])))=
360 LayoutAV::arrayindexNone;
361 return LayoutAV::arrayindexNone;
363 return m_pArrayIndex[index];
Homogeneous collection of Records.
Definition: RecordArrayAV.h:32
WeakRecordAV getWeakRecord(IWORD index)
Return a non-persistent record for the given index.
Definition: RecordArrayAV.h:273
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
kernel
Definition: namespace.dox:3
void setWeak(BWORD weak)
Choose weak referencing.
Definition: RecordArrayAV.h:226
IWORD length(void)
Return the length of the array.
Definition: RecordArrayAV.h:250
RecordAV getRecord(IWORD index)
Return the record at the given index.
Definition: RecordArrayAV.h:262
Automatically reference-counted string container.
Definition: String.h:128
BWORD isWeak(void) const
Return TRUE if using weak referencing.
Definition: RecordArrayAV.h:119
FE_UWORD arrayindex(IWORD index) const
Return the arrayindex at the given index.
Definition: RecordArrayAV.h:343
Reference to an instance of a Layout.
Definition: RecordAV.h:25
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordAV.h:17
sp< Layout > layout(void)
Return the Layout.
Definition: RecordArrayAV.h:257
void bind(sp< RecordGroup > a_spRecordGroup)
Definition: RecordArrayAV.h:89
void maintainOrder(bool a_bool)
Don't reorder entries during removal.
Definition: RecordArrayAV.h:235