1*1a5fa39bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1a5fa39bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1a5fa39bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1a5fa39bSAndrew Rist * distributed with this work for additional information 6*1a5fa39bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1a5fa39bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1a5fa39bSAndrew Rist * "License"); you may not use this file except in compliance 9*1a5fa39bSAndrew Rist * with the License. You may obtain a copy of the License at 10*1a5fa39bSAndrew Rist * 11*1a5fa39bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1a5fa39bSAndrew Rist * 13*1a5fa39bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1a5fa39bSAndrew Rist * software distributed under the License is distributed on an 15*1a5fa39bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1a5fa39bSAndrew Rist * KIND, either express or implied. See the License for the 17*1a5fa39bSAndrew Rist * specific language governing permissions and limitations 18*1a5fa39bSAndrew Rist * under the License. 19*1a5fa39bSAndrew Rist * 20*1a5fa39bSAndrew Rist *************************************************************/ 21*1a5fa39bSAndrew Rist 22*1a5fa39bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _STORE_OBJECT_HXX_ 25cdf0e10cSrcweir #define _STORE_OBJECT_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _SAL_TYPES_H_ 28cdf0e10cSrcweir #include "sal/types.h" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef _RTL_REF_HXX_ 32cdf0e10cSrcweir #include "rtl/ref.hxx" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifndef _OSL_INTERLCK_H_ 36cdf0e10cSrcweir #include "osl/interlck.h" 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace store 40cdf0e10cSrcweir { 41cdf0e10cSrcweir 42cdf0e10cSrcweir /*======================================================================== 43cdf0e10cSrcweir * 44cdf0e10cSrcweir * IStoreHandle interface. 45cdf0e10cSrcweir * 46cdf0e10cSrcweir *======================================================================*/ 47cdf0e10cSrcweir class IStoreHandle : public rtl::IReference 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir /** Replaces dynamic_cast type checking. 51cdf0e10cSrcweir */ 52cdf0e10cSrcweir virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId) = 0; 53cdf0e10cSrcweir }; 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir /** Template helper function as dynamic_cast replacement. 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir template<class store_handle_type> 59cdf0e10cSrcweir store_handle_type * SAL_CALL query ( 60cdf0e10cSrcweir IStoreHandle * pHandle, store_handle_type *); 61cdf0e10cSrcweir 62cdf0e10cSrcweir /*======================================================================== 63cdf0e10cSrcweir * 64cdf0e10cSrcweir * OStoreObject interface. 65cdf0e10cSrcweir * 66cdf0e10cSrcweir *======================================================================*/ 67cdf0e10cSrcweir class OStoreObject : public store::IStoreHandle 68cdf0e10cSrcweir { 69cdf0e10cSrcweir /** Template function specialization as dynamic_cast replacement. 70cdf0e10cSrcweir */ 71cdf0e10cSrcweir friend OStoreObject* 72cdf0e10cSrcweir SAL_CALL query<> (IStoreHandle *pHandle, OStoreObject*); 73cdf0e10cSrcweir 74cdf0e10cSrcweir public: 75cdf0e10cSrcweir /** Construction. 76cdf0e10cSrcweir */ 77cdf0e10cSrcweir OStoreObject (void); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Allocation. 80cdf0e10cSrcweir */ 81cdf0e10cSrcweir static void* operator new (size_t n); 82cdf0e10cSrcweir static void operator delete (void *p, size_t); 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** IStoreHandle. 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** IReference. 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL acquire (void); 91cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL release (void); 92cdf0e10cSrcweir 93cdf0e10cSrcweir protected: 94cdf0e10cSrcweir /** Destruction. 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir virtual ~OStoreObject (void); 97cdf0e10cSrcweir 98cdf0e10cSrcweir private: 99cdf0e10cSrcweir /** The IStoreHandle TypeId. 100cdf0e10cSrcweir */ 101cdf0e10cSrcweir static const sal_uInt32 m_nTypeId; 102cdf0e10cSrcweir 103cdf0e10cSrcweir /** Representation. 104cdf0e10cSrcweir */ 105cdf0e10cSrcweir oslInterlockedCount m_nRefCount; 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** Not implemented. 108cdf0e10cSrcweir */ 109cdf0e10cSrcweir OStoreObject (const OStoreObject&); 110cdf0e10cSrcweir OStoreObject& operator= (const OStoreObject&); 111cdf0e10cSrcweir }; 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** Template function specialization as dynamic_cast replacement. 114cdf0e10cSrcweir */ 115cdf0e10cSrcweir template<> inline OStoreObject* query(IStoreHandle * pHandle,OStoreObject *)116cdf0e10cSrcweirSAL_CALL query (IStoreHandle *pHandle, OStoreObject*) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir if (pHandle && pHandle->isKindOf (OStoreObject::m_nTypeId)) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir // Handle is kind of OStoreObject. 121cdf0e10cSrcweir return static_cast<OStoreObject*>(pHandle); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir return 0; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir /*======================================================================== 127cdf0e10cSrcweir * 128cdf0e10cSrcweir * The End. 129cdf0e10cSrcweir * 130cdf0e10cSrcweir *======================================================================*/ 131cdf0e10cSrcweir 132cdf0e10cSrcweir } // namespace store 133cdf0e10cSrcweir 134cdf0e10cSrcweir #endif /* !_STORE_OBJECT_HXX_ */ 135