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