1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_store.hxx" 30 31 #include "object.hxx" 32 33 #include "sal/types.h" 34 #include "rtl/alloc.h" 35 #include "rtl/ref.hxx" 36 #include "osl/diagnose.h" 37 #include "osl/interlck.h" 38 39 namespace store 40 { 41 42 /*======================================================================== 43 * 44 * OStoreObject implementation. 45 * 46 *======================================================================*/ 47 const sal_uInt32 OStoreObject::m_nTypeId = sal_uInt32(0x58190322); 48 49 /* 50 * OStoreObject. 51 */ 52 OStoreObject::OStoreObject (void) 53 : m_nRefCount (0) 54 { 55 } 56 57 /* 58 * ~OStoreObject. 59 */ 60 OStoreObject::~OStoreObject (void) 61 { 62 OSL_ASSERT(m_nRefCount == 0); 63 } 64 65 /* 66 * operator new. 67 */ 68 void* OStoreObject::operator new (size_t n) 69 { 70 return rtl_allocateMemory (n); 71 } 72 73 /* 74 * operator delete. 75 */ 76 void OStoreObject::operator delete (void *p, size_t) 77 { 78 rtl_freeMemory (p); 79 } 80 81 /* 82 * isKindOf. 83 */ 84 sal_Bool SAL_CALL OStoreObject::isKindOf (sal_uInt32 nTypeId) 85 { 86 return (nTypeId == m_nTypeId); 87 } 88 89 /* 90 * acquire. 91 */ 92 oslInterlockedCount SAL_CALL OStoreObject::acquire (void) 93 { 94 oslInterlockedCount result = osl_incrementInterlockedCount (&m_nRefCount); 95 return (result); 96 } 97 98 /* 99 * release. 100 */ 101 oslInterlockedCount SAL_CALL OStoreObject::release (void) 102 { 103 oslInterlockedCount result = osl_decrementInterlockedCount (&m_nRefCount); 104 if (result == 0) 105 { 106 // Last reference released. 107 delete this; 108 } 109 return (result); 110 } 111 112 } // namespace store 113