(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                 //%/////////////////////////////////////////////////////////////////////////////
 31                 
 32                 #ifndef Pegasus_SCMOStreamer_h
 33                 #define Pegasus_SCMOStreamer_h
 34                 
 35                 #include <Pegasus/Common/Config.h>
 36                 #include <Pegasus/Common/ArrayInternal.h>
 37                 #include <Pegasus/Common/SCMO.h>
 38                 #include <Pegasus/Common/SCMOInstance.h>
 39                 #include <Pegasus/Common/CIMBuffer.h>
 40                 #include <Pegasus/Common/Array.h>
 41                 
 42                 PEGASUS_NAMESPACE_BEGIN
 43 thilo.boehm 1.2 
 44                 
 45                 struct SCMOResolutionTable
 46                 {
 47                     // Though we really store a pointer here, it is stored as Uint64 to
 48                     // become independent from 64bit versus 32bit incarnations of the struct.
 49                     Uint64 scmbptr;
 50                     Uint32 index;
 51                 };
 52                 
 53                 #define PEGASUS_ARRAY_T SCMOResolutionTable
 54                 # include <Pegasus/Common/ArrayInter.h>
 55                 #undef PEGASUS_ARRAY_T
 56                 
 57                 
 58                 class PEGASUS_COMMON_LINKAGE SCMOStreamer
 59                 {
 60                 public:
 61                 
 62                     SCMOStreamer(CIMBuffer& out, Array<SCMOInstance>& x);
 63                 
 64 thilo.boehm 1.2     // Writes the list of SCMOInstances stored in this instance of SCMOStreamer
 65                     // to the output buffer, including their referenced Classes and Instances
 66                     void serialize();
 67                 
 68                     // Reads a list of SCMOInstances from the input buffer and stores them in
 69                     // this instance of SCMOStreamer, including their referenced Classes and
 70                     // Instances
 71                     bool deserialize();
 72                 
 73                     // Writes a single SCMOClass to the given CIMBuffer
 74                     static void serializeClass(CIMBuffer& out, const SCMOClass& scmoClass);
 75                 
 76                     // Reads a single SCMOClass from the given CIMBuffer
 77                     static bool deserializeClass(CIMBuffer& in, SCMOClass& scmoClass);
 78                 
 79                 private:
 80                 
 81                 
 82                 
 83                     // This function takes and instance and adds all of its external
 84                     // references (SCMOClass and SCMOInstances) to the index tables
 85 thilo.boehm 1.2     // For referenced SCMOInstances, the function recusively calls itself.
 86                     //
 87                     // Returns the index position at which the class for this instance was
 88                     // inserted in the class resolver table.
 89                     Uint32 _appendToResolverTables(const SCMOInstance& inst);
 90                 
 91                 
 92                     // This function adds the given instance to the instance resolver table,
 93                     // which stores the connections between instances and their external
 94                     // references.
 95                     //
 96                     // Returns the index position at which the instance was inserted in the
 97                     // instance resolver table.
 98                     Uint32 _appendToInstResolverTable(const SCMOInstance& inst, Uint32 idx);
 99                 
100                 
101                     // Adds an instance to the class resolution table.
102                     // Also adds the class to the class table when neccessary
103                     //
104                     // Returns the index position at which the instance was inserted in the
105                     // instance resolver table.
106 thilo.boehm 1.2     Uint32 _appendToClassResolverTable(const SCMOInstance& inst);
107                 
108                 
109                     // Add the SCMOClass for the given instance to the class table.
110                     // If the class already exists in the table, it returns the index position
111                     // for this class, otherwise appends the class at the end of the table
112                     // and returns the new index position of the class.
113                     Uint32 _appendToClassTable(const SCMOInstance& inst);
114                 
115                     static void _putClasses(CIMBuffer& out,Array<SCMBClass_Main*>& classTable);
116                     static bool _getClasses(CIMBuffer& in,Array<SCMBClass_Main*>& classTable);
117                     void _putInstances();
118                     bool _getInstances();
119                 
120                 
121                 #ifdef PEGASUS_DEBUG
122                     void _dumpTables();
123                 #endif
124                 
125                     // The Buffer for output streaming
126                     CIMBuffer& _buf;
127 thilo.boehm 1.2 
128                     // The array of SCMOInstances to be streamed
129                     Array<SCMOInstance>& _scmoInstances;
130                 
131                     // Counters for the total number of classes and scmo instances
132                     // to be streamed. These counters increase during streaming process.
133                     Uint32 _ttlNumInstances;
134                     Uint32 _ttlNumClasses;
135                 
136                     // Index table used to resolve the absolute pointers to SCMOClasses
137                     // to a relative sequence number (index) in the stream
138                     Array<SCMOResolutionTable> _clsResolverTable;
139                 
140                     // Index table used to resolve the absolute pointers to SCMOInstances
141                     // to a relative sequence number (index) in the stream
142                     Array<SCMOResolutionTable> _instResolverTable;
143                 
144                     // Table of pointers to SCMOClasses to be streamed
145                     Array<SCMBClass_Main*> _classTable;
146                 };
147                 
148 thilo.boehm 1.2 PEGASUS_NAMESPACE_END
149                 
150                 #endif /* Pegasus_SCMOStreamer_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2