update dev300-m58
[ooovba.git] / store / source / object.hxx
blobbc2a9bbcffe89bc51a85b167bdaa112440a4b94f
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: object.hxx,v $
7 * $Revision: 1.1.2.1 $
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,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 #ifndef _STORE_OBJECT_HXX_
37 #define _STORE_OBJECT_HXX_ "$Revision: 1.1.2.1 $"
39 #ifndef _SAL_TYPES_H_
40 #include "sal/types.h"
41 #endif
43 #ifndef _RTL_REF_HXX_
44 #include "rtl/ref.hxx"
45 #endif
47 #ifndef _OSL_INTERLCK_H_
48 #include "osl/interlck.h"
49 #endif
51 namespace store
54 /*========================================================================
56 * IStoreHandle interface.
58 *======================================================================*/
59 class IStoreHandle : public rtl::IReference
61 public:
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.
83 friend OStoreObject*
84 SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*);
86 public:
87 /** Construction.
89 OStoreObject (void);
91 /** Allocation.
93 static void* operator new (size_t n);
94 static void operator delete (void *p, size_t);
96 /** IStoreHandle.
98 virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
100 /** IReference.
102 virtual oslInterlockedCount SAL_CALL acquire (void);
103 virtual oslInterlockedCount SAL_CALL release (void);
105 protected:
106 /** Destruction.
108 virtual ~OStoreObject (void);
110 private:
111 /** The IStoreHandle TypeId.
113 static const sal_uInt32 m_nTypeId;
115 /** Representation.
117 oslInterlockedCount m_nRefCount;
119 /** Not implemented.
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);
135 return 0;
138 /*========================================================================
140 * The End.
142 *======================================================================*/
144 } // namespace store
146 #endif /* !_STORE_OBJECT_HXX_ */