(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 marek 1.34 #include "CIMPropertyRep.h"
 39 mike  1.1  
 40 chip  1.26 PEGASUS_NAMESPACE_BEGIN
 41            
 42 mike  1.1  PEGASUS_USING_STD;
 43            
 44 chip  1.26 CIMObjectRep::CIMObjectRep(const CIMObjectRep& x)
 45 mike  1.36.4.1     : Sharable(), _reference(x._reference)
 46 chip  1.26     {
 47                    x._qualifiers.cloneTo(_qualifiers);
 48                
 49                    _properties.reserveCapacity(x._properties.size());
 50                
 51                    for (Uint32 i = 0, n = x._properties.size(); i < n; i++)
 52                    {
 53                        _properties.append(x._properties[i].clone());
 54                    }
 55                }
 56 mike  1.1      
 57 kumpf 1.10     CIMObjectRep::CIMObjectRep(const CIMObjectPath& reference)
 58 mike  1.1      {
 59 chip  1.28         // ensure the class name is not null
 60 kumpf 1.31         if (reference.getClassName().isNull())
 61 chip  1.28         {
 62                        throw UninitializedObjectException();
 63                    }
 64                
 65                    _reference = reference;
 66 mike  1.1      }
 67                
 68                CIMObjectRep::~CIMObjectRep()
 69                {
 70                }
 71                
 72                void CIMObjectRep::addProperty(const CIMProperty& x)
 73                {
 74 kumpf 1.16         if (x.isUninitialized())
 75 chip  1.26         {
 76                        throw UninitializedObjectException();
 77                    }
 78 mike  1.1      
 79                    // Reject duplicate property names:
 80                
 81 marek 1.34         if (findProperty(x._rep->_name, x._rep->_nameTag) != PEG_NOT_FOUND)
 82 chip  1.26         {
 83                        MessageLoaderParms parms(
 84                            "Common.CIMObjectRep.PROPERTY",
 85                            "property \"$0\"",
 86                            x.getName().getString());
 87                
 88 humberto 1.22             throw AlreadyExistsException(parms);
 89                       }
 90 mike     1.1      
 91                       // Append property:
 92                   
 93                       _properties.append(x);
 94                   }
 95                   
 96                   Boolean CIMObjectRep::identical(const CIMObjectRep* x) const
 97                   {
 98 kumpf    1.32         // If the pointers are the same, the objects must be identical
 99                       if (this == x)
100                       {
101                           return true;
102                       }
103                   
104 chip     1.4          if (!_reference.identical(x->_reference))
105 chip     1.26         {
106 kumpf    1.31             return false;
107 chip     1.26         }
108 mike     1.1      
109                       if (!_qualifiers.identical(x->_qualifiers))
110 chip     1.26         {
111 kumpf    1.31             return false;
112 chip     1.26         }
113 mike     1.1      
114                       // Compare properties:
115                   
116                       {
117 marek    1.34             const PropertySet& tmp1 = _properties;
118                           const PropertySet& tmp2 = x->_properties;
119 mike     1.1      
120 chip     1.26             if (tmp1.size() != tmp2.size())
121                           {
122 kumpf    1.31                 return false;
123 chip     1.26             }
124                   
125                           for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
126                           {
127                               if (!tmp1[i].identical(tmp2[i]))
128                               {
129 kumpf    1.31                     return false;
130 chip     1.26                 }
131                           }
132 mike     1.1          }
133                   
134 kumpf    1.31         return true;
135 kumpf    1.11     }
136                   
137 chip     1.28     void CIMObjectRep::setPath(const CIMObjectPath& path)
138 kumpf    1.11     {
139 chip     1.28         // ensure the class name is not null
140 kumpf    1.31         if (path.getClassName().isNull())
141 chip     1.28         {
142                           throw UninitializedObjectException();
143                       }
144                   
145 chip     1.26         // prevent changing the class name (type) in when updating the object path
146 kumpf    1.31         if (!_reference.getClassName().equal(path.getClassName()))
147 chip     1.26         {
148                           throw TypeMismatchException();
149                       }
150                   
151 kumpf    1.11         _reference = path;
152 mike     1.1      }
153                   
154                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2