summaryrefslogtreecommitdiff
path: root/canvas/source
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2005-11-02 11:51:13 +0000
committerKurt Zenker <kz@openoffice.org>2005-11-02 11:51:13 +0000
commit9bd69f51ba22f65f5e7128e445ecc7e1a98abed4 (patch)
tree2bbbe3e03b09236798d6b6c141cb05ccc390baf8 /canvas/source
parent5e9163f46a72d21d59e0db8339e3cc491e70b8f6 (diff)
INTEGRATION: CWS canvas02 (1.1.2); FILE ADDED
2005/10/11 15:41:09 thb 1.1.2.2: #i54170# Corrected license headers 2005/08/19 11:03:12 thb 1.1.2.1: #i53538# Added null canvas. This canvas will do nothing, except log all operations (to stderr, currently, but planned are various targets)
Diffstat (limited to 'canvas/source')
-rw-r--r--canvas/source/null/null_usagecounter.hxx84
1 files changed, 84 insertions, 0 deletions
diff --git a/canvas/source/null/null_usagecounter.hxx b/canvas/source/null/null_usagecounter.hxx
new file mode 100644
index 000000000000..2d2e35ad6a91
--- /dev/null
+++ b/canvas/source/null/null_usagecounter.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: null_usagecounter.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: kz $ $Date: 2005-11-02 12:51:13 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef _NULLCANVAS_USAGECOUNTER_HXX
+#define _NULLCANVAS_USAGECOUNTER_HXX
+
+#include <osl/interlck.h>
+#include <boost/current_function.hpp>
+
+namespace nullcanvas
+{
+ /** Little resource tracking counter.
+
+ When using this object, a global use counter, specific to the
+ given type is incremented on object construction, and
+ decremented on object destruction.
+ */
+ template< class Type > class UsageCounter
+ {
+ public:
+ UsageCounter()
+ {
+ OSL_TRACE( "%s, %d objects currently in use.\n",
+ BOOST_CURRENT_FUNCTION,
+ osl_incrementInterlockedCount( &s_nCount ) );
+ }
+
+ ~UsageCounter()
+ {
+ const sal_Int32 nCount( osl_decrementInterlockedCount( &s_nCount ) );
+
+ if( !nCount )
+ {
+ OSL_TRACE( "%s, last instance deleted.\n",
+ BOOST_CURRENT_FUNCTION );
+ }
+ else
+ {
+ OSL_TRACE( "%s, %d instances left.\n",
+ BOOST_CURRENT_FUNCTION,
+ nCount );
+ }
+ }
+
+ private:
+ static oslInterlockedCount s_nCount;
+ };
+
+ template< class Type > oslInterlockedCount UsageCounter<Type>::s_nCount = 0;
+}
+
+#endif /* _NULLCANVAS_USAGECOUNTER_HXX */