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

  1 karl  1.12 //%2005////////////////////////////////////////////////////////////////////////
  2 schuur 1.1  //
  3 karl   1.9  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 schuur 1.1  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl   1.9  // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl   1.12 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 schuur 1.1  //
 12             // Permission is hereby granted, free of charge, to any person obtaining a copy
 13             // of this software and associated documentation files (the "Software"), to
 14             // deal in the Software without restriction, including without limitation the
 15             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16             // sell copies of the Software, and to permit persons to whom the Software is
 17             // furnished to do so, subject to the following conditions:
 18 karl   1.9  // 
 19 schuur 1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20             // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22             // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25             // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27             //
 28             //==============================================================================
 29             //
 30             // Author: Adrian Schuur (schuur@de.ibm.com) - PEP 164
 31             //
 32 jim.wunderlich 1.21 // Modified By: 
 33                     //     Dave Sudlik (dsudlik@us.ibm.com)
 34                     //     David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
 35                     //     Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3666
 36                     //     Michael Brasher (mike-brasher@austin.rr.com)
 37 mike           1.26 //     Mike Brasher, Inova Europe (mike-brasher@austin.rr.com)
 38 schuur         1.1  //
 39                     //%/////////////////////////////////////////////////////////////////////////////
 40                     
 41                     #include "XmlWriter.h"
 42                     #include "XmlReader.h"
 43                     #include "XmlParser.h"
 44                     #include "CIMName.h"
 45 r.kieninger    1.27 #include "CIMNameUnchecked.h"
 46 schuur         1.1  #include "BinaryStreamer.h"
 47                     #include "CIMClassRep.h"
 48                     #include "CIMInstanceRep.h"
 49                     #include "CIMMethodRep.h"
 50                     #include "CIMParameterRep.h"
 51                     #include "CIMPropertyRep.h"
 52                     #include "CIMQualifierRep.h"
 53                     #include "CIMValue.h"
 54                     #include "CIMValueRep.h"
 55 jim.wunderlich 1.21 #include "Packer.h"
 56                     
 57                     #define MAGIC_BYTE Uint8(0x11)
 58                     #define VERSION_NUMBER Uint8(1)
 59 schuur         1.1  
 60                     PEGASUS_USING_STD;
 61                     
 62                     PEGASUS_NAMESPACE_BEGIN
 63                     
 64 jim.wunderlich 1.21 enum BinaryObjectType
 65                     {
 66                         BINARY_CLASS,
 67                         BINARY_INSTANCE,
 68 jim.wunderlich 1.22     BINARY_QUALIFIER_DECL
 69 jim.wunderlich 1.21 };
 70 konrad.r       1.8  
 71 mike           1.24 static inline void _packMagicByte(Buffer& out)
 72 schuur         1.1  {
 73 jim.wunderlich 1.21     Packer::packUint8(out, MAGIC_BYTE);
 74 schuur         1.1  }
 75                     
 76 mike           1.24 static void _checkMagicByte(const Buffer& in, Uint32& pos)
 77 schuur         1.1  {
 78 jim.wunderlich 1.21     Uint8 magicByte;
 79                         Packer::unpackUint8(in, pos, magicByte);
 80                     
 81                         if (magicByte != MAGIC_BYTE)
 82                     	throw BinException("Bad magic byte");
 83 schuur         1.1  }
 84                     
 85 jim.wunderlich 1.21 struct Header
 86                     {
 87                         // A version number for this message.
 88                         Uint8 versionNumber;
 89                     
 90                         // The object type (see BinaryObjectType enum).
 91                         Uint8 objectType; 
 92                     };
 93                     
 94 mike           1.24 static void _packHeader(Buffer& out, Uint8 objectType)
 95 schuur         1.1  {
 96 jim.wunderlich 1.21     Packer::packUint8(out, VERSION_NUMBER);
 97                         Packer::packUint8(out, objectType);
 98 schuur         1.1  }
 99                     
