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

  1 thilo.boehm 1.2 //%LICENSE////////////////////////////////////////////////////////////////
  2                 //
  3                 // Licensed to The Open Group (TOG) under one or more contributor license
  4                 // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5                 // this work for additional information regarding copyright ownership.
  6                 // Each contributor licenses this file to you under the OpenPegasus Open
  7                 // Source License; you may not use this file except in compliance with the
  8                 // License.
  9                 //
 10                 // Permission is hereby granted, free of charge, to any person obtaining a
 11                 // copy of this software and associated documentation files (the "Software"),
 12                 // to deal in the Software without restriction, including without limitation
 13                 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14                 // and/or sell copies of the Software, and to permit persons to whom the
 15                 // Software is furnished to do so, subject to the following conditions:
 16                 //
 17                 // The above copyright notice and this permission notice shall be included
 18                 // in all copies or substantial portions of the Software.
 19                 //
 20                 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21                 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 thilo.boehm 1.2 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23                 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24                 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25                 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26                 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27                 //
 28                 //////////////////////////////////////////////////////////////////////////
 29                 //
 30 karl        1.3.4.1 // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
 31                     // (Single Chunk Memory Objects).
 32                     // The design document can be found on the OpenPegasus website openpegasus.org
 33                     // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
 34                     //
 35 thilo.boehm 1.2     //%/////////////////////////////////////////////////////////////////////////////
 36                     
 37                     #ifndef Pegasus_SCMOStreamer_h
 38                     #define Pegasus_SCMOStreamer_h
 39                     
 40                     #include <Pegasus/Common/Config.h>
 41                     #include <Pegasus/Common/ArrayInternal.h>
 42                     #include <Pegasus/Common/SCMO.h>
 43                     #include <Pegasus/Common/SCMOInstance.h>
 44                     #include <Pegasus/Common/CIMBuffer.h>
 45                     #include <Pegasus/Common/Array.h>
 46                     
 47                     PEGASUS_NAMESPACE_BEGIN
 48                     
 49                     
 50                     struct SCMOResolutionTable
 51                     {
 52 karl        1.3.4.1     // Though we only store pointers here, it is stored as union of size 64bit
 53                         // to become independent from 64bit versus 32bit incarnations of the struct.
 54                         union
 55                         {
 56                             Uint64 uint64;
 57                             SCMOInstance* scmoInst;
 58                             SCMBInstance_Main * scmbMain;
 59                         } scmbptr;
 60                     
 61 sahana.prabhakar 1.3         Uint64 index;
 62 thilo.boehm      1.2     };
 63                          
 64                          #define PEGASUS_ARRAY_T SCMOResolutionTable
 65                          # include <Pegasus/Common/ArrayInter.h>
 66                          #undef PEGASUS_ARRAY_T
 67                          
 68                          
 69                          class PEGASUS_COMMON_LINKAGE SCMOStreamer
 70                          {
 71                          public:
 72                          
 73                              SCMOStreamer(CIMBuffer& out, Array<SCMOInstance>& x);
 74                          
 75                              // Writes the list of SCMOInstances stored in this instance of SCMOStreamer
 76                              // to the output buffer, including their referenced Classes and Instances
 77                              void serialize();
 78                          
 79                              // Reads a list of SCMOInstances from the input buffer and stores them in
 80                              // this instance of SCMOStreamer, including their referenced Classes and
 81                              // Instances
 82                              bool deserialize();
 83 thilo.boehm      1.2     
 84                              // Writes a single SCMOClass to the given CIMBuffer
 85                              static void serializeClass(CIMBuffer& out, const SCMOClass& scmoClass);
 86                          
 87                              // Reads a single SCMOClass from the given CIMBuffer
 88                              static bool deserializeClass(CIMBuffer& in, SCMOClass& scmoClass);
 89                          
 90                          private:
 91                          
 92                          
 93                          
 94                              // This function takes and instance and adds all of its external
 95                              // references (SCMOClass and SCMOInstances) to the index tables
 96                              // For referenced SCMOInstances, the function recusively calls itself.
 97                              //
 98                              // Returns the index position at which the class for this instance was
 99                              // inserted in the class resolver table.
100                              Uint32 _appendToResolverTables(const SCMOInstance& inst);
101                          
102                          
103                              // This function adds the given instance to the instance resolver table,
104 thilo.boehm      1.2         // which stores the connections between instances and their external
105                              // references.
106                              //
107                              // Returns the index position at which the instance was inserted in the
108                              // instance resolver table.
109 karl             1.3.4.1     Uint32 _appendToInstResolverTable(SCMOInstance& inst, Uint32 idx);
110 thilo.boehm      1.2     
111                          
112                              // Adds an instance to the class resolution table.
113                              // Also adds the class to the class table when neccessary
114                              //
115                              // Returns the index position at which the instance was inserted in the
116                              // instance resolver table.
117                              Uint32 _appendToClassResolverTable(const SCMOInstance& inst);
118                          
119                          
120                              // Add the SCMOClass for the given instance to the class table.
121                              // If the class already exists in the table, it returns the index position
122                              // for this class, otherwise appends the class at the end of the table
123                              // and returns the new index position of the class.
124                              Uint32 _appendToClassTable(const SCMOInstance& inst);
125                          
126                              static void _putClasses(CIMBuffer& out,Array<SCMBClass_Main*>& classTable);
127                              static bool _getClasses(CIMBuffer& in,Array<SCMBClass_Main*>& classTable);
128                              void _putInstances();
129                              bool _getInstances();
130                          
131 thilo.boehm      1.2     
132                          #ifdef PEGASUS_DEBUG
133                              void _dumpTables();
134                          #endif
135                          
136                              // The Buffer for output streaming
137                              CIMBuffer& _buf;
138                          
139                              // The array of SCMOInstances to be streamed
140                              Array<SCMOInstance>& _scmoInstances;
141                          
142                              // Index table used to resolve the absolute pointers to SCMOClasses
143                              // to a relative sequence number (index) in the stream
144                              Array<SCMOResolutionTable> _clsResolverTable;
145                          
146                              // Index table used to resolve the absolute pointers to SCMOInstances
147                              // to a relative sequence number (index) in the stream
148                              Array<SCMOResolutionTable> _instResolverTable;
149                          
150                              // Table of pointers to SCMOClasses to be streamed
151                              Array<SCMBClass_Main*> _classTable;
152 thilo.boehm      1.2     };
153                          
154                          PEGASUS_NAMESPACE_END
155                          
156                          #endif /* Pegasus_SCMOStreamer_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2