1*73d9b18aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*73d9b18aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*73d9b18aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*73d9b18aSAndrew Rist * distributed with this work for additional information 6*73d9b18aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*73d9b18aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*73d9b18aSAndrew Rist * "License"); you may not use this file except in compliance 9*73d9b18aSAndrew Rist * with the License. You may obtain a copy of the License at 10*73d9b18aSAndrew Rist * 11*73d9b18aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*73d9b18aSAndrew Rist * 13*73d9b18aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*73d9b18aSAndrew Rist * software distributed under the License is distributed on an 15*73d9b18aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*73d9b18aSAndrew Rist * KIND, either express or implied. See the License for the 17*73d9b18aSAndrew Rist * specific language governing permissions and limitations 18*73d9b18aSAndrew Rist * under the License. 19*73d9b18aSAndrew Rist * 20*73d9b18aSAndrew Rist *************************************************************/ 21*73d9b18aSAndrew Rist 22*73d9b18aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_store.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "object.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "sal/types.h" 30cdf0e10cSrcweir #include "rtl/alloc.h" 31cdf0e10cSrcweir #include "rtl/ref.hxx" 32cdf0e10cSrcweir #include "osl/diagnose.h" 33cdf0e10cSrcweir #include "osl/interlck.h" 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace store 36cdf0e10cSrcweir { 37cdf0e10cSrcweir 38cdf0e10cSrcweir /*======================================================================== 39cdf0e10cSrcweir * 40cdf0e10cSrcweir * OStoreObject implementation. 41cdf0e10cSrcweir * 42cdf0e10cSrcweir *======================================================================*/ 43cdf0e10cSrcweir const sal_uInt32 OStoreObject::m_nTypeId = sal_uInt32(0x58190322); 44cdf0e10cSrcweir 45cdf0e10cSrcweir /* 46cdf0e10cSrcweir * OStoreObject. 47cdf0e10cSrcweir */ OStoreObject(void)48cdf0e10cSrcweirOStoreObject::OStoreObject (void) 49cdf0e10cSrcweir : m_nRefCount (0) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir /* 54cdf0e10cSrcweir * ~OStoreObject. 55cdf0e10cSrcweir */ ~OStoreObject(void)56cdf0e10cSrcweirOStoreObject::~OStoreObject (void) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir OSL_ASSERT(m_nRefCount == 0); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir /* 62cdf0e10cSrcweir * operator new. 63cdf0e10cSrcweir */ operator new(size_t n)64cdf0e10cSrcweirvoid* OStoreObject::operator new (size_t n) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir return rtl_allocateMemory (n); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir /* 70cdf0e10cSrcweir * operator delete. 71cdf0e10cSrcweir */ operator delete(void * p,size_t)72cdf0e10cSrcweirvoid OStoreObject::operator delete (void *p, size_t) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir rtl_freeMemory (p); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir /* 78cdf0e10cSrcweir * isKindOf. 79cdf0e10cSrcweir */ isKindOf(sal_uInt32 nTypeId)80cdf0e10cSrcweirsal_Bool SAL_CALL OStoreObject::isKindOf (sal_uInt32 nTypeId) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir return (nTypeId == m_nTypeId); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir /* 86cdf0e10cSrcweir * acquire. 87cdf0e10cSrcweir */ acquire(void)88cdf0e10cSrcweiroslInterlockedCount SAL_CALL OStoreObject::acquire (void) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir oslInterlockedCount result = osl_incrementInterlockedCount (&m_nRefCount); 91cdf0e10cSrcweir return (result); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir /* 95cdf0e10cSrcweir * release. 96cdf0e10cSrcweir */ release(void)97cdf0e10cSrcweiroslInterlockedCount SAL_CALL OStoreObject::release (void) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir oslInterlockedCount result = osl_decrementInterlockedCount (&m_nRefCount); 100cdf0e10cSrcweir if (result == 0) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir // Last reference released. 103cdf0e10cSrcweir delete this; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir return (result); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir } // namespace store 109