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

  1 karl  1.29 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.1  //
  3 karl  1.24 // 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 karl  1.23 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.24 // 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.25 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.29 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 chip  1.2  // 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 mike  1.1  // 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.29 // 
 21 chip  1.2  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.1  // 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 chip  1.2  // 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 mike  1.1  // 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            #include "CIMObjectRep.h"
 35 chip  1.26 
 36            #include <Pegasus/Common/CIMName.h>
 37 kumpf 1.30 #include <Pegasus/Common/MessageLoader.h>
 38 mike  1.1  
 39 chip  1.26 PEGASUS_NAMESPACE_BEGIN
 40            
 41 mike  1.1  PEGASUS_USING_STD;
 42            
 43 chip  1.26 CIMObjectRep::CIMObjectRep()
 44            {
 45            }
 46            
 47            CIMObjectRep::CIMObjectRep(const CIMObjectRep& x)
 48 aruran.ms 1.27     : Sharable(), _reference(x._reference),
 49 chip      1.26     _resolved(x._resolved)
 50                {
 51                    x._qualifiers.cloneTo(_qualifiers);
 52                
 53                    _properties.reserveCapacity(x._properties.size());
 54                
 55                    for (Uint32 i = 0, n = x._properties.size(); i < n; i++)
 56                    {
 57                        _properties.append(x._properties[i].clone());
 58                    }
 59                }
 60 mike      1.1  
 61 kumpf     1.10 CIMObjectRep::CIMObjectRep(const CIMObjectPath& reference)
 62 chip      1.28     : _resolved(false)
 63 mike      1.1  {
 64 chip      1.28     // ensure the class name is not null
 65 kumpf     1.31     if (reference.getClassName().isNull())
 66 chip      1.28     {
 67                        throw UninitializedObjectException();
 68                    }
 69                
 70                    _reference = reference;
 71 mike      1.1  }
 72                
 73                CIMObjectRep::~CIMObjectRep()
 74                {
 75                }
 76                
 77                void CIMObjectRep::addProperty(const CIMProperty& x)
 78                {
 79 kumpf     1.16     if (x.isUninitialized())
 80 chip      1.26     {
 81                        throw UninitializedObjectException();
 82                    }
 83 mike      1.1  
 84                    // Reject duplicate property names:
 85                
 86 chip      1.26     if (findProperty(x.getName()) != PEG_NOT_FOUND)
 87                    {
 88                        MessageLoaderParms parms(
 89                            "Common.CIMObjectRep.PROPERTY",
 90                            "property \"$0\"",
 91                            x.getName().getString());
 92                
 93 humberto  1.22         throw AlreadyExistsException(parms);
 94                    }
 95 mike      1.1  
 96                    // Append property:
 97                
 98                    _properties.append(x);
 99                }
100                
101 kumpf     1.15 Uint32 CIMObjectRep::findProperty(const CIMName& name) const
102 mike      1.1  {
103                    for (Uint32 i = 0, n = _properties.size(); i < n; i++)
104                    {
105 chip      1.26         if (name.equal(_properties[i].getName()))
106                        {
107 kumpf     1.31             return i;
108 chip      1.26         }
109 mike      1.1      }
110                
111 kumpf     1.31     return PEG_NOT_FOUND;
112 mike      1.1  }
113                
114 kumpf     1.20 CIMProperty CIMObjectRep::getProperty(Uint32 index)
115 mike      1.1  {
116 kumpf     1.20     if (index >= _properties.size())
117 chip      1.26     {
118                        throw IndexOutOfBoundsException();
119                    }
120 mike      1.1  
121 kumpf     1.31     return _properties[index];
122 mike      1.1  }
123                
124 kumpf     1.20 void CIMObjectRep::removeProperty(Uint32 index)
125 chip      1.26 {
126 kumpf     1.30     if (index >= _properties.size())
127 mike      1.1      {
128 chip      1.26         throw IndexOutOfBoundsException();
129 mike      1.1      }
130                
131 chip      1.26     _properties.remove(index);
132 mike      1.1  }
133                
134                
135 chip      1.26 Uint32 CIMObjectRep::getPropertyCount() const
136 mike      1.1  {
137 kumpf     1.31     return _properties.size();
138 mike      1.1  }
139                
140                
141                Boolean CIMObjectRep::identical(const CIMObjectRep* x) const
142                {
143 chip      1.4      if (!_reference.identical(x->_reference))
144 chip      1.26     {
145 kumpf     1.31         return false;
146 chip      1.26     }
147 mike      1.1  
148                    if (!_qualifiers.identical(x->_qualifiers))
149 chip      1.26     {
150 kumpf     1.31         return false;
151 chip      1.26     }
152 mike      1.1  
153                    // Compare properties:
154                
155                    {
156 chip      1.26         const Array<CIMProperty>& tmp1 = _properties;
157                        const Array<CIMProperty>& tmp2 = x->_properties;
158 mike      1.1  
159 chip      1.26         if (tmp1.size() != tmp2.size())
160                        {
161 kumpf     1.31             return false;
162 chip      1.26         }
163                
164                        for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
165                        {
166                            if (!tmp1[i].identical(tmp2[i]))
167                            {
168 kumpf     1.31                 return false;
169 chip      1.26             }
170                        }
171 mike      1.1      }
172                
173                    if (_resolved != x->_resolved)
174 chip      1.26     {
175 kumpf     1.31         return false;
176 chip      1.26     }
177 mike      1.1  
178 kumpf     1.31     return true;
179 kumpf     1.11 }
180                
181 chip      1.28 void CIMObjectRep::setPath(const CIMObjectPath& path)
182 kumpf     1.11 {
183 chip      1.28     // ensure the class name is not null
184 kumpf     1.31     if (path.getClassName().isNull())
185 chip      1.28     {
186                        throw UninitializedObjectException();
187                    }
188                
189 chip      1.26     // prevent changing the class name (type) in when updating the object path
190 kumpf     1.31     if (!_reference.getClassName().equal(path.getClassName()))
191 chip      1.26     {
192                        throw TypeMismatchException();
193                    }
194                
195 kumpf     1.11     _reference = path;
196 mike      1.1  }
197                
198                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2