1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_cppu_Shield_hxx 25 #define INCLUDED_cppu_Shield_hxx 26 27 #include <cppu/Map.hxx> 28 29 30 namespace cssu = com::sun::star::uno; 31 32 namespace cppu 33 { 34 /** Helpers for mapping objects relative to the thread-safe and current environments. 35 (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Shield_Helpers) 36 */ 37 38 39 /** Maps an object from the current to the thread-safe Environment, returns mapped object. 40 41 @param pT the object to be mapped 42 @return the mapped object 43 @since UDK 3.2.7 44 */ shield(T * pT)45 template<class T> inline T * shield(T * pT) 46 { 47 return mapOut(pT, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); 48 } 49 50 /** Maps an object from the thread-safe Environment to the current one, returns mapped object. 51 52 @param pT the object to be mapped 53 @return the mapped object 54 @since UDK 3.2.7 55 */ unshield(T * pT)56 template<class T> inline T * unshield(T * pT) 57 { 58 return mapIn(pT, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); 59 } 60 61 62 /** Maps an any from the current to the thread-safe Environment, fills the passed any. 63 64 @param any the any to be mapped 65 @param the target any 66 @since UDK 3.2.7 67 */ shieldAny(cssu::Any const & any,cssu::Any * res)68 inline void shieldAny(cssu::Any const & any, cssu::Any * res) 69 { 70 mapOutAny(any, res, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); 71 } 72 73 74 /** Maps an any from the thread-safe Environment to the current one, fills the passed any. 75 76 @param any the any to be mapped 77 @param the target any 78 @since UDK 3.2.7 79 */ unshieldAny(cssu::Any const & any,cssu::Any * res)80 inline void unshieldAny(cssu::Any const & any, cssu::Any * res) 81 { 82 mapInAny(any, res, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); 83 } 84 } 85 86 #endif 87