MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / ReadObjectDynCreate

Method ReadObjectDynCreate

src/core/serializerimpl.cpp:241–331  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// ReadObjectDynCreate //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

239// ReadObjectDynCreate
240///////////////////////////////////////////////////////////////////////////////
241iTypedSerializable* cSerializerImpl::ReadObjectDynCreate()
242{
243 cDebug d("cSerializerImpl::ReadObjectDynCreate");
244 //d.TraceDetail("Entering... archive offset = %d\n", mpArchive->CurrentPos());
245
246 int32 size, objIdx;
247 uint32 crc;
248 // first, get the type...
249 mpArchive->ReadInt32(reinterpret_cast<int32&>(crc));
250
251 // read in the version
252 int32 version;
253 mpArchive->ReadInt32(version);
254
255 // read in the size and the index...
256 mpArchive->ReadInt32(size);
257
258 // Save the position so we can seek correctly later on
259 //int64 sizePos = mpArchive->CurrentPos();
260
261 mpArchive->ReadInt32(objIdx);
262 if (objIdx == 0)
263 {
264 // the object is not reference counted; create and read in the object
265 // first, we need to create the object.
266 SerMap::iterator si;
267 si = mSerCreateMap.find(crc);
268 if (si == mSerCreateMap.end())
269 {
270 // unable to find the creation function...
271 d.TraceError("Unable to find creation function for non-ref counted object %d\n", crc);
272 TOSTRINGSTREAM str;
273#ifdef DEBUG
274 // Let's only report the actual crc in debug mode
275 str << (int32)crc << std::ends;
276#endif
277 ThrowAndAssert(eSerializerUnknownType(str.str(), mFileName, eSerializer::TY_FILE));
278 }
279 iTypedSerializable* pObj = ((*si).second)();
280 d.TraceDetail("Created non-ref counted object %s(%p)\n", pObj->GetType().AsString(), pObj);
281 pObj->Read(this, version);
282
283 // seek past this object in case filepos is not correct!
284 //mpArchive->Seek(sizePos + size, cBidirArchive::BEGINNING);
285
286 return pObj;
287 }
288 else
289 {
290 // refrence counted...
291 iSerRefCountObj* pObj;
292 pObj = mRefCtObjTbl.Lookup(objIdx);
293 if (pObj == NULL)
294 {
295 // not in table yet...first find the creation function
296 SerRefCountMap::iterator rci;
297 rci = mSerRefCountCreateMap.find(crc);
298 if (rci == mSerRefCountCreateMap.end())

Callers 7

ReadMethod · 0.80
ReadMethod · 0.80
ReadMethod · 0.80
ReadMethod · 0.80
ReadMethod · 0.80
TestFCOSpecHelperFunction · 0.80
TestSerRefCountObjFunction · 0.80

Calls 10

endMethod · 0.80
TraceErrorMethod · 0.60
TraceDetailMethod · 0.60
ReadInt32Method · 0.45
findMethod · 0.45
AsStringMethod · 0.45
ReadMethod · 0.45
LookupMethod · 0.45
AddMethod · 0.45
AddRefMethod · 0.45

Tested by 4

ReadMethod · 0.64
ReadMethod · 0.64
TestFCOSpecHelperFunction · 0.64
TestSerRefCountObjFunction · 0.64