summaryrefslogtreecommitdiff
path: root/slideshow/source/inc
diff options
context:
space:
mode:
authorAndre Fischer <af@openoffice.org>2009-04-27 11:42:05 +0000
committerAndre Fischer <af@openoffice.org>2009-04-27 11:42:05 +0000
commit69a4a545a556bd189736b3e510d4b4b07ae8cb6e (patch)
tree33696e0153c26ca3c8cf32b988cc6422688cccee /slideshow/source/inc
parentaa02f1da390cb9b1225de978f8e2965c34e3a45f (diff)
#i48179# Debug: added descriptive strings to events.
Diffstat (limited to 'slideshow/source/inc')
-rw-r--r--slideshow/source/inc/debug.hxx87
-rw-r--r--slideshow/source/inc/delayevent.hxx69
-rw-r--r--slideshow/source/inc/event.hxx14
-rw-r--r--slideshow/source/inc/interruptabledelayevent.hxx5
4 files changed, 155 insertions, 20 deletions
diff --git a/slideshow/source/inc/debug.hxx b/slideshow/source/inc/debug.hxx
new file mode 100644
index 000000000000..e9c501ca58aa
--- /dev/null
+++ b/slideshow/source/inc/debug.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: layer.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SLIDESHOW_DEBUG_HXX
+#define INCLUDED_SLIDESHOW_DEBUG_HXX
+
+#include "animationnode.hxx"
+
+namespace slideshow { namespace internal {
+
+#if OSL_DEBUG_LEVEL > 1
+void Debug_ShowNodeTree (const AnimationNodeSharedPtr& rpNode);
+#endif
+
+// Uncomment the following line to define
+// SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS
+// in order to add descriptions to Event objects that help debugging event
+// base problems.
+#define SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS
+
+
+#if OSL_DEBUG_LEVEL > 1
+
+// Change this to a valid filename. The file is created anew with every
+// office start (and execution of at least one TRACE... command.)
+#define TRACE_LOG_FILE_NAME "d:\\tmp\\log.txt"
+
+class DebugTraceScope
+{
+public:
+ DebugTraceScope (const sal_Char* sFormat, ...);
+ ~DebugTraceScope (void);
+private:
+ static const sal_Int32 mnBufferSize = 512;
+ sal_Char* msMessage;
+};
+
+void SAL_CALL DebugTraceBegin (const sal_Char* sFormat, ...);
+void SAL_CALL DebugTraceEnd (const sal_Char* sFormat, ...);
+void SAL_CALL DebugTraceMessage (const sal_Char* sFormat, ...);
+
+#define TRACE_BEGIN DebugTraceBegin
+#define TRACE_END DebugTraceEnd
+#define TRACE DebugTraceMessage
+#define TRACE_SCOPE DebugTraceScope aTraceScope
+
+#else // OSL_DEBUG_LEVEL > 1
+
+#define TRACE_BEGIN 1 ? ((void)0) : DebugTraceBegin
+#define TRACE_END 1 ? ((void)0) : DebugTraceEnd
+#define TRACE 1 ? ((void)0) : DebugTraceMessage
+#define TRACE_SCOPE
+
+#endif // OSL_DEBUG_LEVEL > 1
+
+
+} }
+
+
+#endif
diff --git a/slideshow/source/inc/delayevent.hxx b/slideshow/source/inc/delayevent.hxx
index 29ef713f6550..458d5f9c0a0e 100644
--- a/slideshow/source/inc/delayevent.hxx
+++ b/slideshow/source/inc/delayevent.hxx
@@ -31,6 +31,7 @@
#define INCLUDED_SLIDESHOW_DELAYEVENT_HXX
#include "event.hxx"
+#include "debug.hxx"
#include <boost/noncopyable.hpp>
#include <boost/function.hpp>
#if defined(VERBOSE) && defined(DBG_UTIL)
@@ -48,16 +49,23 @@ public:
typedef ::boost::function0<void> FunctorT;
template <typename FuncT>
- Delay( FuncT const& func, double nTimeout )
- : mnTimeout(nTimeout), maFunc(func), mbWasFired(false) {}
+ Delay( FuncT const& func,
+ double nTimeout
+#if OSL_DEBUG_LEVEL > 1 && defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+ , const ::rtl::OUString& rsDescription
+ ) : Event(rsDescription),
+#else
+ ) :
+#endif
+ mnTimeout(nTimeout), maFunc(func), mbWasFired(false) {}
-#if defined(VERBOSE) && defined(DBG_UTIL)
Delay( const boost::function0<void>& func,
- double nTimeout,
- char const* const ) :
+ double nTimeout
+#if OSL_DEBUG_LEVEL > 1 && defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+ , const ::rtl::OUString& rsDescription
+ ) : Event(rsDescription),
#else
- Delay( const boost::function0<void>& func,
- double nTimeout ) :
+ ) :
#endif
mnTimeout(nTimeout),
maFunc(func),
@@ -76,7 +84,7 @@ private:
bool mbWasFired;
};
-#if OSL_DEBUG_LEVEL < 1
+#if OSL_DEBUG_LEVEL <= 1
/** Generate delay event
@@ -89,7 +97,7 @@ private:
@return generated delay event
*/
template <typename FuncT>
-inline EventSharedPtr makeDelay( FuncT const& func, double nTimeout )
+inline EventSharedPtr makeDelay_( FuncT const& func, double nTimeout )
{
return EventSharedPtr( new Delay( func, nTimeout ) );
}
@@ -102,19 +110,29 @@ inline EventSharedPtr makeDelay( FuncT const& func, double nTimeout )
@return generated immediate event.
*/
template <typename FuncT>
-inline EventSharedPtr makeEvent( FuncT const& func )
+inline EventSharedPtr makeEvent_( FuncT const& func )
{
return EventSharedPtr( new Delay( func, 0.0 ) );
}
+
+// Strip away description.
+#define makeDelay(f, t, d) makeDelay_(f, t)
+#define makeEvent(f, d) makeEvent_(f)
+
#else // OSL_DEBUG_LEVEL > 1
class Delay_ : public Delay {
public:
template <typename FuncT>
Delay_( FuncT const& func, double nTimeout,
- char const* from_function, char const* from_file, int from_line )
- : Delay(func, nTimeout),
+ char const* from_function, char const* from_file, int from_line,
+ const ::rtl::OUString& rsDescription )
+ : Delay(func, nTimeout
+#if defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+ , rsDescription
+#endif
+ ),
FROM_FUNCTION(from_function),
FROM_FILE(from_file), FROM_LINE(from_line) {}
@@ -126,16 +144,31 @@ public:
template <typename FuncT>
inline EventSharedPtr makeDelay_(
FuncT const& func, double nTimeout,
- char const* from_function, char const* from_file, int from_line )
+ char const* from_function, char const* from_file, int from_line,
+ const ::rtl::OUString& rsDescription )
{
return EventSharedPtr( new Delay_( func, nTimeout,
- from_function, from_file, from_line ) );
+ from_function, from_file, from_line, rsDescription ) );
}
-#define makeDelay(f, t) makeDelay_(f, t, \
-BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)
-#define makeEvent(f) makeDelay_(f, 0.0, \
-BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)
+#if defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+
+#define makeDelay(f, t, d) makeDelay_(f, t, \
+ BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(d)))
+#define makeEvent(f, d) makeDelay_(f, 0.0, \
+ BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(d)))
+
+#else
+
+#define makeDelay(f, t, d) makeDelay_(f, t, \
+ BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)
+#define makeEvent(f, d) makeDelay_(f, 0.0, \
+ BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)
+
+#endif
+
#endif // OSL_DEBUG_LEVEL < 1
diff --git a/slideshow/source/inc/event.hxx b/slideshow/source/inc/event.hxx
index 80e825cc8049..c609c3e814a5 100644
--- a/slideshow/source/inc/event.hxx
+++ b/slideshow/source/inc/event.hxx
@@ -31,7 +31,8 @@
#define INCLUDED_SLIDESHOW_EVENT_HXX
#include "disposable.hxx"
-
+#include "debug.hxx"
+#include <rtl/ustring.hxx>
#include <boost/shared_ptr.hpp>
#include <vector>
@@ -43,6 +44,10 @@ namespace internal {
class Event : public Disposable
{
public:
+#if OSL_DEBUG_LEVEL > 1 && defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+ Event (const ::rtl::OUString& rsDescription) : msDescription(rsDescription) {};
+#endif
+
/** Execute the event.
@return true, if event was successfully executed.
@@ -72,6 +77,13 @@ public:
event is to be fired.
*/
virtual double getActivationTime( double nCurrentTime ) const = 0;
+
+#if OSL_DEBUG_LEVEL > 1 && defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+ ::rtl::OUString GetDescription (void) const { return msDescription; }
+
+private:
+ const ::rtl::OUString msDescription;
+#endif
};
typedef ::boost::shared_ptr< Event > EventSharedPtr;
diff --git a/slideshow/source/inc/interruptabledelayevent.hxx b/slideshow/source/inc/interruptabledelayevent.hxx
index 96795dfa51d4..d983d3ba6cff 100644
--- a/slideshow/source/inc/interruptabledelayevent.hxx
+++ b/slideshow/source/inc/interruptabledelayevent.hxx
@@ -49,6 +49,9 @@ namespace slideshow
public:
DelayFacade( const EventSharedPtr& rEvent,
double nTimeout ) :
+#if OSL_DEBUG_LEVEL > 1 && defined (SLIDESHOW_ADD_DESCRIPTIONS_TO_EVENTS)
+ Event(::rtl::OUString::createFromAscii("DelayFacade")),
+#endif
mpEvent( rEvent ),
mnTimeout( nTimeout )
{
@@ -138,7 +141,7 @@ namespace slideshow
{
InterruptableEventPair aRes;
- aRes.mpImmediateEvent = makeEvent( rFunctor );
+ aRes.mpImmediateEvent = makeEvent( rFunctor, "makeInterruptableDelay");
aRes.mpTimeoutEvent.reset( new DelayFacade( aRes.mpImmediateEvent,
nTimeout ) );