00001 /******************************************************************************* 00002 * Copyright (C) 2005 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 00035 #include "OWBI1_config.h" 00036 #include "OWBI1_CIMPropertyList.hpp" 00037 #include "OWBI1_Array.hpp" 00038 #include "OWBI1_COWIntrusiveCountableBase.hpp" 00039 00040 namespace OWBI1 00041 { 00042 00043 struct CIMPropertyList::Rep : public COWIntrusiveCountableBase 00044 { 00045 Rep() 00046 : allProperties(true) 00047 { 00048 } 00049 00050 Rep(const CIMNameArray& n) 00051 : allProperties(false) 00052 , names(n.begin(), n.end()) 00053 { 00054 } 00055 00056 Rep(const StringArray& n) 00057 : allProperties(false) 00058 , names(n.begin(), n.end()) 00059 { 00060 } 00061 00062 bool allProperties; 00063 SortedVectorSet<CIMName> names; 00064 }; 00065 00067 CIMPropertyList::CIMPropertyList() 00068 : m_pdata(new Rep) 00069 { 00070 00071 } 00072 00074 CIMPropertyList::CIMPropertyList(const StringArray& properties) 00075 : m_pdata(new Rep(properties)) 00076 { 00077 00078 } 00079 00081 CIMPropertyList::CIMPropertyList(const CIMNameArray& properties) 00082 : m_pdata(new Rep(properties)) 00083 { 00084 00085 } 00086 00088 CIMPropertyList::~CIMPropertyList() 00089 { 00090 } 00091 00093 CIMPropertyList::CIMPropertyList(const CIMPropertyList& other) 00094 : SerializableIFC(other) 00095 , m_pdata(other.m_pdata) 00096 { 00097 } 00098 00100 CIMPropertyList& 00101 CIMPropertyList::operator=(const CIMPropertyList& other) 00102 { 00103 m_pdata = other.m_pdata; 00104 return *this; 00105 } 00106 00108 CIMPropertyList::const_iterator 00109 CIMPropertyList::begin() const 00110 { 00111 return m_pdata->names.begin(); 00112 } 00113 00115 CIMPropertyList::const_iterator 00116 CIMPropertyList::end() const 00117 { 00118 return m_pdata->names.end(); 00119 } 00120 00122 bool 00123 CIMPropertyList::isAllProperties() const 00124 { 00125 return m_pdata->allProperties; 00126 } 00127 00129 bool 00130 CIMPropertyList::hasProperty(const CIMName& propertyName) const 00131 { 00132 if (m_pdata->allProperties) 00133 { 00134 return true; 00135 } 00136 return m_pdata->names.count(propertyName) == 1; 00137 } 00138 00140 void 00141 CIMPropertyList::readObject(std::istream &istrm) 00142 { 00143 00144 } 00145 00147 void 00148 CIMPropertyList::writeObject(std::ostream &ostrm) const 00149 { 00150 00151 } 00152 00153 00154 00155 } // end namespace OWBI1 00156 00157 00158