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

  1 karl  1.16 //%2006////////////////////////////////////////////////////////////////////////
  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 karl   1.16 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12             // EMC Corporation; Symantec Corporation; The Open Group.
 13 schuur 1.1  //
 14             // Permission is hereby granted, free of charge, to any person obtaining a copy
 15             // of this software and associated documentation files (the "Software"), to
 16             // deal in the Software without restriction, including without limitation the
 17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18             // sell copies of the Software, and to permit persons to whom the Software is
 19             // furnished to do so, subject to the following conditions:
 20 karl   1.4  // 
 21 schuur 1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22             // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24             // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27             // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29             //
 30             //==============================================================================
 31             //
 32             // Author: Adrian Schuur (schuur@de.ibm.com) - PEP 164
 33             //
 34 david.dillard 1.5  // Modified By: David Dillard, VERITAS Software Corp.
 35                    //                  (david.dillard@veritas.com)
 36 aruran.ms     1.7  //              Aruran, IBM (ashanmug@in.ibm.com) for BUG#3348
 37 schuur        1.1  //
 38                    //%/////////////////////////////////////////////////////////////////////////////
 39                    
 40 jim.wunderlich 1.9  
 41 schuur         1.1  #include "ObjectStreamer.h"
 42                     
 43                     #include "AutoStreamer.h"
 44                     
 45                     PEGASUS_NAMESPACE_BEGIN
 46                     
 47                     AutoStreamer::AutoStreamer(ObjectStreamer *primary, Uint8 marker) {
 48                        _readerCount=0;
 49                        if (marker) {
 50                           _readers[_readerCount].reader=primary;
 51                           _readers[_readerCount++].marker=marker;
 52                        }
 53                        else _defaultReader=primary;
 54 schuur         1.2     _primary=primary; 
 55 schuur         1.1  }
 56                     
 57 aruran.ms      1.8  AutoStreamer::~AutoStreamer() {
 58 konrad.r       1.13     for (Uint32 i=0; i<=_readerCount; ++i)
 59                         {
 60                     	if (_defaultReader != _readers[i].reader)
 61                             	delete _readers[i].reader;
 62                         }
 63                         if (_defaultReader)
 64                         	delete _defaultReader;
 65 aruran.ms      1.7  }
 66                     
 67 schuur         1.1  void AutoStreamer::addReader(ObjectStreamer *reader, Uint8 marker) {
 68                        if (marker) {
 69                           _readers[_readerCount].reader=reader;
 70                           _readers[_readerCount++].marker=marker;
 71                        }
 72                        else _defaultReader=reader;
 73                     }
 74                     
 75                     
 76 mike           1.15 void AutoStreamer::encode(Buffer& out, const CIMClass& cls)
 77 schuur         1.1  {
 78                        _primary->encode(out,cls);
 79                     }
 80                     
 81 mike           1.15 void AutoStreamer::encode(Buffer& out, const CIMInstance& inst)
 82 schuur         1.1  {
 83                        _primary->encode(out,inst);
 84                     }
 85                     
 86 mike           1.15 void AutoStreamer::encode(Buffer& out, const CIMQualifierDecl& qual)
 87 schuur         1.1  {
 88                        _primary->encode(out,qual);
 89                     }
 90                     
 91 mike           1.15 void AutoStreamer::write(PEGASUS_STD(ostream)& os, Buffer& in)
 92 schuur         1.1  {
 93 kumpf          1.3     _primary->write(os,in);
 94 schuur         1.1  }
 95                     
 96                     
 97 mike           1.15 void AutoStreamer::decode(const Buffer& in, unsigned int pos, CIMClass& cls)
 98 schuur         1.1  {
 99                        for (Uint16 i=0,m=_readerCount; i<m; i++) {
100 jim.wunderlich 1.9        if (_readers[i].marker==in[pos]) {
101 schuur         1.1           _readers[i].reader->decode(in,pos,cls);
102                              return;
103                           }
104                        }
105                        _defaultReader->decode(in,pos,cls);
106                     }
107                     
108 mike           1.15 void AutoStreamer::decode(const Buffer& in, unsigned int pos, CIMInstance& inst)
109 schuur         1.1  {
110                        for (Uint16 i=0,m=_readerCount; i<m; i++) {
111 jim.wunderlich 1.9        if (_readers[i].marker==in[pos]) {
112 schuur         1.1           _readers[i].reader->decode(in,pos,inst);
113                              return;
114                           }
115                        }
116                        _defaultReader->decode(in,pos,inst);
117                     }
118                     
119 mike           1.15 void AutoStreamer::decode(const Buffer& in, unsigned int pos, CIMQualifierDecl& qual)
120 schuur         1.1  {
121                        for (Uint16 i=0,m=_readerCount; i<m; i++) {
122 jim.wunderlich 1.9        if (_readers[i].marker==in[pos]) {
123 schuur         1.1           _readers[i].reader->decode(in,pos,qual);
124                              return;
125                           }
126                        }
127                        _defaultReader->decode(in,pos,qual);
128                     }
129                     
130                     PEGASUS_NAMESPACE_END
131                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2