100 jim.wunderlich 1.21 static void _checkHeader(
101 mike           1.24     const Buffer& in, Uint32& pos, Uint8 expectedObjectType)
102 schuur         1.1  {
103 jim.wunderlich 1.21     Header header;
104                         Packer::unpackUint8(in, pos, header.versionNumber);
105                         Packer::unpackUint8(in, pos, header.objectType);
106                     
107                         if (header.objectType != expectedObjectType)
108                     	throw BinException("Unexpected object type");
109                     
110                         if (header.versionNumber != VERSION_NUMBER)
111                     	throw BinException("Unsupported version");
112 schuur         1.1  }
113                     
114 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Boolean& x)
115 schuur         1.1  {
116 jim.wunderlich 1.21     Packer::unpackBoolean(in, pos, x);
117 schuur         1.1  }
118                     
119 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Uint8& x)
120 schuur         1.1  {
121 jim.wunderlich 1.21     Packer::unpackUint8(in, pos, x);
122 schuur         1.1  }
123                     
124 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Sint8& x)
125 jim.wunderlich 1.21 {
126                         Packer::unpackUint8(in, pos, (Uint8&)x);
127                     }
128 schuur         1.1  
129 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Uint16& x)
130 jim.wunderlich 1.21 {
131                         Packer::unpackUint16(in, pos, x);
132                     }
133 schuur         1.1  
134 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Sint16& x)
135 schuur         1.1  {
136 jim.wunderlich 1.21     Packer::unpackUint16(in, pos, (Uint16&)x);
137 schuur         1.1  }
138                     
139 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Uint32& x)
140 schuur         1.1  {
141 jim.wunderlich 1.21     Packer::unpackUint32(in, pos, x);
142 schuur         1.1  }
143                     
144 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Sint32& x)
145 schuur         1.1  {
146 jim.wunderlich 1.21     Packer::unpackUint32(in, pos, (Uint32&)x);
147 schuur         1.1  }
148                     
149 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Uint64& x)
150 schuur         1.1  {
151 jim.wunderlich 1.21     Packer::unpackUint64(in, pos, x);
152 schuur         1.1  }
153                     
154 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Sint64& x)
155 schuur         1.1  {
156 jim.wunderlich 1.21     Packer::unpackUint64(in, pos, (Uint64&)x);
157 schuur         1.1  }
158                     
159 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Real32& x)
160 schuur         1.1  {
161 jim.wunderlich 1.21     Packer::unpackReal32(in, pos, x);
162 schuur         1.1  }
163                     
164 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Real64& x)
165 jim.wunderlich 1.21 {
166                         Packer::unpackReal64(in, pos, x);
167                     }
168 schuur         1.1  
169 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, Char16& x)
170 jim.wunderlich 1.21 {
171                         Packer::unpackChar16(in, pos, x);
172                     }
173 schuur         1.1  
174 mike           1.24 inline void _unpack(const Buffer& in, Uint32& pos, String& x)
175 schuur         1.1  {
176 jim.wunderlich 1.21     Packer::unpackString(in, pos, x);
177                     }
178 konrad.r       1.5  
179 mike           1.24 void _unpack(const Buffer& in, Uint32& pos, CIMDateTime& x)
180 jim.wunderlich 1.21 {
181                         String tmp;
182                         Packer::unpackString(in, pos, tmp);
183                         x.set(tmp);
184 schuur         1.1  }
185                     
186 mike           1.24 void _unpack(const Buffer& in, Uint32& pos, CIMObjectPath& x)
187 schuur         1.1  {
188 jim.wunderlich 1.21     String tmp;
189                         Packer::unpackString(in, pos, tmp);
190                         x.set(tmp);
191 schuur         1.1  }
192                     
193 jim.wunderlich 1.21 template<class T>
194                     struct UnpackArray
195                     {
196                         static void func(
197 mike           1.24 	const Buffer& in, Uint32& pos, size_t n, CIMValue& value)
198 jim.wunderlich 1.21     {
199                     	Array<T> array;
200                     	array.reserveCapacity(n);
201                     
202                     	for (size_t i = 0; i < n; i++)
203                     	{
204                     	    T tmp;
205                     	    _unpack(in, pos, tmp);
206                     	    array.append(tmp);
207                     	}
208                     
209                     	value.set(array);
210                         }
211                     };
212                     
213                     template<class T>
214                     struct UnpackScalar
215 schuur         1.1  {
216 jim.wunderlich 1.21     static void func(
217 mike           1.24 	const Buffer& in, Uint32& pos, CIMValue& value)
218 jim.wunderlich 1.21     {
219                     	T tmp;
220                     	_unpack(in, pos, tmp);
221                     	value.set(tmp);
222                         }
223                     };
224                     
225                     template<class OBJECT>
226                     struct UnpackQualifiers
227                     {
228 mike           1.24     static void func(const Buffer& in, Uint32& pos, OBJECT& x)
229 jim.wunderlich 1.21     {
230                     	Uint32 n;
231                     	Packer::unpackSize(in, pos, n);
232                     
233                     	CIMQualifier q;
234                     
235                     	for (size_t i = 0; i < n; i++)
236                     	{
237                     	    BinaryStreamer::_unpackQualifier(in, pos, q);
238                     	    x.addQualifier(q);
239                     	}
240                         }
241                     };
242                     
243                     template<class REP>
244                     struct PackQualifiers
245                     {
246 mike           1.24     static void func(Buffer& out, REP* rep)
247 jim.wunderlich 1.21     {
248                     	Uint32 n = rep->getQualifierCount();
249                     	Packer::packSize(out, n);
250                     
251                     	for (Uint32 i = 0; i < n; i++)
252                     	    BinaryStreamer::_packQualifier(out, rep->getQualifier(i));
253                         }
254                     };
255                     
256                     template<class OBJECT>
257                     struct UnpackProperties
258                     {
259 mike           1.24     static void func(const Buffer& in, Uint32& pos, OBJECT& x)
260 jim.wunderlich 1.21     {
261                     	Uint32 n;
262                     	Packer::unpackSize(in, pos, n);
263                     
264                     	CIMProperty p;
265                     
266                     	for (size_t i = 0; i < n; i++)
267                     	{
268                     	    BinaryStreamer::_unpackProperty(in, pos, p);
269                     	    x.addProperty(p);
270                     	}
271                         }
272                     };
273                     
274                     template<class OBJECT>
275                     struct UnpackMethods
276                     {
277 mike           1.24     static void func(const Buffer& in, Uint32& pos, OBJECT& x)
278 jim.wunderlich 1.21     {
279                     	Uint32 n;
280                     	Packer::unpackSize(in, pos, n);
281                     
282                     	CIMMethod m;
283                     
284                     	for (size_t i = 0; i < n; i++)
285                     	{
286                     	    BinaryStreamer::_unpackMethod(in, pos, m);
287                     	    x.addMethod(m);
288                     	}
289                         }
290                     };
291                     
292 mike           1.24 void BinaryStreamer::_packName(Buffer& out, const CIMName& x)
293 jim.wunderlich 1.21 {
294                         Packer::packString(out, x.getString());
295 schuur         1.1  }
296                     
297 jim.wunderlich 1.21 void BinaryStreamer::_unpackName(
298 mike           1.24     const Buffer& in, Uint32& pos, CIMName& x)
299 schuur         1.1  {
300 jim.wunderlich 1.21     String tmp;
301                         Packer::unpackString(in, pos, tmp);
302 r.kieninger    1.27     x = tmp.size() ? CIMNameUnchecked(tmp) : CIMName();
303 schuur         1.1  }
304                     
305 mike           1.24 void BinaryStreamer::_packQualifier(Buffer& out, const CIMQualifier& x)
306 schuur         1.1  {
307 jim.wunderlich 1.21     CIMQualifierRep* rep = x._rep;
308                     
309                         _packMagicByte(out);
310                         _packName(out, rep->getName());
311                         _packValue(out, rep->getValue());
312                         _packFlavor(out, rep->getFlavor());
313                         Packer::packBoolean(out, rep->getPropagated());
314 schuur         1.1  }
315                     
316 jim.wunderlich 1.21 void BinaryStreamer::_unpackQualifier(
317 mike           1.24     const Buffer& in, Uint32& pos, CIMQualifier& x)
318 schuur         1.1  {
319 jim.wunderlich 1.21     _checkMagicByte(in, pos);
320                     
321                         CIMName name;
322                         _unpackName(in, pos, name);
323                     
324                         CIMValue value;
325                         _unpackValue(in, pos, value);
326                     
327                         CIMFlavor flavor;
328                         BinaryStreamer::_unpackFlavor(in, pos, flavor);
329                     
330                         Boolean propagated;
331                         Packer::unpackBoolean(in, pos, propagated);
332                     
333                         x = CIMQualifier(name, value, flavor, propagated);
334 schuur         1.1  }
335                     
336 mike           1.24 void BinaryStreamer::_packValue(Buffer& out, const CIMValue& x)
337 jim.wunderlich 1.21 {
338                         CIMValueRep* rep = x._rep;
339                     
340                         _packMagicByte(out);
341                         _packType(out, x.getType());
342                         Packer::packBoolean(out, x.isArray());
343                     
344                         Uint32 n = x.getArraySize();
345 schuur         1.1  
346 jim.wunderlich 1.21     if (x.isArray())
347                     	Packer::packSize(out, n);
348 schuur         1.1  
349 jim.wunderlich 1.21     Packer::packBoolean(out, x.isNull());
350 schuur         1.1  
351 jim.wunderlich 1.21     if (x.isNull())
352                     	return;
353                     
354                         if (x.isArray())
355                         {
356                     	switch (x.getType()) 
357                     	{
358                     	    case CIMTYPE_BOOLEAN:
359 mike           1.26 		Packer::packBoolean(
360                     		    out, CIMValueType<Boolean>::aref(rep).getData(), n);
361 jim.wunderlich 1.21 		break;
362                     
363                     	    case CIMTYPE_SINT8:
364                     	    case CIMTYPE_UINT8:
365 mike           1.26 		Packer::packUint8(
366                     		    out, CIMValueType<Uint8>::aref(rep).getData(), n);
367 jim.wunderlich 1.21 		break;
368                     
369                     	    case CIMTYPE_SINT16:
370                     	    case CIMTYPE_UINT16:
371                     	    case CIMTYPE_CHAR16:
372 mike           1.26 		Packer::packUint16(
373                     		    out, CIMValueType<Uint16>::aref(rep).getData(), n);
374 jim.wunderlich 1.21 		break;
375 schuur         1.1  
376 jim.wunderlich 1.21 	    case CIMTYPE_SINT32:
377                     	    case CIMTYPE_UINT32:
378                     	    case CIMTYPE_REAL32:
379 mike           1.26 		Packer::packUint32(
380                     		    out, CIMValueType<Uint32>::aref(rep).getData(), n);
381 jim.wunderlich 1.21 		break;
382 schuur         1.1  
383 jim.wunderlich 1.21 	    case CIMTYPE_SINT64:
384                     	    case CIMTYPE_UINT64:
385                     	    case CIMTYPE_REAL64:
386 mike           1.26 		Packer::packUint64(
387                     		    out, CIMValueType<Uint64>::aref(rep).getData(), n);
388 jim.wunderlich 1.21 		break;
389 schuur         1.1  
390 jim.wunderlich 1.21 	    case CIMTYPE_STRING:
391 mike           1.25 		Packer::packString(out, 
392 mike           1.26 		    CIMValueType<String>::aref(rep).getData(), n);
393 jim.wunderlich 1.21 		break;
394 schuur         1.1  
395 jim.wunderlich 1.21 	    case CIMTYPE_DATETIME:
396                     	    {
397 mike           1.26 		const Array<CIMDateTime>& a = 
398                     		    CIMValueType<CIMDateTime>::aref(rep);
399                     
400 jim.wunderlich 1.21 		for (Uint32 i = 0; i < n; i++) 
401 mike           1.26 		    Packer::packString(out, a[i].toString());
402 jim.wunderlich 1.21 		break;
403                     	    }
404 schuur         1.1  
405 jim.wunderlich 1.21 	    case CIMTYPE_REFERENCE:
406                     	    {
407 mike           1.26 		const Array<CIMObjectPath>& a = 
408                     		    CIMValueType<CIMObjectPath>::aref(rep);
409                     
410 jim.wunderlich 1.21 		for (Uint32 i = 0; i < n; i++) 
411 mike           1.26 		    Packer::packString(out, a[i].toString());
412 jim.wunderlich 1.21 		break;
413                     	    }
414 schuur         1.1  
415 jim.wunderlich 1.21 	    case CIMTYPE_OBJECT:
416                     		break;
417                     	}
418                         }
419                         else
420                         {
421                     	switch (x.getType()) 
422                     	{
423                     	    case CIMTYPE_BOOLEAN:
424 mike           1.26 		Packer::packBoolean(out, rep->u._booleanValue);
425 jim.wunderlich 1.21 		break;
426                     
427                     	    case CIMTYPE_SINT8:
428                     	    case CIMTYPE_UINT8:
429 mike           1.26 		Packer::packUint8(out, rep->u._uint8Value);
430 jim.wunderlich 1.21 		break;
431                     
432                     	    case CIMTYPE_SINT16:
433                     	    case CIMTYPE_UINT16:
434                     	    case CIMTYPE_CHAR16:
435 mike           1.26 		Packer::packUint16(out, rep->u._uint16Value);
436 jim.wunderlich 1.21 		break;
437                     
438                     	    case CIMTYPE_SINT32:
439                     	    case CIMTYPE_UINT32:
440                     	    case CIMTYPE_REAL32:
441 mike           1.26 		Packer::packUint32(out, rep->u._uint32Value);
442 jim.wunderlich 1.21 		break;
443                     
444                     	    case CIMTYPE_SINT64:
445                     	    case CIMTYPE_UINT64:
446                     	    case CIMTYPE_REAL64:
447 mike           1.26 		Packer::packUint64(out, rep->u._uint64Value);
448 jim.wunderlich 1.21 		break;
449                     
450                     	    case CIMTYPE_STRING:
451 mike           1.26 		Packer::packString(out, CIMValueType<String>::ref(rep));
452 jim.wunderlich 1.21 		break;
453                     
454                     	    case CIMTYPE_DATETIME:
455 mike           1.26 		Packer::packString(
456                     		    out, CIMValueType<CIMDateTime>::ref(rep).toString());
457 jim.wunderlich 1.21 		break;
458                     
459                     	    case CIMTYPE_REFERENCE:
460 mike           1.26 		Packer::packString(
461                     		    out, CIMValueType<CIMObjectPath>::ref(rep).toString());
462 jim.wunderlich 1.21 		break;
463                     
464                     	    case CIMTYPE_OBJECT:
465                     		break;
466                     	}
467                         }
468 schuur         1.1  }
469                     
470 jim.wunderlich 1.21 void BinaryStreamer::_unpackValue(
471 mike           1.24     const Buffer& in, Uint32& pos, CIMValue& x)
472 jim.wunderlich 1.21 {
473                         _checkMagicByte(in, pos);
474                     
475                         CIMType type;
476                         _unpackType(in, pos, type);
477                     
478                         Boolean isArray;
479                         Packer::unpackBoolean(in, pos, isArray);
480 schuur         1.1  
481 jim.wunderlich 1.23     Uint32 arraySize = 0;
482 konrad.r       1.8  
483 jim.wunderlich 1.21     if (isArray)
484                     	Packer::unpackSize(in, pos, arraySize);
485 schuur         1.1  
486 jim.wunderlich 1.21     Boolean isNull;
487                         Packer::unpackBoolean(in, pos, isNull);
488 schuur         1.1  
489 jim.wunderlich 1.21     if (isNull)
490                         {
491                     	x = CIMValue(type, isArray, arraySize);
492                     	return;
493                         }
494 schuur         1.1  
495 jim.wunderlich 1.21     if (isArray)
496                         {
497                     	CIMValue cimValue(type, isArray, arraySize);
498                     
499                     	switch (type) 
500                     	{
501                     	    case CIMTYPE_BOOLEAN:
502                     		UnpackArray<Boolean>::func(in, pos, arraySize, cimValue);
503                     		break;
504                     
505                     	    case CIMTYPE_UINT8:
506                     		UnpackArray<Uint8>::func(in, pos, arraySize, cimValue);
507                     		break;
508                     
509                     	    case CIMTYPE_SINT8:
510                     		UnpackArray<Sint8>::func(in, pos, arraySize, cimValue);
511                     		break;
512                     
513                     	    case CIMTYPE_UINT16:
514                     		UnpackArray<Uint16>::func(in, pos, arraySize, cimValue);
515                     		break;
516 jim.wunderlich 1.21 
517                     	    case CIMTYPE_SINT16:
518                     		UnpackArray<Sint16>::func(in, pos, arraySize, cimValue);
519                     		break;
520                     
521                     	    case CIMTYPE_UINT32:
522                     		UnpackArray<Uint32>::func(in, pos, arraySize, cimValue);
523                     		break;
524                     
525                     	    case CIMTYPE_SINT32:
526                     		UnpackArray<Sint32>::func(in, pos, arraySize, cimValue);
527                     		break;
528                     
529                     	    case CIMTYPE_UINT64:
530                     		UnpackArray<Uint64>::func(in, pos, arraySize, cimValue);
531                     		break;
532                     
533                     	    case CIMTYPE_SINT64:
534                     		UnpackArray<Sint64>::func(in, pos, arraySize, cimValue);
535                     		break;
536                     
537 jim.wunderlich 1.21 	    case CIMTYPE_REAL32:
538                     		UnpackArray<Real32>::func(in, pos, arraySize, cimValue);
539                     		break;
540                     
541                     	    case CIMTYPE_REAL64:
542                     		UnpackArray<Real64>::func(in, pos, arraySize, cimValue);
543                     		break;
544                     
545                     	    case CIMTYPE_CHAR16:
546                     		UnpackArray<Char16>::func(in, pos, arraySize, cimValue);
547                     		break;
548                     
549                     	    case CIMTYPE_STRING:
550                     		UnpackArray<String>::func(in, pos, arraySize, cimValue);
551                     		break;
552                     
553                     	    case CIMTYPE_DATETIME:
554                     		UnpackArray<CIMDateTime>::func(in, pos, arraySize, cimValue);
555                     		break;
556                     
557                     	    case CIMTYPE_REFERENCE:
558 jim.wunderlich 1.21 		UnpackArray<CIMObjectPath>::func(in, pos, arraySize, cimValue);
559                     		break;
560                     
561                     	    case CIMTYPE_OBJECT:
562                     		break;
563                     	}
564 schuur         1.1  
565 jim.wunderlich 1.21 	x = cimValue;
566                         }
567                         else
568                         {
569                     	CIMValue cimValue(type, isArray);
570                     
571                     	switch (type) 
572                     	{
573                     	    case CIMTYPE_BOOLEAN:
574                     		UnpackScalar<Boolean>::func(in, pos, cimValue);
575                     		break;
576                     
577                     	    case CIMTYPE_UINT8:
578                     		UnpackScalar<Uint8>::func(in, pos, cimValue);
579                     		break;
580                     
581                     	    case CIMTYPE_SINT8:
582                     		UnpackScalar<Sint8>::func(in, pos, cimValue);
583                     		break;
584                     
585                     	    case CIMTYPE_UINT16:
586 jim.wunderlich 1.21 		UnpackScalar<Uint16>::func(in, pos, cimValue);
587                     		break;
588                     
589                     	    case CIMTYPE_SINT16:
590                     		UnpackScalar<Sint16>::func(in, pos, cimValue);
591                     		break;
592                     
593                     	    case CIMTYPE_UINT32:
594                     		UnpackScalar<Uint32>::func(in, pos, cimValue);
595                     		break;
596                     
597                     	    case CIMTYPE_SINT32:
598                     		UnpackScalar<Sint32>::func(in, pos, cimValue);
599                     		break;
600                     
601                     	    case CIMTYPE_UINT64:
602                     		UnpackScalar<Uint64>::func(in, pos, cimValue);
603                     		break;
604                     
605                     	    case CIMTYPE_SINT64:
606                     		UnpackScalar<Sint64>::func(in, pos, cimValue);
607 jim.wunderlich 1.21 		break;
608                     
609                     	    case CIMTYPE_REAL32:
610                     		UnpackScalar<Real32>::func(in, pos, cimValue);
611                     		break;
612                     
613                     	    case CIMTYPE_REAL64:
614                     		UnpackScalar<Real64>::func(in, pos, cimValue);
615                     		break;
616                     
617                     	    case CIMTYPE_CHAR16:
618                     		UnpackScalar<Char16>::func(in, pos, cimValue);
619                     		break;
620                     
621                     	    case CIMTYPE_STRING:
622                     		UnpackScalar<String>::func(in, pos, cimValue);
623                     		break;
624                     
625                     	    case CIMTYPE_DATETIME:
626                     		UnpackScalar<CIMDateTime>::func(in, pos, cimValue);
627                     		break;
628 jim.wunderlich 1.21 
629                     	    case CIMTYPE_REFERENCE:
630                     		UnpackScalar<CIMObjectPath>::func(in, pos, cimValue);
631                     		break;
632                     
633                     	    case CIMTYPE_OBJECT:
634                     		break;
635                     	}
636 schuur         1.1  
637 jim.wunderlich 1.21 	x = cimValue;
638                         }
639 schuur         1.1  
640 jim.wunderlich 1.21     return;
641                     }
642 schuur         1.1  
643 mike           1.24 void BinaryStreamer::_packProperty(Buffer& out, const CIMProperty& x)
644 jim.wunderlich 1.21 {
645                         CIMPropertyRep* rep = x._rep;
646 schuur         1.1  
647 jim.wunderlich 1.21     _packMagicByte(out);
648                         _packName(out, rep->getName());
649                         _packValue(out, rep->getValue());
650                         Packer::packSize(out, rep->getArraySize());
651                         _packName(out, rep->getReferenceClassName());
652                         _packName(out, rep->getClassOrigin());
653                         Packer::packBoolean(out, rep->getPropagated());
654                         PackQualifiers<CIMPropertyRep>::func(out, rep);
655 schuur         1.1  }
656                     
657 jim.wunderlich 1.21 void BinaryStreamer::_unpackProperty(
658 mike           1.24     const Buffer& in, Uint32& pos, CIMProperty& x)
659 jim.wunderlich 1.21 {
660                         _checkMagicByte(in, pos);
661 schuur         1.1  
662 jim.wunderlich 1.21     CIMName name;
663                         _unpackName(in, pos, name);
664 schuur         1.1  
665 jim.wunderlich 1.21     CIMValue value;
666                         _unpackValue(in, pos, value);
667 schuur         1.1  
668 jim.wunderlich 1.21     Uint32 arraySize;
669                         Packer::unpackSize(in, pos, arraySize);
670 schuur         1.1  
671 jim.wunderlich 1.21     CIMName referenceClassName;
672                         _unpackName(in, pos, referenceClassName);
673 schuur         1.1  
674 jim.wunderlich 1.21     CIMName classOrigin;
675                         _unpackName(in, pos, classOrigin);
676 schuur         1.1  
677 jim.wunderlich 1.21     Boolean propagated;
678                         Packer::unpackBoolean(in, pos, propagated);
679 schuur         1.1  
680 jim.wunderlich 1.21     CIMProperty cimProperty(
681                     	name, value, arraySize, referenceClassName, classOrigin, propagated);
682 schuur         1.1  
683 jim.wunderlich 1.21     UnpackQualifiers<CIMProperty>::func(in, pos, cimProperty);
684 schuur         1.1  
685 jim.wunderlich 1.21     x = cimProperty;
686 schuur         1.1  }
687                     
688 mike           1.24 void BinaryStreamer::_packParameter(Buffer& out, const CIMParameter& x)
689 jim.wunderlich 1.21 {
690                         CIMParameterRep* rep = x._rep;
691 schuur         1.1  
692 jim.wunderlich 1.21     _packMagicByte(out);
693                         _packName(out, rep->getName());
694                         _packType(out, rep->getType());
695                         Packer::packBoolean(out, rep->isArray());
696                         Packer::packSize(out, rep->getArraySize());
697                         _packName(out, rep->getReferenceClassName());
698                         PackQualifiers<CIMParameterRep>::func(out, rep);
699                     }
700                     
701                     void BinaryStreamer::_unpackParameter(
702 mike           1.24     const Buffer& in, Uint32& pos, CIMParameter& x)
703 schuur         1.1  {
704 jim.wunderlich 1.21     _checkMagicByte(in, pos);
705 konrad.r       1.8  
706 jim.wunderlich 1.21     CIMName name;
707                         _unpackName(in, pos, name);
708 konrad.r       1.8  
709 jim.wunderlich 1.21     CIMType type;
710                         _unpackType(in, pos, type);
711 schuur         1.1  
712 jim.wunderlich 1.21     Boolean isArray;
713                         Packer::unpackBoolean(in, pos, isArray);
714 schuur         1.1  
715 jim.wunderlich 1.21     Uint32 arraySize;
716                         Packer::unpackSize(in, pos, arraySize);
717 schuur         1.1  
718 jim.wunderlich 1.21     CIMName referenceClassName;
719                         _unpackName(in, pos, referenceClassName);
720 schuur         1.1  
721 jim.wunderlich 1.21     CIMParameter cimParameter(
722                     	name, type, isArray, arraySize, referenceClassName);
723 schuur         1.1  
724 jim.wunderlich 1.21     UnpackQualifiers<CIMParameter>::func(in, pos, cimParameter);
725 schuur         1.1  
726 jim.wunderlich 1.21     x = cimParameter;
727                     }
728 schuur         1.1  
729 mike           1.24 void BinaryStreamer::_packParameters(Buffer& out, CIMMethodRep* rep)
730 jim.wunderlich 1.21 {
731                         Uint32 n = rep->getParameterCount();
732                         Packer::packSize(out, n);
733 schuur         1.1  
734 jim.wunderlich 1.21     for (Uint32 i = 0; i < n; i++)
735                     	BinaryStreamer::_packParameter(out, rep->getParameter(i));
736 schuur         1.1  }
737                     
738 jim.wunderlich 1.21 void BinaryStreamer::_unpackParameters(
739 mike           1.24     const Buffer& in, Uint32& pos, CIMMethod& x)
740 jim.wunderlich 1.21 {
741                         Uint32 n;
742                         Packer::unpackSize(in, pos, n);
743 schuur         1.1  
744 jim.wunderlich 1.21     for (size_t i = 0; i < n; i++)
745                         {
746                     	CIMParameter q;
747                     	_unpackParameter(in, pos, q);
748                     	x.addParameter(q);
749                         }
750                     }
751 schuur         1.1  
752 mike           1.24 void BinaryStreamer::_packMethod(Buffer& out, const CIMMethod& x)
753 jim.wunderlich 1.21 {
754                         CIMMethodRep* rep = x._rep;
755 schuur         1.1  
756 jim.wunderlich 1.21     _packMagicByte(out);
757                         _packName(out, rep->getName());
758                         _packType(out, rep->getType());
759                         _packName(out, rep->getClassOrigin());
760                         Packer::packBoolean(out, rep->getPropagated());
761                         PackQualifiers<CIMMethodRep>::func(out, rep);
762                         _packParameters(out, rep);
763                     }
764 schuur         1.1  
765 jim.wunderlich 1.21 void BinaryStreamer::_unpackMethod(
766 mike           1.24     const Buffer& in, Uint32& pos, CIMMethod& x)
767 schuur         1.1  {
768 jim.wunderlich 1.21     _checkMagicByte(in, pos);
769 schuur         1.1  
770 jim.wunderlich 1.21     CIMName name;
771                         _unpackName(in, pos, name);
772 schuur         1.1  
773 jim.wunderlich 1.21     CIMType type;
774                         _unpackType(in, pos, type);
775 schuur         1.1  
776 jim.wunderlich 1.21     CIMName classOrigin;
777                         _unpackName(in, pos, classOrigin);
778 schuur         1.1  
779 jim.wunderlich 1.21     Boolean propagated;
780                         Packer::unpackBoolean(in, pos, propagated);
781 schuur         1.1  
782 jim.wunderlich 1.21     CIMMethod cimMethod(name, type, classOrigin, propagated);
783                         UnpackQualifiers<CIMMethod>::func(in, pos, cimMethod);
784                         _unpackParameters(in, pos, cimMethod);
785 schuur         1.1  
786 jim.wunderlich 1.21     x = cimMethod;
787 schuur         1.1  }
788                     
789 mike           1.24 void BinaryStreamer::_packObjectPath(Buffer& out, const CIMObjectPath& x)
790 jim.wunderlich 1.21 {
791                         Packer::packString(out, x.toString());
792                     }
793 schuur         1.1  
794 jim.wunderlich 1.21 void BinaryStreamer::_unpackObjectPath(
795 mike           1.24     const Buffer& in, Uint32& pos, CIMObjectPath& x)
796 schuur         1.1  {
797 jim.wunderlich 1.21     String tmp;
798                         Packer::unpackString(in, pos, tmp);
799                         x = CIMObjectPath(tmp);
800                     }
801 konrad.r       1.8  
802 mike           1.24 void BinaryStreamer::_packProperties(Buffer& out, CIMObjectRep* rep)
803 jim.wunderlich 1.21 {
804                         Uint32 n = rep->getPropertyCount();
805                         Packer::packSize(out, n);
806 schuur         1.1  
807 jim.wunderlich 1.21     for (Uint32 i = 0; i < n; i++)
808                     	BinaryStreamer::_packProperty(out, rep->getProperty(i));
809                     }
810 schuur         1.1  
811 mike           1.24 void BinaryStreamer::_packMethods(Buffer& out, CIMClassRep* rep)
812 jim.wunderlich 1.21 {
813                         Uint32 n = rep->getMethodCount();
814                         Packer::packSize(out, n);
815 schuur         1.1  
816 jim.wunderlich 1.21     for (Uint32 i = 0; i < n; i++)
817                     	BinaryStreamer::_packMethod(out, rep->getMethod(i));
818                     }
819 schuur         1.1  
820 mike           1.24 void BinaryStreamer::_packScope(Buffer& out, const CIMScope& x)
821 jim.wunderlich 1.21 {
822                         Packer::packUint32(out, x.cimScope);
823                     }
824 schuur         1.1  
825 jim.wunderlich 1.21 void BinaryStreamer::_unpackScope(
826 mike           1.24     const Buffer& in, Uint32& pos, CIMScope& x)
827 jim.wunderlich 1.21 {
828                         Packer::unpackUint32(in, pos, x.cimScope);
829                     }
830 schuur         1.1  
831 mike           1.24 void BinaryStreamer::_packFlavor(Buffer& out, const CIMFlavor& x)
832 jim.wunderlich 1.21 {
833                         Packer::packUint32(out, x.cimFlavor);
834 schuur         1.1  }
835                     
836 jim.wunderlich 1.21 void BinaryStreamer::_unpackFlavor(
837 mike           1.24     const Buffer& in, Uint32& pos, CIMFlavor& x)
838 jim.wunderlich 1.21 {
839                         Packer::unpackUint32(in, pos, x.cimFlavor);
840                     }
841 schuur         1.1  
842 mike           1.24 void BinaryStreamer::_packType(Buffer& out, const CIMType& x)
843 jim.wunderlich 1.21 {
844                         Packer::packUint8(out, Uint8(x));
845                     }
846 schuur         1.1  
847 jim.wunderlich 1.21 void BinaryStreamer::_unpackType(
848 mike           1.24     const Buffer& in, Uint32& pos, CIMType& x)
849 jim.wunderlich 1.21 {
850                         Uint8 tmp;
851                         Packer::unpackUint8(in, pos, tmp);
852                         x = CIMType(tmp);
853                     }
854 schuur         1.1  
855 jim.wunderlich 1.21 void BinaryStreamer::encode(
856 mike           1.24     Buffer& out, 
857 jim.wunderlich 1.21     const CIMClass& x)
858                     {
859                         CIMClassRep* rep = x._rep;
860                         _packMagicByte(out);
861                         _packHeader(out, BINARY_CLASS);
862                         _packName(out, x.getClassName());
863                         _packName(out, x.getSuperClassName());
864                         PackQualifiers<CIMClassRep>::func(out, rep);
865                         _packProperties(out, rep);
866                         _packMethods(out, rep);
867                         Packer::packBoolean(out, rep->_resolved);
868                     }
869 schuur         1.1  
870 jim.wunderlich 1.21 void BinaryStreamer::decode(
871 mike           1.24     const Buffer& in, 
872 jim.wunderlich 1.21     unsigned int pos, 
873                         CIMClass& x)
874 schuur         1.1  {
875 jim.wunderlich 1.21     _checkMagicByte(in, pos);
876                         _checkHeader(in, pos, BINARY_CLASS);
877                     
878                         CIMName className;
879                         _unpackName(in, pos, className);
880                     
881                         CIMName superClassName;
882                         _unpackName(in, pos, superClassName);
883 schuur         1.1  
884 jim.wunderlich 1.21     CIMClass cimClass(className, superClassName);
885 schuur         1.1  
886 jim.wunderlich 1.21     UnpackQualifiers<CIMClass>::func(in, pos, cimClass);
887                         UnpackProperties<CIMClass>::func(in, pos, cimClass);
888                         UnpackMethods<CIMClass>::func(in, pos, cimClass);
889 schuur         1.1  
890 jim.wunderlich 1.21     Boolean resolved;
891                         Packer::unpackBoolean(in, pos, resolved);
892                         cimClass._rep->_resolved = resolved;
893                         x = cimClass;
894                     }
895 schuur         1.1  
896 jim.wunderlich 1.21 void BinaryStreamer::encode(
897 mike           1.24     Buffer& out, 
898 jim.wunderlich 1.21     const CIMInstance& x)
899                     {
900                         CIMInstanceRep* rep = x._rep;
901                         _packMagicByte(out);
902                         _packHeader(out, BINARY_INSTANCE);
903                         _packObjectPath(out, x.getPath());
904                         PackQualifiers<CIMInstanceRep>::func(out, rep);
905                         _packProperties(out, rep);
906                         Packer::packBoolean(out, rep->_resolved);
907                     }
908 schuur         1.1  
909 jim.wunderlich 1.21 void BinaryStreamer::decode(
910 mike           1.24     const Buffer& in, 
911 jim.wunderlich 1.21     unsigned int pos, 
912                         CIMInstance& x)
913                     {
914                         _checkMagicByte(in, pos);
915                         _checkHeader(in, pos, BINARY_INSTANCE);
916 schuur         1.1  
917 jim.wunderlich 1.21     CIMObjectPath objectPath;
918                         _unpackObjectPath(in, pos, objectPath);
919                         CIMInstance cimInstance(objectPath.getClassName());
920                         cimInstance.setPath(objectPath);
921 schuur         1.1  
922 jim.wunderlich 1.21     UnpackQualifiers<CIMInstance>::func(in, pos, cimInstance);
923                         UnpackProperties<CIMInstance>::func(in, pos, cimInstance);
924                     
925                         Boolean resolved;
926                         Packer::unpackBoolean(in, pos, resolved);
927                         cimInstance._rep->_resolved = resolved;
928                         x = cimInstance;
929 schuur         1.1  }
930                     
931 jim.wunderlich 1.21 void BinaryStreamer::encode(
932 mike           1.24     Buffer& out, 
933 jim.wunderlich 1.21     const CIMQualifierDecl& x)
934                     {
935                         _packMagicByte(out);
936                         _packHeader(out, BINARY_QUALIFIER_DECL);
937                         _packName(out , x.getName());
938                         _packValue(out , x.getValue());
939                         _packScope(out , x.getScope());
940                         _packFlavor(out , x.getFlavor());
941                         Packer::packSize(out, x.getArraySize());
942                     }
943 schuur         1.1  
944 jim.wunderlich 1.21 void BinaryStreamer::decode(
945 mike           1.24     const Buffer& in, 
946 jim.wunderlich 1.21     unsigned int pos, 
947                         CIMQualifierDecl& x)
948 schuur         1.1  {
949 jim.wunderlich 1.21     _checkMagicByte(in, pos);
950                         _checkHeader(in, pos, BINARY_QUALIFIER_DECL);
951                     
952                         CIMName qualifierName;
953                         _unpackName(in, pos, qualifierName);
954                     
955                         CIMValue value;
956                         _unpackValue(in, pos, value);
957                     
958                         CIMScope scope;
959                         _unpackScope(in, pos, scope);
960 konrad.r       1.8  
961 jim.wunderlich 1.21     CIMFlavor flavor;
962                         BinaryStreamer::_unpackFlavor(in, pos, flavor);
963                     
964                         Uint32 arraySize;
965                         Packer::unpackSize(in, pos, arraySize);
966                     
967                         x = CIMQualifierDecl(qualifierName, value, scope, flavor, arraySize);
968 schuur         1.1  }
969                     
970                     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2