45 template <
class BV, VD::Type, u32, u32>
class BitField;
77 typedef typename CC::ATOM_TYPE T;
82 typedef typename CC::PARAM_CONFIG P;
87 enum { BPA = P::BITS_PER_ATOM };
92 enum { R = P::EVENT_WINDOW_RADIUS };
104 template <
class BV, VD::Type, u32, u32>
friend class BitField;
111 COMPILATION_REQUIREMENT<sizeof(Atom)==sizeof(m_bits)>();
125 return atom.GetType()==type;
139 return atom.GetType()==other.GetType();
153 return static_cast<const T*
>(
this)->IsSaneImpl();
168 return static_cast<T*
>(
this)->HasBeenRepairedImpl();
180 return static_cast<const T*
>(
this)->GetTypeImpl();
190 static_cast<const T*
>(
this)->PrintImpl(ostream);
201 static_cast<const T*
>(
this)->WriteStateBitsImpl(ostream);
211 static_cast<T*
>(
this)->ReadStateBitsImpl(hexStr);
223 static_cast<T*
>(
this)->ReadStateBitsImpl(bv);
245 u32 len = strlen(hexStr);
246 u32 bitLen = len * 4;
250 FAIL(ILLEGAL_ARGUMENT);
258 for(s32 i = len - 1; i >= 0; i--)
261 if(hexVal >=
'0' && hexVal <=
'9')
265 else if(hexVal >=
'a' && hexVal >=
'f')
267 hexVal = hexVal -
'a' + 10;
269 else if(hexVal >=
'A' && hexVal <=
'F')
271 hexVal = hexVal -
'A' + 10;
275 FAIL(ILLEGAL_ARGUMENT);
278 for(s32 j = 3; j >= 0; j--)
297 for(u32 i = 0; i < BPA; i++)
299 if(rand.
OneIn(bitOdds))
306 bool operator==(
const Atom & rhs)
const
311 bool operator!=(
const Atom & rhs)
const
313 return !(*
this == rhs);
void WriteStateBits(ByteSink &ostream) const
Definition: Atom.h:199
u32 GetType() const
Definition: Atom.h:178
void Clear()
Definition: BitVector.tcc:26
void ReadStateBits(const BitVector< BPA > &bv)
Definition: Atom.h:221
void WriteBit(u32 idx, bool bit)
Definition: BitVector.tcc:41
void WriteBits(ByteSink &ostream) const
Definition: Atom.h:232
void Print(ByteSink &ostream) const
Definition: BitVector.tcc:202
bool OneIn(u32 odds)
Definition: Random.h:96
bool IsSane() const
Definition: Atom.h:151
bool ToggleBit(const u32 idx)
Definition: BitVector.tcc:54
void ReadStateBits(const char *hexStr)
Definition: Atom.h:209
bool HasBeenRepaired()
Definition: Atom.h:166
void XRay(Random &rand, u32 bitOdds)
Definition: Atom.h:295
Definition: ByteSink.h:47
static bool IsSameType(const T &atom, const T &other)
Definition: Atom.h:137
void Print(ByteSink &ostream) const
Definition: Atom.h:188
void ReadBits(const char *hexStr)
Definition: Atom.h:243
BitVector< BPA > m_bits
Definition: Atom.h:99
static bool IsType(const T &atom, u32 type)
Definition: Atom.h:123