1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _STORE_OBJECT_HXX_
21 #define _STORE_OBJECT_HXX_
23 #include "sal/types.h"
25 #include "rtl/ref.hxx"
27 #include "osl/interlck.h"
32 /*========================================================================
34 * IStoreHandle interface.
36 *======================================================================*/
37 class IStoreHandle
: public rtl::IReference
40 /** Replaces dynamic_cast type checking.
42 virtual sal_Bool SAL_CALL
isKindOf (sal_uInt32 nTypeId
) = 0;
49 /** Template helper function as dynamic_cast replacement.
51 template<class store_handle_type
>
52 store_handle_type
* SAL_CALL
query (
53 IStoreHandle
* pHandle
, store_handle_type
*);
55 /*========================================================================
57 * OStoreObject interface.
59 *======================================================================*/
60 class OStoreObject
: public store::IStoreHandle
62 /** Template function specialization as dynamic_cast replacement.
65 SAL_CALL query
<> (IStoreHandle
*pHandle
, OStoreObject
*);
74 static void* operator new (size_t n
);
75 static void operator delete (void *p
);
79 virtual sal_Bool SAL_CALL
isKindOf (sal_uInt32 nTypeId
);
83 virtual oslInterlockedCount SAL_CALL
acquire (void);
84 virtual oslInterlockedCount SAL_CALL
release (void);
89 virtual ~OStoreObject (void);
92 /** The IStoreHandle TypeId.
94 static const sal_uInt32 m_nTypeId
;
98 oslInterlockedCount m_nRefCount
;
102 OStoreObject (const OStoreObject
&);
103 OStoreObject
& operator= (const OStoreObject
&);
106 /** Template function specialization as dynamic_cast replacement.
108 template<> inline OStoreObject
*
109 SAL_CALL
query (IStoreHandle
*pHandle
, OStoreObject
*)
111 if (pHandle
&& pHandle
->isKindOf (OStoreObject::m_nTypeId
))
113 // Handle is kind of OStoreObject.
114 return static_cast<OStoreObject
*>(pHandle
);
119 /*========================================================================
123 *======================================================================*/
127 #endif /* !_STORE_OBJECT_HXX_ */
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */