(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             //%/////////////////////////////////////////////////////////////////////////////
 33             
 34 jim.wunderlich 1.9  
 35 schuur         1.1  #include "ObjectStreamer.h"
 36                     
 37                     #include "AutoStreamer.h"
 38                     
 39                     PEGASUS_NAMESPACE_BEGIN
 40                     
 41 kumpf          1.18 AutoStreamer::AutoStreamer(ObjectStreamer *primary, Uint8 marker)
 42                     {
 43                         _readerCount=0;
 44                         if (marker)
 45                         {
 46                             _readers[_readerCount].reader=primary;
 47                             _readers[_readerCount++].marker=marker;
 48                         }
 49                         else _defaultReader=primary;
 50                         _primary=primary;
 51 schuur         1.1  }
 52                     
 53 kumpf          1.18 AutoStreamer::~AutoStreamer()
 54                     {
 55 konrad.r       1.13     for (Uint32 i=0; i<=_readerCount; ++i)
 56                         {
 57 kumpf          1.18         if (_defaultReader != _readers[i].reader)
 58                                 delete _readers[i].reader;
 59 konrad.r       1.13     }
 60 kumpf          1.17     delete _defaultReader;
 61 aruran.ms      1.7  }
 62                     
 63 kumpf          1.18 void AutoStreamer::addReader(ObjectStreamer *reader, Uint8 marker)
 64                     {
 65                         if (marker)
 66                         {
 67                             _readers[_readerCount].reader=reader;
 68                             _readers[_readerCount++].marker=marker;
 69                         }
 70                         else _defaultReader=reader;
 71 schuur         1.1  }
 72                     
 73                     
 74 mike           1.15 void AutoStreamer::encode(Buffer& out, const CIMClass& cls)
 75 schuur         1.1  {
 76                        _primary->encode(out,cls);
 77                     }
 78                     
 79 mike           1.15 void AutoStreamer::encode(Buffer& out, const CIMInstance& inst)
 80 schuur         1.1  {
 81                        _primary->encode(out,inst);
 82                     }
 83                     
 84 mike           1.15 void AutoStreamer::encode(Buffer& out, const CIMQualifierDecl& qual)
 85 schuur         1.1  {
 86                        _primary->encode(out,qual);
 87                     }
 88                     
 89 mike           1.15 void AutoStreamer::write(PEGASUS_STD(ostream)& os, Buffer& in)
 90 schuur         1.1  {
 91 kumpf          1.3     _primary->write(os,in);
 92 schuur         1.1  }
 93                     
 94                     
 95 kumpf          1.18 void AutoStreamer::decode(
 96                         const Buffer& in,
 97                         unsigned int pos,
 98                         CIMClass& cls)
 99                     {
100                         for (Uint16 i=0,m=_readerCount; i<m; i++)
101                         {
102                             if (_readers[i].marker==in[pos])
103                             {
104                                 _readers[i].reader->decode(in,pos,cls);
105                                 return;
106                             }
107                         }
108                         _defaultReader->decode(in,pos,cls);
109                     }
110                     
111                     void AutoStreamer::decode(
112                         const Buffer& in,
113                         unsigned int pos,
114                         CIMInstance& inst)
115                     {
116 kumpf          1.18     for (Uint16 i=0,m=_readerCount; i<m; i++)
117                         {
118                             if (_readers[i].marker==in[pos])
119                             {
120                                 _readers[i].reader->decode(in,pos,inst);
121                                 return;
122                             }
123                         }
124                         _defaultReader->decode(in,pos,inst);
125                     }
126                     
127                     void AutoStreamer::decode(
128                         const Buffer& in,
129                         unsigned int pos,
130                         CIMQualifierDecl& qual)
131 schuur         1.1  {
132 kumpf          1.18     for (Uint16 i=0,m=_readerCount; i<m; i++)
133                         {
134                             if (_readers[i].marker==in[pos])
135                             {
136                                 _readers[i].reader->decode(in,pos,qual);
137                                 return;
138                             }
139                         }
140                         _defaultReader->decode(in,pos,qual);
141 schuur         1.1  }
142                     
143                     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2