1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2011 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "sal/config.h" 29 30 #include "com/sun/star/uno/RuntimeException.hpp" 31 #include "rtl/byteseq.hxx" 32 #include "osl/mutex.hxx" 33 34 #include "lessoperators.hxx" 35 #include "outgoingrequest.hxx" 36 #include "outgoingrequests.hxx" 37 38 namespace binaryurp { 39 40 namespace { 41 42 namespace css = com::sun::star; 43 44 } 45 46 OutgoingRequests::OutgoingRequests() {} 47 48 OutgoingRequests::~OutgoingRequests() {} 49 50 void OutgoingRequests::push( 51 rtl::ByteSequence const & tid, OutgoingRequest const & request) 52 { 53 osl::MutexGuard g(mutex_); 54 map_[tid].push_back(request); 55 } 56 57 OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) { 58 osl::MutexGuard g(mutex_); 59 Map::iterator i(map_.find(tid)); 60 if (i == map_.end()) { 61 throw css::uno::RuntimeException( 62 rtl::OUString( 63 RTL_CONSTASCII_USTRINGPARAM("URP: reply for unknown TID")), 64 css::uno::Reference< css::uno::XInterface >()); 65 } 66 OSL_ASSERT(!i->second.empty()); 67 return i->second.back(); 68 } 69 70 void OutgoingRequests::pop(rtl::ByteSequence const & tid) throw () { 71 osl::MutexGuard g(mutex_); 72 Map::iterator i(map_.find(tid)); 73 OSL_ASSERT(i != map_.end()); 74 i->second.pop_back(); 75 if (i->second.empty()) { 76 map_.erase(i); 77 } 78 } 79 80 } 81