7 #ifndef __data_RecordArraySB_h__ 8 #define __data_RecordArraySB_h__ 13 struct hash_sb_pointer
14 { FE_UWORD operator()(
const void *pV)
const 15 {
return reinterpret_cast<FE_UWORD
>(pV); } };
18 {
bool operator()(
void *pV1,
void *pV2)
const 19 {
return pV1 == pV2; } };
22 typedef HashMap<
void *,
25 eq_sb_pointer> t_sb_map;
27 typedef std::map< void *, IWORD > t_sb_map;
52 FE_UWORD idr(IWORD index);
65 bool add(
const RecordSB &record, IWORD *index = NULL);
69 bool addCovert(
const RecordSB &record, IWORD *index = NULL){
return false;}
72 void enableDuplicates(
bool a_bool);
81 bool remove(
const RecordSB &record, IWORD *index = NULL);
84 bool removeCovert(
const RecordSB &record,IWORD *index=NULL) {
return false; }
85 void removeCovert(IWORD index) {}
99 void set(
RecordSB &record, IWORD index);
112 void setWeak(BWORD weak);
115 BWORD
isWeak(
void)
const {
return m_weak; }
122 void remove(IWORD index);
125 T &accessAttribute(FE_UWORD aLocator, FE_UWORD aIndex)
const;
128 void *
data(IWORD index)
const;
132 void acquireSB(IWORD index);
133 void releaseSB(IWORD index);
135 I32 readSerialNumber(IWORD index)
const;
137 void trackBlock(U32 index);
138 void untrackBlock(U32 index);
153 const String& name(
void)
const 154 {
return m_spLayout.isValid()?
155 m_spLayout->name(): Counted::name(); }
156 const String verboseName(
void)
const 157 {
return "RecordArray " +
158 String(m_weak?
"(weak) ":
"") + name(); }
163 inline T &RecordArraySB::accessAttribute(FE_UWORD aLocator, FE_UWORD aIndex)
const 165 #if FE_CODEGEN<=FE_DEBUG 166 return *((T *)((
char *)(
data(aIndex)) + m_spLayout->offsetTable()[aLocator]));
168 return *((T *)((
char *)(
data(aIndex)) + m_spLayout.raw()->offsetTable()[aLocator]));
172 class PtrRecordArraySBInfo :
public BaseType::Info
175 virtual IWORD output(std::ostream &ostrm,
void *instance, t_serialMode mode);
176 virtual void input(std::istream &istrm,
void *instance, t_serialMode mode);
177 virtual IWORD iosize(
void);
178 virtual bool getConstruct(
void);
179 virtual void construct(
void *instance);
180 virtual void destruct(
void *instance);
192 inline void RecordArraySB::set(
WeakRecordSB &record, IWORD index)
194 record.
set(m_ppSB[index]);
197 inline void RecordArraySB::set(
RecordSB &record, IWORD index)
199 record.
set(m_ppSB[index]);
203 inline LayoutSB *RecordArraySB::rawLayout(
void)
const 205 return m_spLayout.raw();
210 inline void *RecordArraySB::operator[](IWORD index)
212 return m_ppSB[index];
229 void* pSB=
data(index);
240 void* pSB=
data(index);
248 inline void RecordArraySB::acquireSB(IWORD index)
252 FE_SB_TO_HDR(m_ppSB[index])->m_pStore->acquireSB(m_ppSB[index]);
257 inline void RecordArraySB::releaseSB(IWORD index)
262 FE_SB_TO_HDR(m_ppSB[index])->m_pStore->releaseSB(getRecord(index));
266 inline I32 RecordArraySB::readSerialNumber(IWORD index)
const 268 return (m_serialOffset>=0 && m_ppSB[index])?
269 *((I32 *)((
char *)(m_ppSB[index]) + m_serialOffset)): -1;
274 #if FE_CODEGEN<=FE_DEBUG 275 if(index >= m_used || index < 0)
277 feX(
"fe::RecordArray::data",
"index out of range");
283 feLog(
"RecordArray::data %d SN %d vs %d\n",
284 index,m_pSN[index],readSerialNumber(index));
288 if(m_weak && m_pSN[index]>=0 && m_pSN[index]!=readSerialNumber(index))
290 feLog(
"RecordArray::data weak element %d is not valid (%d vs %d)\n",
291 index,m_pSN[index],readSerialNumber(index));
293 feLog(
" name \"%s\"\n",name().c_str());
299 return m_ppSB[index];
304 return reinterpret_cast<FE_UWORD
>(
data(index));
307 inline void RecordArraySB::untrackBlock(U32 index)
310 untrackReference(FE_SB_TO_HDR(m_ppSB[index]),
this);
314 inline void RecordArraySB::trackBlock(U32 index)
318 blockname.
sPrintf(
"block:%d %s",index,name().c_str());
319 trackReference(FE_SB_TO_HDR(m_ppSB[index]),
this,
"RecordArray");
sp< Layout > layout(void)
Return the Layout.
Definition: RecordArraySB.h:221
FE_UWORD idr(IWORD index)
Return the state block at the given index.
Definition: RecordArraySB.h:302
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
kernel
Definition: namespace.dox:3
IWORD length(void)
Return the length of the array.
Definition: RecordArraySB.h:216
void set(void *datablock)
Set the state block.
Definition: RecordSB.h:194
String & sPrintf(const char *fmt,...)
Populate the string in the manner of sprintf().
Definition: String.cc:529
Automatically reference-counted string container.
Definition: String.h:128
Reference to an instance of a Layout.
Definition: RecordSB.h:35
void * data(IWORD index) const
Return the state block at the given index.
Definition: RecordArraySB.h:272
RecordSB getRecord(IWORD index)
Return the record at the given index.
Definition: RecordArraySB.h:226
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Record "type" definition.
Definition: LayoutSB.h:32
void setWeak(BWORD weak)
Choose weak referencing.
Definition: RecordArraySB.h:183
Homogeneous collection of Records.
Definition: RecordArraySB.h:40
BWORD isWeak(void) const
Return TRUE if using weak referencing.
Definition: RecordArraySB.h:115
void set(void *datablock)
Set the state block.
Definition: WeakRecordSB.h:197
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17
WeakRecordSB getWeakRecord(IWORD index)
Return a non-persistent record for the given index.
Definition: RecordArraySB.h:237