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

  1 karl  1.6 //%2005////////////////////////////////////////////////////////////////////////
  2 schuur 1.1 //
  3 karl   1.4 // 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.4 // 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.6 // 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.4 // 
 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 david.dillard 1.5 // Modified By: David Dillard, VERITAS Software Corp.
 33                   //                  (david.dillard@veritas.com)
 34 schuur        1.1 //
 35                   //%/////////////////////////////////////////////////////////////////////////////
 36                   
 37                   #include "ObjectStreamer.h"
 38                   
 39                   #include "AutoStreamer.h"
 40                   
 41                   PEGASUS_NAMESPACE_BEGIN
 42                   
 43                   AutoStreamer::AutoStreamer(ObjectStreamer *primary, Uint8 marker) {
 44                      _readerCount=0;
 45                      if (marker) {
 46                         _readers[_readerCount].reader=primary;
 47                         _readers[_readerCount++].marker=marker;
 48                      }
 49                      else _defaultReader=primary;
 50 schuur        1.2    _primary=primary; 
 51 schuur        1.1 }
 52                   
 53                   void AutoStreamer::addReader(ObjectStreamer *reader, Uint8 marker) {
 54                      if (marker) {
 55                         _readers[_readerCount].reader=reader;
 56                         _readers[_readerCount++].marker=marker;
 57                      }
 58                      else _defaultReader=reader;
 59                   }
 60                   
 61                   
 62 david.dillard 1.5 void AutoStreamer::encode(Array<char>& out, const CIMClass& cls)
 63 schuur        1.1 {
 64                      _primary->encode(out,cls);
 65                   }
 66                   
 67 david.dillard 1.5 void AutoStreamer::encode(Array<char>& out, const CIMInstance& inst)
 68 schuur        1.1 {
 69                      _primary->encode(out,inst);
 70                   }
 71                   
 72 david.dillard 1.5 void AutoStreamer::encode(Array<char>& out, const CIMQualifierDecl& qual)
 73 schuur        1.1 {
 74                      _primary->encode(out,qual);
 75                   }
 76                   
 77 david.dillard 1.5 void AutoStreamer::write(PEGASUS_STD(ostream)& os, Array<char>& in)
 78 schuur        1.1 {
 79 kumpf         1.3    _primary->write(os,in);
 80 schuur        1.1 }
 81                   
 82                   
 83 david.dillard 1.5 void AutoStreamer::decode(const Array<char>& in, unsigned int pos, CIMClass& cls)
 84 schuur        1.1 {
 85                      for (Uint16 i=0,m=_readerCount; i<m; i++) {
 86                         if (_readers[i].marker==in[0]) {
 87                            _readers[i].reader->decode(in,pos,cls);
 88                            return;
 89                         }
 90                      }
 91                      _defaultReader->decode(in,pos,cls);
 92                   }
 93                   
 94 david.dillard 1.5 void AutoStreamer::decode(const Array<char>& in, unsigned int pos, CIMInstance& inst)
 95 schuur        1.1 {
 96                      for (Uint16 i=0,m=_readerCount; i<m; i++) {
 97                         if (_readers[i].marker==in[0]) {
 98                            _readers[i].reader->decode(in,pos,inst);
 99                            return;
100                         }
101                      }
102                      _defaultReader->decode(in,pos,inst);
103                   }
104                   
105 david.dillard 1.5 void AutoStreamer::decode(const Array<char>& in, unsigned int pos, CIMQualifierDecl& qual)
106 schuur        1.1 {
107                      for (Uint16 i=0,m=_readerCount; i<m; i++) {
108                         if (_readers[i].marker==in[0]) {
109                            _readers[i].reader->decode(in,pos,qual);
110                            return;
111                         }
112                      }
113                      _defaultReader->decode(in,pos,qual);
114                   }
115                   
116                   PEGASUS_NAMESPACE_END
117                   

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2