1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cachemapobject1.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_UCB_CACHEMAPOBJECT1_HXX
32 #define INCLUDED_UCB_CACHEMAPOBJECT1_HXX
34 #include "osl/interlck.h"
35 #include "osl/mutex.hxx"
36 #include "rtl/ref.hxx"
37 #include "sal/types.h"
38 #include "salhelper/simplereferenceobject.hxx"
44 #ifndef INCLUDED_MEMORY
46 #define INCLUDED_MEMORY
49 namespace rtl
{ class OUString
; }
50 namespace ucb
{ namespace cachemap
{ class Object1
; } }
52 namespace ucb
{ namespace cachemap
{
54 class ObjectContainer1
: public salhelper::SimpleReferenceObject
59 virtual ~ObjectContainer1() SAL_THROW(());
61 rtl::Reference
< Object1
> get(rtl::OUString
const & rKey
);
64 typedef std::map
< rtl::OUString
, Object1
* > Map
;
69 void releaseElement(Object1
* pElement
) SAL_THROW(());
71 friend class Object1
; // to access Map, releaseElement()
77 inline void acquire() SAL_THROW(())
78 { osl_incrementInterlockedCount(&m_nRefCount
); }
80 inline void release() SAL_THROW(())
81 { m_xContainer
->releaseElement(this); }
84 rtl::Reference
< ObjectContainer1
> m_xContainer
;
85 ObjectContainer1::Map::iterator m_aContainerIt
;
86 oslInterlockedCount m_nRefCount
;
88 inline Object1(rtl::Reference
< ObjectContainer1
> const & rContainer
);
90 inline ~Object1() SAL_THROW(());
92 Object1(Object1
&); // not implemented
93 void operator =(Object1
); // not implemented
95 friend class ObjectContainer1
;
96 // to access m_aContainerIt, m_nRefCount, Object1(), ~Object1()
98 friend struct std::auto_ptr
< Object1
>; // to access ~Object1()
99 // work around compiler bug...
101 friend class std::auto_ptr
< Object1
>; // to access ~Object1()
107 #endif // INCLUDED_UCB_CACHEMAPOBJECT1_HXX