Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_STORE_SOURCE_OBJECT_HXX
21 : #define INCLUDED_STORE_SOURCE_OBJECT_HXX
22 :
23 : #include "sal/types.h"
24 : #include "osl/interlck.h"
25 : #include "salhelper/simplereferenceobject.hxx"
26 :
27 : namespace store
28 : {
29 :
30 : /*========================================================================
31 : *
32 : * IStoreHandle interface.
33 : *
34 : *======================================================================*/
35 1926 : class IStoreHandle : public virtual salhelper::SimpleReferenceObject
36 : {
37 : public:
38 : /** Replaces dynamic_cast type checking.
39 : */
40 : virtual bool isKindOf (sal_uInt32 nTypeId) = 0;
41 :
42 : protected:
43 1918 : virtual ~IStoreHandle() {}
44 : };
45 :
46 : /** Template helper function as dynamic_cast replacement.
47 : */
48 : template<class store_handle_type>
49 : store_handle_type * SAL_CALL query (
50 : IStoreHandle * pHandle, store_handle_type *);
51 :
52 : /*========================================================================
53 : *
54 : * OStoreObject interface.
55 : *
56 : *======================================================================*/
57 : class OStoreObject : public store::IStoreHandle
58 : {
59 : /** Template function specialization as dynamic_cast replacement.
60 : */
61 : friend OStoreObject*
62 : SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*);
63 :
64 : public:
65 : /** Construction.
66 : */
67 1926 : OStoreObject() {}
68 :
69 : /** IStoreHandle.
70 : */
71 : virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE;
72 :
73 : protected:
74 : /** Destruction.
75 : */
76 1918 : virtual ~OStoreObject() {}
77 :
78 : private:
79 : /** The IStoreHandle TypeId.
80 : */
81 : static const sal_uInt32 m_nTypeId;
82 : OStoreObject (const OStoreObject&) SAL_DELETED_FUNCTION;
83 : OStoreObject& operator= (const OStoreObject&) SAL_DELETED_FUNCTION;
84 : };
85 :
86 : /** Template function specialization as dynamic_cast replacement.
87 : */
88 : template<> inline OStoreObject*
89 : SAL_CALL query (IStoreHandle *pHandle, OStoreObject*)
90 : {
91 : if (pHandle && pHandle->isKindOf (OStoreObject::m_nTypeId))
92 : {
93 : // Handle is kind of OStoreObject.
94 : return static_cast<OStoreObject*>(pHandle);
95 : }
96 : return 0;
97 : }
98 :
99 : /*========================================================================
100 : *
101 : * The End.
102 : *
103 : *======================================================================*/
104 :
105 : } // namespace store
106 :
107 : #endif // INCLUDED_STORE_SOURCE_OBJECT_HXX
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|