(file) Return to SCMOStreamer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/SCMOStreamer.cpp between version 1.1.2.4 and 1.1.2.8

version 1.1.2.4, 2009/11/18 09:30:44 version 1.1.2.8, 2009/12/10 11:32:44
Line 53 
Line 53 
 { {
 }; };
  
   // Writes a single SCMOClass to the given CIMBuffer
   void SCMOStreamer::serializeClass(CIMBuffer& out, const SCMOClass& scmoClass)
   {
       PEG_METHOD_ENTER(TRC_DISPATCHER,"SCMOStreamer::serializeClass");
   
       Array<SCMBClass_Main*> classTable;
       classTable.append(scmoClass.cls.hdr);
   
       _putClasses(out, classTable);
   
       PEG_METHOD_EXIT();
   };
   
   // Reads a single SCMOClass from the given CIMBuffer
   bool SCMOStreamer::deserializeClass(CIMBuffer& in, SCMOClass& scmoClass)
   {
       PEG_METHOD_ENTER(TRC_DISPATCHER,"SCMOStreamer::deserializeClass");
   
       Array<SCMBClass_Main*> classTable;
       if(!_getClasses(in, classTable))
       {
           PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
               "Failed to get Class!");
           PEG_METHOD_EXIT();
           return false;
       }
   
       if (classTable.size() > 0)
       {
           scmoClass = SCMOClass(classTable[0]);
       }
   
       PEG_METHOD_EXIT();
       return true;
   };
  
 // Writes the list of SCMOInstances stored in this instance of SCMOStreamer // Writes the list of SCMOInstances stored in this instance of SCMOStreamer
 // to the output buffer, including their referenced Classes and Instances // to the output buffer, including their referenced Classes and Instances
Line 74 
Line 109 
         _appendToResolverTables(inst);         _appendToResolverTables(inst);
     }     }
  
     _putClasses();      _putClasses(_buf,_classTable);
  
     _putInstances();     _putInstances();
  
Line 87 
Line 122 
 // 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())      if(!_getClasses(_buf,_classTable))
     {     {
         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
             "Failed to get Classes!");             "Failed to get Classes!");
Line 147 
Line 182 
 { {
     SCMOResolutionTable tableEntry;     SCMOResolutionTable tableEntry;
  
     tableEntry.scmbptr = (void*)&inst;      tableEntry.scmbptr = (Uint64)(void*)&inst;
     tableEntry.index = idx;     tableEntry.index = idx;
  
     _instResolverTable.append(tableEntry);     _instResolverTable.append(tableEntry);
Line 173 
Line 208 
     // Now build a new entry for the class resolution table     // Now build a new entry for the class resolution table
     SCMOResolutionTable tableEntry;     SCMOResolutionTable tableEntry;
  
     tableEntry.scmbptr = (void*)inst.inst.hdr;      tableEntry.scmbptr = (Uint64)(void*)inst.inst.hdr;
     tableEntry.index = clsIdx;     tableEntry.index = clsIdx;
  
     _clsResolverTable.append(tableEntry);     _clsResolverTable.append(tableEntry);
Line 191 
Line 226 
 Uint32 SCMOStreamer::_appendToClassTable(const SCMOInstance& inst) Uint32 SCMOStreamer::_appendToClassTable(const SCMOInstance& inst)
 { {
     Uint32 clsTableSize = _classTable.size();     Uint32 clsTableSize = _classTable.size();
     const 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();
  
Line 247 
Line 282 
  
  
 // Adds the list of SCMOClasses from the ClassTable to the output buffer // Adds the list of SCMOClasses from the ClassTable to the output buffer
 void SCMOStreamer::_putClasses()  void SCMOStreamer::_putClasses(
       CIMBuffer& out,
       Array<SCMBClass_Main*>& classTable)
 { {
     Uint32 numClasses = _classTable.size();      Uint32 numClasses = classTable.size();
     const SCMBClass_Main* const* clsArray = _classTable.getData();      const SCMBClass_Main* const* clsArray = classTable.getData();
  
     // Number of classes     // Number of classes
     _buf.putUint32(numClasses);      out.putUint32(numClasses);
  
     // SCMOClasses, one by one     // SCMOClasses, one by one
     for (Uint32 x=0; x < numClasses; x++)     for (Uint32 x=0; x < numClasses; x++)
Line 261 
Line 298 
         // Calculate the in-use size of the SCMOClass data         // Calculate the in-use size of the SCMOClass data
         Uint64 size =         Uint64 size =
             clsArray[x]->header.totalSize - clsArray[x]->header.freeBytes;             clsArray[x]->header.totalSize - clsArray[x]->header.freeBytes;
         _buf.putUint64(size);          out.putUint64(size);
  
         // Write class data         // Write class data
         _buf.putBytes(clsArray[x],size);          out.putBytes(clsArray[x],(size_t)size);
     }     }
  
 } }
  
 // Reads a list of SCMOClasses from the input buffer // Reads a list of SCMOClasses from the input buffer
 bool SCMOStreamer::_getClasses()  bool SCMOStreamer::_getClasses(
       CIMBuffer& in,
       Array<SCMBClass_Main*>& classTable)
 { {
     // Number of classes     // Number of classes
     Uint32 numClasses;     Uint32 numClasses;
     if(! _buf.getUint32(numClasses) )      if(! in.getUint32(numClasses) )
     {     {
         return false;         return false;
     }     }
Line 283 
Line 322 
     for (Uint32 x=0; x < numClasses; x++)     for (Uint32 x=0; x < numClasses; x++)
     {     {
         Uint64 size;         Uint64 size;
         if (!_buf.getUint64(size))          if (!in.getUint64(size))
         {         {
             return false;             return false;
         }         }
  
         // 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 (!_buf.getBytes(scmbClassPtr,size))          if (!in.getBytes(scmbClassPtr,(size_t)size))
         {         {
             return false;             return false;
         }         }
Line 307 
Line 346 
         scmbClassPtr->header.freeBytes = 0;         scmbClassPtr->header.freeBytes = 0;
         scmbClassPtr->refCount.set(0);         scmbClassPtr->refCount.set(0);
  
         _classTable.append(scmbClassPtr);          classTable.append(scmbClassPtr);
     }     }
  
     return true;     return true;
Line 346 
Line 385 
         _buf.putUint64(size);         _buf.putUint64(size);
  
         // Write class data         // Write class data
         _buf.putBytes(instPtr,size);          _buf.putBytes(instPtr,(size_t)size);
     }     }
 } }
  
Line 404 
Line 443 
         // 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;
         }         }
Line 420 
Line 460 
         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);
Line 443 
Line 483 
             }             }
         }         }
  
         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]);


Legend:
Removed from v.1.1.2.4  
changed lines
  Added in v.1.1.2.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2