(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.6 and 1.8

version 1.1.2.6, 2009/12/04 13:57:19 version 1.8, 2014/08/28 15:56:29
Line 27 
Line 27 
 // //
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
 // //
   // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
   // (Single Chunk Memory Objects).
   // The design document can be found on the OpenPegasus website openpegasus.org
   // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
   //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
Line 47 
Line 52 
  
 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)  
 { {
 }; };
  
Line 177 
Line 180 
 // Returns the index position at which the instance was inserted in the // Returns the index position at which the instance was inserted in the
 // instance resolver table. // instance resolver table.
 Uint32 SCMOStreamer::_appendToInstResolverTable( Uint32 SCMOStreamer::_appendToInstResolverTable(
     const SCMOInstance& inst,      SCMOInstance& inst,
     Uint32 idx)     Uint32 idx)
 { {
     SCMOResolutionTable tableEntry;     SCMOResolutionTable tableEntry;
       tableEntry.scmbptr.scmoInst = &inst;
     tableEntry.scmbptr = (Uint64)(void*)&inst;  
     tableEntry.index = idx;     tableEntry.index = idx;
  
     _instResolverTable.append(tableEntry);     _instResolverTable.append(tableEntry);
Line 207 
Line 209 
  
     // 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.scmbMain = inst.inst.hdr;
     tableEntry.scmbptr = (Uint64)(void*)inst.inst.hdr;  
     tableEntry.index = clsIdx;     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
Line 226 
Line 226 
 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();
  
Line 262 
Line 262 
     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.uint64,
                 _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.uint64,
                 _instResolverTable[x].index);                 _instResolverTable[x].index);
     }     }
     fprintf(stderr,"=====================================================\n");     fprintf(stderr,"=====================================================\n");
Line 301 
Line 301 
         out.putUint64(size);         out.putUint64(size);
  
         // Write class data         // Write class data
         out.putBytes(clsArray[x],size);          out.putBytes(clsArray[x],(size_t)size);
     }     }
  
 } }
Line 328 
Line 328 
         }         }
  
         // 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;
         }         }
Line 380 
Line 380 
     for (Uint32 x=0; x < numInst; x++)     for (Uint32 x=0; x < numInst; x++)
     {     {
         // Calculate the in-use size of the SCMOInstance data         // Calculate the in-use size of the SCMOInstance data
         SCMBInstance_Main* instPtr = (SCMBInstance_Main*)instArray[x].scmbptr;          SCMBInstance_Main* instPtr = instArray[x].scmbptr.scmbMain;
         Uint64 size = instPtr->header.totalSize - instPtr->header.freeBytes;         Uint64 size = instPtr->header.totalSize - instPtr->header.freeBytes;
         _buf.putUint64(size);         _buf.putUint64(size);
  
         // Write class data         // Write class data
         _buf.putBytes(instPtr,size);          _buf.putBytes(instPtr,(size_t)size);
     }     }
 } }
  
Line 418 
Line 418 
  
     // Instance references resolution table     // Instance references resolution table
     SCMOResolutionTable *extRefArray = new SCMOResolutionTable[numExtRefs];     SCMOResolutionTable *extRefArray = new SCMOResolutionTable[numExtRefs];
     Uint32 extRefIndex=0;  
     if (numExtRefs > 0)     if (numExtRefs > 0)
     {     {
         if(!_buf.getBytes(extRefArray, numExtRefs*sizeof(SCMOResolutionTable)))         if(!_buf.getBytes(extRefArray, numExtRefs*sizeof(SCMOResolutionTable)))
Line 443 
Line 442 
         // 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 459 
Line 459 
         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.scmoInst = scmoInstPtr;
   
   #ifdef PEGASUS_DEBUG
           _clsResolverTable.append(instArray[x]);
   #endif
       }
   
       // resolve all references in all instances
         if (numExtRefs > 0)         if (numExtRefs > 0)
         {         {
             // Handle the external references to other SCMOInstances          for (Uint32 x = 0; x < numInst; x++)
             Uint32 numExtRefs = scmoInstPtr->numberExtRef();  
             for (Uint32 i=0; i < numExtRefs; i++)  
             {             {
                 Uint32 extRefPos = extRefArray[extRefIndex].index;              SCMOInstance* inst = (SCMOInstance*)instArray[x].scmbptr.scmoInst;
                 SCMOInstance* extRefPtr =              // resolve all references in this instance
                     (SCMOInstance*)instArray[extRefPos].scmbptr;              for (Uint32 ref = 0; ref < inst->numberExtRef(); ref++)
                 scmoInstPtr->putExtRef(i,extRefPtr);              {
                   SCMOInstance* oldPtr = inst->getExtRef(ref);
                 // Mark instance as already consumed                  /* find the instance for given reference*/
                 instArray[extRefPos].scmbptr = 0;                  for (Uint32 y = 0; y < numExtRefs; y++)
                   {
                 extRefIndex++;                      if (extRefArray[y].scmbptr.scmoInst == oldPtr) {
                           Uint64 i = extRefArray[y].index;
                           SCMOInstance *newPtr = instArray[i].scmbptr.scmoInst;
                           inst->putExtRef(ref, newPtr);
                           // consume the instance
                           instArray[i].scmbptr.uint64 = 0;
                           break;
                       }
                   }
             }             }
         }         }
   
         instArray[x].scmbptr = (Uint64)(void*)scmoInstPtr;  
   
 #ifdef PEGASUS_DEBUG  
         _clsResolverTable.append(instArray[x]);  
 #endif  
     }     }
  
     // Append all non-referenced instances to output array     // Append all non-referenced instances to output array
     for (Uint32 x=0; x < numInst; x++)     for (Uint32 x=0; x < numInst; x++)
     {     {
         if (instArray[x].scmbptr)          if (0 != instArray[x].scmbptr.scmoInst)
         {         {
             _scmoInstances.append(*((SCMOInstance*)instArray[x].scmbptr));              _scmoInstances.append(*(instArray[x].scmbptr.scmoInst));
             delete (SCMOInstance*)instArray[x].scmbptr;              delete instArray[x].scmbptr.scmoInst;
         }         }
     }     }
     delete [] instArray;     delete [] instArray;


Legend:
Removed from v.1.1.2.6  
changed lines
  Added in v.1.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2