version 1.1.2.5, 2009/12/03 15:53:27
|
version 1.5, 2013/01/14 12:05:39
|
|
|
| |
SCMOStreamer::SCMOStreamer(CIMBuffer& out, Array<SCMOInstance>& x) : | SCMOStreamer::SCMOStreamer(CIMBuffer& out, Array<SCMOInstance>& x) : |
_buf(out), | _buf(out), |
_scmoInstances(x), |
_scmoInstances(x) |
_ttlNumInstances(0), |
|
_ttlNumClasses(0) |
|
{ | { |
}; | }; |
| |
|
|
// instance of SCMOStreamer, including their referenced Classes and Instances | // instance of SCMOStreamer, including their referenced Classes and Instances |
bool SCMOStreamer::deserialize() | bool SCMOStreamer::deserialize() |
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER,"SCMOStreamer::serialize"); |
PEG_METHOD_ENTER(TRC_DISPATCHER,"SCMOStreamer::deserialize"); |
| |
if(!_getClasses(_buf,_classTable)) | if(!_getClasses(_buf,_classTable)) |
{ | { |
|
|
const SCMOInstance& inst, | const SCMOInstance& inst, |
Uint32 idx) | Uint32 idx) |
{ | { |
SCMOResolutionTable tableEntry; |
SCMOResolutionTable tableEntry = { (Uint64)(void*)&inst, idx}; |
|
|
tableEntry.scmbptr = (void*)&inst; |
|
tableEntry.index = idx; |
|
|
|
_instResolverTable.append(tableEntry); | _instResolverTable.append(tableEntry); |
| |
// The number of elements in the array minus 1 is the index position | // The number of elements in the array minus 1 is the index position |
|
|
| |
| |
// Now build a new entry for the class resolution table | // Now build a new entry for the class resolution table |
SCMOResolutionTable tableEntry; |
SCMOResolutionTable tableEntry = {(Uint64)(void*)inst.inst.hdr, clsIdx}; |
|
|
tableEntry.scmbptr = (void*)inst.inst.hdr; |
|
tableEntry.index = clsIdx; |
|
|
|
_clsResolverTable.append(tableEntry); | _clsResolverTable.append(tableEntry); |
| |
// The number of elements in the array minus 1 is the index position | // The number of elements in the array minus 1 is the index position |
|
|
Uint32 SCMOStreamer::_appendToClassTable(const SCMOInstance& inst) | Uint32 SCMOStreamer::_appendToClassTable(const SCMOInstance& inst) |
{ | { |
Uint32 clsTableSize = _classTable.size(); | Uint32 clsTableSize = _classTable.size(); |
SCMBClass_Main* clsPtr = inst.inst.hdr->theClass->cls.hdr; |
SCMBClass_Main* clsPtr = inst.inst.hdr->theClass.ptr->cls.hdr; |
| |
const SCMBClass_Main* const* clsArray = _classTable.getData(); | const SCMBClass_Main* const* clsArray = _classTable.getData(); |
| |
|
|
fprintf(stderr,"INSTANCES:\n"); | fprintf(stderr,"INSTANCES:\n"); |
for (Uint32 x=0; x < _clsResolverTable.size(); x++) | for (Uint32 x=0; x < _clsResolverTable.size(); x++) |
{ | { |
fprintf(stderr,"\t[%2d] I = %p - cls = %2d\n", |
fprintf(stderr,"\t[%2d] I = %llx - cls = %2lld\n", |
x, | x, |
_clsResolverTable[x].scmbptr, | _clsResolverTable[x].scmbptr, |
_clsResolverTable[x].index); | _clsResolverTable[x].index); |
|
|
fprintf(stderr,"INSTANCE REFERENCES:\n"); | fprintf(stderr,"INSTANCE REFERENCES:\n"); |
for (Uint32 x=0; x < _instResolverTable.size(); x++) | for (Uint32 x=0; x < _instResolverTable.size(); x++) |
{ | { |
fprintf(stderr,"\t[%2d] R = %p - I = %2d\n", |
fprintf(stderr,"\t[%2d] R = %llx - I = %2lld\n", |
x, | x, |
_instResolverTable[x].scmbptr, | _instResolverTable[x].scmbptr, |
_instResolverTable[x].index); | _instResolverTable[x].index); |
|
|
out.putUint64(size); | out.putUint64(size); |
| |
// Write class data | // Write class data |
out.putBytes(clsArray[x],size); |
out.putBytes(clsArray[x],(size_t)size); |
} | } |
| |
} | } |
|
|
} | } |
| |
// Read class data | // Read class data |
SCMBClass_Main* scmbClassPtr = (SCMBClass_Main*)malloc(size); |
SCMBClass_Main* scmbClassPtr = (SCMBClass_Main*)malloc((size_t)size); |
if (0 == scmbClassPtr) | if (0 == scmbClassPtr) |
{ | { |
// Not enough memory! | // Not enough memory! |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
if (!in.getBytes(scmbClassPtr,size)) |
if (!in.getBytes(scmbClassPtr,(size_t)size)) |
{ | { |
return false; | return false; |
} | } |
|
|
_buf.putUint64(size); | _buf.putUint64(size); |
| |
// Write class data | // Write class data |
_buf.putBytes(instPtr,size); |
_buf.putBytes(instPtr,(size_t)size); |
} | } |
} | } |
| |
|
|
// updates without reallocation | // updates without reallocation |
| |
// Read instance data | // Read instance data |
SCMBInstance_Main* scmbInstPtr = (SCMBInstance_Main*)malloc(size+64); |
SCMBInstance_Main* scmbInstPtr = |
|
(SCMBInstance_Main*)malloc((size_t)size+64); |
if (0 == scmbInstPtr) | if (0 == scmbInstPtr) |
{ | { |
// Not enough memory! | // Not enough memory! |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
if(!_buf.getBytes(scmbInstPtr,size)) |
if(!_buf.getBytes(scmbInstPtr,(size_t)size)) |
{ | { |
return false; | return false; |
} | } |
|
|
scmbInstPtr->header.totalSize = size+64; | scmbInstPtr->header.totalSize = size+64; |
scmbInstPtr->header.freeBytes = 64; | scmbInstPtr->header.freeBytes = 64; |
scmbInstPtr->refCount.set(0); | scmbInstPtr->refCount.set(0); |
scmbInstPtr->theClass = |
scmbInstPtr->theClass.ptr = |
new SCMOClass((SCMBClass_Main*)clsArray[instArray[x].index]); | new SCMOClass((SCMBClass_Main*)clsArray[instArray[x].index]); |
| |
SCMOInstance* scmoInstPtr = new SCMOInstance(scmbInstPtr); | SCMOInstance* scmoInstPtr = new SCMOInstance(scmbInstPtr); |
|
|
} | } |
} | } |
| |
instArray[x].scmbptr = (void*)scmoInstPtr; |
instArray[x].scmbptr = (Uint64)(void*)scmoInstPtr; |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
_clsResolverTable.append(instArray[x]); | _clsResolverTable.append(instArray[x]); |