7 #ifndef __data_RecordSB_h__ 8 #define __data_RecordSB_h__ 13 #define FE_RECORD_COUNT_DEBUG FALSE 53 FE_UWORD idr(
void)
const;
56 bool isValid(
void)
const;
67 T &accessAttribute(FE_UWORD aLocator)
const;
69 void *rawAttribute(FE_UWORD aLocator)
const;
73 void *
data(
void)
const;
82 void set(
void *datablock);
90 { FE_UWORD operator()(
const RecordSB r_rec)
const 91 {
return r_rec.
idr() % 17191; } };
95 return (lhs.
idr() < rhs.
idr());
98 class RecordSBInfo :
public BaseType::Info
101 virtual String print(
void *instance);
102 virtual IWORD output(std::ostream &ostrm,
void *instance, t_serialMode mode);
103 virtual void input(std::istream &istrm,
void *instance, t_serialMode mode);
104 virtual IWORD iosize(
void);
105 virtual bool getConstruct(
void);
106 virtual void construct(
void *instance);
107 virtual void destruct(
void *instance);
110 inline RecordSB::RecordSB(I32)
112 m_pStateBlock = NULL;
115 inline RecordSB::RecordSB(
const RecordSB &other)
117 m_spLayout = other.m_spLayout;
118 m_pStateBlock = other.m_pStateBlock;
131 inline RecordSB::~RecordSB(
void)
138 return m_spLayout.raw();
146 m_spLayout = other.m_spLayout;
147 m_pStateBlock = other.m_pStateBlock;
153 inline bool RecordSB::operator==(
const RecordSB &other)
const 155 return (m_pStateBlock == other.m_pStateBlock);
158 inline bool RecordSB::operator!=(
const RecordSB &other)
const 160 return (m_pStateBlock != other.m_pStateBlock);
165 return m_pStateBlock;
170 return reinterpret_cast<FE_UWORD
>(m_pStateBlock);
174 inline T &RecordSB::accessAttribute(FE_UWORD aLocator)
const 176 return *((T *)((
char *)(
data()) + m_spLayout->offsetTable()[aLocator]));
179 inline void *RecordSB::rawAttribute(FE_UWORD aLocator)
const 181 return (
void *)((
char *)(
data()) + m_spLayout->offsetTable()[aLocator]);
186 return (m_pStateBlock != NULL);
197 m_pStateBlock = datablock;
199 m_spLayout = FE_SB_TO_HDR(m_pStateBlock)->m_pStore->getLayout();
202 inline void RecordSB::release(
void)
204 #if FE_RECORD_COUNT_DEBUG 205 register FE_UWORD index;
206 if(m_spLayout.isValid())
208 m_spLayout->scope()->findAttribute(FE_C,index);
209 if(m_spLayout->offsetTable()[index] != offsetNone)
211 IWORD &count= *((IWORD *)((
char *)(
data()) +
212 layout()->offsetTable()[index]));
214 fe_fprintf(stderr,
"Release %p %d->%d %s\n",(U32)
this,count,count-1,
215 m_spLayout->name().c_str());
223 Counted::untrackReference(FE_SB_TO_HDR(m_pStateBlock),&m_pStateBlock);
227 FE_SB_TO_HDR(m_pStateBlock)->m_pStore->releaseSB(*
this);
231 inline void RecordSB::acquire(
void)
233 #if FE_RECORD_COUNT_DEBUG 234 register FE_UWORD index;
235 if(m_spLayout.isValid())
237 m_spLayout->scope()->findAttribute(FE_C,index);
238 if(m_spLayout->offsetTable()[index] != offsetNone)
240 IWORD &count= *((IWORD *)((
char *)(
data()) +
241 m_spLayout->offsetTable()[index]));
243 fe_fprintf(stderr,
"Acquire %p %d->%d %s\n",(U32)
this,count,count+1,
244 m_spLayout->name().c_str());
251 FE_SB_TO_HDR(m_pStateBlock)->m_pStore->acquireSB(m_pStateBlock);
256 Counted::trackReference(FE_SB_TO_HDR(m_pStateBlock),&m_pStateBlock,
Memory manager for state blocks.
Definition: SegmentStore.h:17
bool isValid(void) const
Return true if the Record points to a valid state block.
Definition: RecordSB.h:184
Smart pointer used with types represented by BaseType.
Definition: Instance.h:28
kernel
Definition: namespace.dox:3
void * data(void) const
Return the state block.
Definition: RecordSB.h:163
sp< Layout > layout(void) const
Return the Layout.
Definition: RecordSB.h:189
BWORD operator!=(const DualString &s1, const DualString &s2)
Compare two DualString's (reverse logic)
Definition: DualString.h:229
void set(void *datablock)
Set the state block.
Definition: RecordSB.h:194
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString's.
Definition: DualString.h:208
FE_UWORD idr(void) const
Return a unique runtime id (id-runtime, idr, since 'rid' has other meaning.
Definition: RecordSB.h:168
LayoutSB * rawLayout(void) const
Return a raw pointer to the Layout.
Definition: RecordSB.h:136
Automatically reference-counted string container.
Definition: String.h:128
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Record "type" definition.
Definition: LayoutSB.h:32
Homogeneous collection of Records.
Definition: RecordArraySB.h:40
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17