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 INCLUDED_STORE_SOURCE_OBJECT_HXX
21 #define INCLUDED_STORE_SOURCE_OBJECT_HXX
23 #include "sal/types.h"
24 #include "osl/interlck.h"
25 #include "salhelper/simplereferenceobject.hxx"
30 /*========================================================================
32 * IStoreHandle interface.
34 *======================================================================*/
35 class IStoreHandle
: public virtual salhelper::SimpleReferenceObject
38 /** Replaces dynamic_cast type checking.
40 virtual bool isKindOf (sal_uInt32 nTypeId
) = 0;
43 virtual ~IStoreHandle() {}
46 /** Template helper function as dynamic_cast replacement.
48 template<class store_handle_type
>
49 store_handle_type
* SAL_CALL
query (
50 IStoreHandle
* pHandle
, store_handle_type
*);
52 /*========================================================================
54 * OStoreObject interface.
56 *======================================================================*/
57 class OStoreObject
: public store::IStoreHandle
59 /** Template function specialization as dynamic_cast replacement.
62 SAL_CALL query
<> (IStoreHandle
*pHandle
, OStoreObject
*);
71 virtual bool isKindOf (sal_uInt32 nTypeId
) SAL_OVERRIDE
;
76 virtual ~OStoreObject() {}
79 /** The IStoreHandle TypeId.
81 static const sal_uInt32 m_nTypeId
;
82 OStoreObject (const OStoreObject
&) SAL_DELETED_FUNCTION
;
83 OStoreObject
& operator= (const OStoreObject
&) SAL_DELETED_FUNCTION
;
86 /** Template function specialization as dynamic_cast replacement.
88 template<> inline OStoreObject
*
89 SAL_CALL
query (IStoreHandle
*pHandle
, OStoreObject
*)
91 if (pHandle
&& pHandle
->isKindOf (OStoreObject::m_nTypeId
))
93 // Handle is kind of OStoreObject.
94 return static_cast<OStoreObject
*>(pHandle
);
99 /*========================================================================
103 *======================================================================*/
107 #endif // INCLUDED_STORE_SOURCE_OBJECT_HXX
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */