UDK 3.2.7 C/C++ API Reference
cppu/Map.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*************************************************************************
00003  *
00004  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00005  *
00006  * Copyright 2000, 2010 Oracle and/or its affiliates.
00007  *
00008  * OpenOffice.org - a multi-platform office productivity suite
00009  *
00010  * This file is part of OpenOffice.org.
00011  *
00012  * OpenOffice.org is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 3
00014  * only, as published by the Free Software Foundation.
00015  *
00016  * OpenOffice.org is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License version 3 for more details
00020  * (a copy is included in the LICENSE file that accompanied this code).
00021  *
00022  * You should have received a copy of the GNU Lesser General Public License
00023  * version 3 along with OpenOffice.org.  If not, see
00024  * <http://www.openoffice.org/license.html>
00025  * for a copy of the LGPLv3 License.
00026  *
00027  ************************************************************************/
00028 
00029 #ifndef INCLUDED_cppu_Map_hxx
00030 #define INCLUDED_cppu_Map_hxx
00031 
00032 #include <uno/mapping.hxx>
00033 
00034 
00035 namespace cssu = com::sun::star::uno;
00036 
00037 namespace cppu
00038 {
00050     template<class T> inline T * mapOut(T * pT, cssu::Environment const & outerEnv)
00051     {
00052         cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
00053 
00054         return reinterpret_cast<T *>(curr2outer.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
00055     }
00056 
00057 
00065     template<class T> inline T * mapIn(T * pT, cssu::Environment const & outerEnv)
00066     {
00067         cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
00068 
00069         return reinterpret_cast<T *>(outer2curr.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
00070     }
00071 
00072 
00080     // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
00081     inline void mapOutAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
00082     {
00083         cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
00084 
00085         uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release);
00086         uno_type_any_constructAndConvert(
00087             res,
00088             const_cast<void *>(any.getValue()),
00089             any.getValueTypeRef(),
00090             curr2outer.get());
00091     }
00092 
00093 
00101     inline void mapInAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
00102     {
00103         cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
00104 
00105         uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release);
00106         uno_type_any_constructAndConvert(
00107             res,
00108             const_cast<void *>(any.getValue()),
00109             any.getValueTypeRef(),
00110             outer2curr.get());
00111     }
00112 }
00113 
00114 #endif
00115 
00116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines