1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: object.hxx,v $
9 * last change: $Author: mhu $ $Date: 2008/09/18 16:10:51 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #ifndef _STORE_OBJECT_HXX_
37 #define _STORE_OBJECT_HXX_ "$Revision: 1.1.2.1 $"
40 #include "sal/types.h"
44 #include "rtl/ref.hxx"
47 #ifndef _OSL_INTERLCK_H_
48 #include "osl/interlck.h"
54 /*========================================================================
56 * IStoreHandle interface.
58 *======================================================================*/
59 class IStoreHandle
: public rtl::IReference
62 /** Replaces dynamic_cast type checking.
64 virtual sal_Bool SAL_CALL
isKindOf (sal_uInt32 nTypeId
) = 0;
68 /** Template helper function as dynamic_cast replacement.
70 template<class store_handle_type
>
71 store_handle_type
* SAL_CALL
query (
72 IStoreHandle
* pHandle
, store_handle_type
*);
74 /*========================================================================
76 * OStoreObject interface.
78 *======================================================================*/
79 class OStoreObject
: public store::IStoreHandle
81 /** Template function specialization as dynamic_cast replacement.
84 SAL_CALL query
<> (IStoreHandle
*pHandle
, OStoreObject
*);
93 static void* operator new (size_t n
);
94 static void operator delete (void *p
, size_t);
98 virtual sal_Bool SAL_CALL
isKindOf (sal_uInt32 nTypeId
);
102 virtual oslInterlockedCount SAL_CALL
acquire (void);
103 virtual oslInterlockedCount SAL_CALL
release (void);
108 virtual ~OStoreObject (void);
111 /** The IStoreHandle TypeId.
113 static const sal_uInt32 m_nTypeId
;
117 oslInterlockedCount m_nRefCount
;
121 OStoreObject (const OStoreObject
&);
122 OStoreObject
& operator= (const OStoreObject
&);
125 /** Template function specialization as dynamic_cast replacement.
127 template<> inline OStoreObject
*
128 SAL_CALL
query (IStoreHandle
*pHandle
, OStoreObject
*)
130 if (pHandle
&& pHandle
->isKindOf (OStoreObject::m_nTypeId
))
132 // Handle is kind of OStoreObject.
133 return static_cast<OStoreObject
*>(pHandle
);
138 /*========================================================================
142 *======================================================================*/
146 #endif /* !_STORE_OBJECT_HXX_ */