00001 /******************************************************************************* 00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * - Redistributions of source code must retain the above copyright notice, 00008 * this list of conditions and the following disclaimer. 00009 * 00010 * - Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 00014 * - Neither the name of Vintela, Inc. nor the names of its 00015 * contributors may be used to endorse or promote products derived from this 00016 * software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS 00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00028 * POSSIBILITY OF SUCH DAMAGE. 00029 *******************************************************************************/ 00030 00036 #ifndef OWBI1_CIMINSTANCE_HPP_INCLUDE_GUARD_ 00037 #define OWBI1_CIMINSTANCE_HPP_INCLUDE_GUARD_ 00038 #include "OWBI1_config.h" 00039 #include "OWBI1_COWIntrusiveReference.hpp" 00040 #include "OWBI1_CIMElement.hpp" 00041 #include "OWBI1_CIMFwd.hpp" 00042 #include "OWBI1_CIMDataType.hpp" // for OWBI1_CIMDataType::INVALID 00043 #include "OWBI1_WBEMFlags.hpp" 00044 #include "OWBI1_CIMName.hpp" // necessary for implicit conversion (const char* -> CIMName) to work 00045 #include "OWBI1_CIMPropertyList.hpp" 00046 00047 namespace OWBI1 00048 { 00049 00081 class OWBI1_OWBI1PROVIFC_API CIMInstance : public CIMElement 00082 { 00083 public: 00084 enum { SERIALIZATION_VERSION = 1 }; // Version # for serialization 00085 00086 enum EErrorCodes 00087 { 00088 E_INSTANCE_HAS_NO_SUCH_PROPERTY 00089 }; 00090 00094 CIMInstance(); 00099 explicit CIMInstance(CIMNULL_t); 00104 CIMInstance(const CIMInstance& arg); 00109 explicit CIMInstance(const CIMName& name); 00114 explicit CIMInstance(const char* name); 00115 00116 explicit CIMInstance(const detail::CIMInstanceRepRef& rep); 00117 00121 ~CIMInstance(); 00126 virtual void setNull(); 00132 CIMInstance& operator= (const CIMInstance& arg); 00136 CIMName getClassName() const; 00141 CIMInstance& setKeys(const CIMPropertyArray& keys); 00147 CIMInstance& setClassName(const CIMName& name); 00151 String getLanguage() const; 00156 void setLanguage(const String& language); 00166 CIMPropertyArray getProperties( 00167 Int32 valueDataType = CIMDataType::INVALID) const; 00178 CIMInstance& setProperties(const CIMPropertyArray& props); 00186 CIMProperty getProperty(const CIMName& name, 00187 const CIMName& originClass) const; 00194 CIMProperty getProperty(const CIMName& name) const; 00201 CIMProperty getPropertyT(const CIMName& name) const; 00208 CIMValue getPropertyValue(const CIMName& name) const; 00214 bool propertyHasValue(const CIMName& name) const; 00219 CIMPropertyArray getKeyValuePairs() const; 00227 CIMInstance& updatePropertyValues(const CIMPropertyArray& props); 00234 CIMInstance& updatePropertyValue(const CIMProperty& prop); 00241 CIMInstance& updatePropertyValue(const CIMName& name, const CIMValue& cv); 00251 CIMInstance& setProperty(const CIMName& name, const CIMValue& cv); 00261 CIMInstance& setProperty(const CIMProperty& prop); 00267 CIMInstance& removeProperty(const CIMName& propName); 00276 CIMInstance clone(const CIMPropertyList& propertyList=CIMPropertyList()) const; 00284 CIMInstance& syncWithClass(const CIMClass& cc); 00302 CIMInstance createModifiedInstance( 00303 const CIMInstance& previousInstance, 00304 const CIMPropertyList& propertyList, 00305 const CIMClass& theClass) const; 00309 virtual CIMName getName() const; 00315 virtual void setName(const CIMName& name); 00320 virtual void readObject(std::istream &istrm); 00325 virtual void writeObject(std::ostream &ostrm) const; 00329 virtual String toMOF() const; 00333 virtual String toString() const; 00341 bool propertiesAreEqualTo(const CIMInstance& other) const; 00342 00343 typedef detail::CIMInstanceRepRef CIMInstance::*safe_bool; 00344 operator safe_bool () const; 00345 bool operator!() const; 00346 00347 detail::CIMInstanceRepRef getRep() const; 00348 protected: 00349 void _buildKeys(); 00350 00351 #ifdef OWBI1_WIN32 00352 #pragma warning (push) 00353 #pragma warning (disable: 4251) 00354 #endif 00355 00356 detail::CIMInstanceRepRef m_rep; 00357 00358 #ifdef OWBI1_WIN32 00359 #pragma warning (pop) 00360 #endif 00361 00362 friend OWBI1_OWBI1PROVIFC_API bool operator<(const CIMInstance& x, const CIMInstance& y); 00363 }; 00364 00365 } // end namespace OWBI1 00366 00367 #endif