Branch libreoffice-5-0-4
[LibreOffice.git] / store / source / object.hxx
blob40bc287652ad4a3870ab4b32995e739450c6e58f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
27 namespace store
30 /*========================================================================
32 * IStoreHandle interface.
34 *======================================================================*/
35 class IStoreHandle : public virtual salhelper::SimpleReferenceObject
37 public:
38 /** Replaces dynamic_cast type checking.
40 virtual bool isKindOf (sal_uInt32 nTypeId) = 0;
42 protected:
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.
61 friend OStoreObject*
62 SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*);
64 public:
65 /** Construction.
67 OStoreObject() {}
69 /** IStoreHandle.
71 virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE;
73 protected:
74 /** Destruction.
76 virtual ~OStoreObject() {}
78 private:
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);
96 return 0;
99 /*========================================================================
101 * The End.
103 *======================================================================*/
105 } // namespace store
107 #endif // INCLUDED_STORE_SOURCE_OBJECT_HXX
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */