OW_CIMScope.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.  *
00003 * Redistribution and use in source and binary forms, with or without
00004 * modification, are permitted provided that the following conditions are met:
00005 *
00006 *  - Redistributions of source code must retain the above copyright notice,
00007 *    this list of conditions and the following disclaimer.
00008 *
00009 *  - Redistributions in binary form must reproduce the above copyright notice,
00010 *    this list of conditions and the following disclaimer in the documentation
00011 *    and/or other materials provided with the distribution.
00012 *
00013 *  - Neither the name of Vintela, Inc. nor the names of its
00014 *    contributors may be used to endorse or promote products derived from this
00015 *    software without specific prior written permission.
00016 *
00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00021 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027 * POSSIBILITY OF SUCH DAMAGE.
00028 *******************************************************************************/
00029 
00035 #ifndef OW_CIMSCOPE_HPP_
00036 #define OW_CIMSCOPE_HPP_
00037 #include "OW_config.h"
00038 #include "OW_CIMBase.hpp"
00039 
00040 #if defined(BAD)
00041 #undef BAD
00042 #endif
00043 
00044 namespace OW_NAMESPACE
00045 {
00046 
00051 class OW_COMMON_API CIMScope : public CIMBase
00052 {
00053 public:
00054    // An enumeration of the scope values that this class understands
00055    enum Scope
00056    {
00057       BAD         = 0,  // Indicates unset or bad
00058       SCHEMA      = 1,  // A CIM schema
00059       CLASS    = 2,  // A CIM class
00060       ASSOCIATION = 3,  // A CIM association
00061       INDICATION  = 4,  // A CIM indication
00062       PROPERTY = 5,  // A CIM property
00063       REFERENCE   = 6,  // A CIM reference
00064       METHOD      = 7,  // A CIM method
00065       PARAMETER   = 8,  // A CIM parameter
00066       QUALIFIER   = 9,     // A CIM qualifier
00067       ANY         = 11, // Any CIM element
00068       MAXSCOPE = 12
00069    };
00073    CIMScope() : CIMBase(), m_val(BAD) {}
00078    CIMScope(Scope scopeVal) : CIMBase(), m_val(scopeVal)
00079    {
00080       if (!validScope(scopeVal))
00081          m_val = BAD;
00082    }
00087    CIMScope(const CIMScope& arg) :
00088       CIMBase(), m_val(arg.m_val) {}
00092    virtual void setNull();
00098    CIMScope& operator= (const CIMScope& arg)
00099    {
00100       m_val = arg.m_val;
00101       return *this;
00102    }
00106    Scope getScope() const {  return m_val; }
00112    bool equals(const CIMScope& arg) const
00113    {
00114       return (m_val == arg.m_val);
00115    }
00121    bool operator == (const CIMScope& arg) const
00122    {
00123       return equals(arg);
00124    }
00130    bool operator != (const CIMScope& arg) const
00131    {
00132       return !equals(arg);
00133    }
00134 
00135    typedef Scope CIMScope::*safe_bool;
00139    operator safe_bool () const
00140       {  return (validScope(m_val) == true) ? &CIMScope::m_val : 0; }
00141    bool operator!() const
00142       {  return !validScope(m_val); }
00146    virtual String toString() const;
00150    virtual String toMOF() const;
00155    virtual void readObject(std::istream &istrm);
00160    virtual void writeObject(std::ostream &ostrm) const;
00161 private:
00162    static bool validScope(Scope val)
00163    {
00164       return (val > BAD && val < MAXSCOPE);
00165    }
00166    Scope m_val;
00167    friend bool operator<(const CIMScope& x, const CIMScope& y)
00168    {
00169       return x.m_val < y.m_val;
00170    }
00171 };
00172 
00173 } // end namespace OW_NAMESPACE
00174 
00175 #endif

Generated on Thu Feb 9 08:47:55 2006 for openwbem by  doxygen 1.4.6