OWBI1_CIMDetail.hpp

Go to the documentation of this file.
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 #ifndef OWBI1_CIM_DETAIL_HPP_INCLUDE_GUARD_
00036 #define OWBI1_CIM_DETAIL_HPP_INCLUDE_GUARD_
00037 
00038 #include "OWBI1_config.h"
00039 #include "OW_Types.hpp"
00040 
00041 // this header contains internal implementation details. DO NOT USE IT! (unless of course you're working on the OWBI1 implementation :-)
00042 
00043 namespace OWBI1
00044 {
00045 
00046 namespace detail
00047 {
00048 
00049 template <typename T>
00050 struct getRepT
00051 {
00052    typedef void type;
00053 };
00054 
00055 template <>
00056 struct getRepT<CIMObjectPath>
00057 {
00058    typedef CIMObjectPathRep type;
00059 };
00060 
00061 template <>
00062 struct getRepT<CIMDateTime>
00063 {
00064    typedef CIMDateTimeRep type;
00065 };
00066 
00067 template <>
00068 struct getRepT<CIMClass>
00069 {
00070    typedef CIMClassRep type;
00071 };
00072 
00073 template <>
00074 struct getRepT<CIMInstance>
00075 {
00076    typedef CIMInstanceRep type;
00077 };
00078 
00079 template <>
00080 struct getRepT<CIMFlavor>
00081 {
00082    typedef CIMFlavorRep type;
00083 };
00084 
00085 template <>
00086 struct getRepT<CIMScope>
00087 {
00088    typedef CIMScopeRep type;
00089 };
00090 
00091 template <>
00092 struct getRepT<CIMQualifier>
00093 {
00094    typedef CIMQualifierRep type;
00095 };
00096 
00098 template <typename T1, typename T2>
00099 void unwrapArray(T1& out, const T2& in)
00100 {
00101    out.resize(in.size());
00102    for (size_t i = 0; i < in.size(); ++i)
00103    {
00104       out[i] = getOWObj(*in[i].getRep());
00105    }
00106 }
00107 
00109 template <typename T1, typename T2>
00110 T1 unwrapArray(const T2& in)
00111 {
00112    T1 rv(in.size());
00113    for (size_t i = 0; i < in.size(); ++i)
00114    {
00115       rv[i] = getOWObj(*in[i].getRep());
00116    }
00117    return rv;
00118 }
00119 
00121 template <typename T1, typename T2>
00122 void wrapArray(T1& out, const T2& in)
00123 {
00124    out.resize(in.size());
00125    for (size_t i = 0; i < in.size(); ++i)
00126    {
00127       typedef typename getRepT<typename T1::value_type>::type rep_t;
00128       out[i] = typename T1::value_type(new rep_t(in[i]));
00129    }
00130 }
00131 
00133 template <typename T1, typename T2>
00134 T1 wrapArray(const T2& in)
00135 {
00136    T1 rv(in.size());
00137    wrapArray(rv, in);
00138    return rv;
00139 }
00140 
00141 } // end namespace detail
00142 
00143 } // end namespace OWBI1
00144 
00145 #endif
00146 
00147 

Generated on Thu Feb 9 08:48:25 2006 for openwbem by  doxygen 1.4.6