update credits
[LibreOffice.git] / store / source / object.hxx
blob91f528a474807120a5ea7fdca6d1c1d6228ef21b
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 _STORE_OBJECT_HXX_
21 #define _STORE_OBJECT_HXX_
23 #include "sal/types.h"
25 #include "rtl/ref.hxx"
27 #include "osl/interlck.h"
29 namespace store
32 /*========================================================================
34 * IStoreHandle interface.
36 *======================================================================*/
37 class IStoreHandle : public rtl::IReference
39 public:
40 /** Replaces dynamic_cast type checking.
42 virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId) = 0;
44 protected:
45 ~IStoreHandle() {}
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.
64 friend OStoreObject*
65 SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*);
67 public:
68 /** Construction.
70 OStoreObject (void);
72 /** Allocation.
74 static void* operator new (size_t n);
75 static void operator delete (void *p);
77 /** IStoreHandle.
79 virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
81 /** IReference.
83 virtual oslInterlockedCount SAL_CALL acquire (void);
84 virtual oslInterlockedCount SAL_CALL release (void);
86 protected:
87 /** Destruction.
89 virtual ~OStoreObject (void);
91 private:
92 /** The IStoreHandle TypeId.
94 static const sal_uInt32 m_nTypeId;
96 /** Representation.
98 oslInterlockedCount m_nRefCount;
100 /** Not implemented.
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);
116 return 0;
119 /*========================================================================
121 * The End.
123 *======================================================================*/
125 } // namespace store
127 #endif /* !_STORE_OBJECT_HXX_ */
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */