summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svl/inc/pch/precompiled_svl.hxx4
-rw-r--r--svtools/inc/pch/precompiled_svtools.hxx4
-rw-r--r--svtools/source/misc/templatefoldercache.cxx56
-rw-r--r--vos/inc/vos/connectn.hxx118
-rw-r--r--vos/inc/vos/ref.hxx184
-rw-r--r--vos/inc/vos/timer.hxx202
-rw-r--r--vos/source/makefile.mk2
-rw-r--r--vos/source/timer.cxx504
8 files changed, 32 insertions, 1042 deletions
diff --git a/svl/inc/pch/precompiled_svl.hxx b/svl/inc/pch/precompiled_svl.hxx
index 276e1c60b3bd..e142013b0ea5 100644
--- a/svl/inc/pch/precompiled_svl.hxx
+++ b/svl/inc/pch/precompiled_svl.hxx
@@ -385,6 +385,7 @@
#include <rtl/logfile.hxx>
#include <rtl/math.hxx>
#include <rtl/memory.h>
+#include <rtl/ref.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/string.hxx>
#include <rtl/tencinfo.h>
@@ -395,6 +396,7 @@
#include <rtl/ustring.hxx>
#include <rtl/uuid.h>
+#include <salhelper/simplereferenceobject.hxx>
#include <salhelper/timer.hxx>
#include <sot/clsids.hxx>
@@ -421,8 +423,6 @@
#include <vos/mutex.hxx>
#include <vos/process.hxx>
-#include <vos/ref.hxx>
-#include <vos/refernce.hxx>
#include <vos/security.hxx>
#include <vos/thread.hxx>
diff --git a/svtools/inc/pch/precompiled_svtools.hxx b/svtools/inc/pch/precompiled_svtools.hxx
index fce981e33e08..7aafdc3025e5 100644
--- a/svtools/inc/pch/precompiled_svtools.hxx
+++ b/svtools/inc/pch/precompiled_svtools.hxx
@@ -385,6 +385,7 @@
#include <rtl/logfile.hxx>
#include <rtl/math.hxx>
#include <rtl/memory.h>
+#include <rtl/ref.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/string.hxx>
#include <rtl/tencinfo.h>
@@ -395,6 +396,7 @@
#include <rtl/ustring.hxx>
#include <rtl/uuid.h>
+#include <salhelper/simplereferenceobject.hxx>
#include <salhelper/timer.hxx>
#include <sot/clsids.hxx>
@@ -425,8 +427,6 @@
#include <vos/mutex.hxx>
#include <vos/process.hxx>
-#include <vos/ref.hxx>
-#include <vos/refernce.hxx>
//---MARKER---
diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx
index 7635803c9372..366037c7a1d3 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -39,8 +39,8 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/util/XOfficeInstallationDirectories.hpp>
#include <ucbhelper/content.hxx>
-#include <vos/ref.hxx>
-#include <vos/refernce.hxx>
+#include <rtl/ref.hxx>
+#include <salhelper/simplereferenceobject.hxx>
#include <tools/urlobj.hxx>
#include <tools/debug.hxx>
#include <unotools/pathoptions.hxx>
@@ -116,13 +116,13 @@ namespace svt
//= TemplateContent
//=====================================================================
struct TemplateContent;
- typedef ::std::vector< ::vos::ORef< TemplateContent > > TemplateFolderContent;
+ typedef ::std::vector< ::rtl::Reference< TemplateContent > > TemplateFolderContent;
typedef TemplateFolderContent::const_iterator ConstFolderIterator;
typedef TemplateFolderContent::iterator FolderIterator;
/** a struct describing one content in one of the template dirs (or at least it's relevant aspects)
*/
- struct TemplateContent : public ::vos::OReference
+ struct TemplateContent : public ::salhelper::SimpleReferenceObject
{
public:
@@ -161,7 +161,7 @@ namespace svt
inline TemplateFolderContent::size_type
size() const { return m_aSubContents.size(); }
- inline void push_back( const ::vos::ORef< TemplateContent >& _rxNewElement )
+ inline void push_back( const ::rtl::Reference< TemplateContent >& _rxNewElement )
{ m_aSubContents.push_back( _rxNewElement ); }
};
@@ -207,12 +207,12 @@ namespace svt
//---------------------------------------------------------------------
/// compares two TemplateContent by URL
struct TemplateContentURLLess
- :public ::std::binary_function < ::vos::ORef< TemplateContent >
- , ::vos::ORef< TemplateContent >
+ :public ::std::binary_function < ::rtl::Reference< TemplateContent >
+ , ::rtl::Reference< TemplateContent >
, bool
>
{
- bool operator() ( const ::vos::ORef< TemplateContent >& _rxLHS, const ::vos::ORef< TemplateContent >& _rxRHS ) const
+ bool operator() ( const ::rtl::Reference< TemplateContent >& _rxLHS, const ::rtl::Reference< TemplateContent >& _rxRHS ) const
{
return _rxLHS->getURL() < _rxRHS->getURL()
? true
@@ -222,7 +222,7 @@ namespace svt
//---------------------------------------------------------------------
/// sorts the sib contents of a TemplateFolderContent
- struct SubContentSort : public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ struct SubContentSort : public ::std::unary_function< ::rtl::Reference< TemplateContent >, void >
{
void operator() ( TemplateFolderContent& _rFolder ) const
{
@@ -241,9 +241,9 @@ namespace svt
);
}
- void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ void operator() ( const ::rtl::Reference< TemplateContent >& _rxContent ) const
{
- if ( _rxContent.isValid() && _rxContent->size() )
+ if ( _rxContent.is() && _rxContent->size() )
{
operator()( _rxContent->getSubContents() );
}
@@ -253,15 +253,15 @@ namespace svt
/** does a deep compare of two template contents
*/
struct TemplateContentEqual
- :public ::std::binary_function < ::vos::ORef< TemplateContent >
- , ::vos::ORef< TemplateContent >
+ :public ::std::binary_function < ::rtl::Reference< TemplateContent >
+ , ::rtl::Reference< TemplateContent >
, bool
>
{
//.................................................................
- bool operator() (const ::vos::ORef< TemplateContent >& _rLHS, const ::vos::ORef< TemplateContent >& _rRHS )
+ bool operator() (const ::rtl::Reference< TemplateContent >& _rLHS, const ::rtl::Reference< TemplateContent >& _rRHS )
{
- if ( !_rLHS.isValid() || !_rRHS.isValid() )
+ if ( !_rLHS.is() || !_rRHS.is() )
{
DBG_ERROR( "TemplateContentEqual::operator(): invalid contents!" );
return true;
@@ -320,12 +320,12 @@ namespace svt
//---------------------------------------------------------------------
/// functor which stores the local name of a TemplateContent
struct StoreLocalContentName
- :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ :public ::std::unary_function< ::rtl::Reference< TemplateContent >, void >
,public StoreString
{
StoreLocalContentName( SvStream& _rStorage ) : StoreString( _rStorage ) { }
- void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ void operator() ( const ::rtl::Reference< TemplateContent >& _rxContent ) const
{
DBG_ERRORFILE( "This method must not be used, the whole URL must be stored!" );
@@ -336,7 +336,7 @@ namespace svt
//---------------------------------------------------------------------
struct StoreContentURL
- :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ :public ::std::unary_function< ::rtl::Reference< TemplateContent >, void >
,public StoreString
{
uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
@@ -347,7 +347,7 @@ namespace svt
xOfficeInstDirs )
: StoreString( _rStorage ), m_xOfficeInstDirs( xOfficeInstDirs ) { }
- void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ void operator() ( const ::rtl::Reference< TemplateContent >& _rxContent ) const
{
// use the base class operator with the local name of the content
String sURL = _rxContent->getURL();
@@ -361,7 +361,7 @@ namespace svt
//---------------------------------------------------------------------
/// functor which stores the complete content of a TemplateContent
struct StoreFolderContent
- :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ :public ::std::unary_function< ::rtl::Reference< TemplateContent >, void >
,public StorageHelper
{
uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
@@ -397,9 +397,9 @@ namespace svt
}
//.................................................................
- void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ void operator() ( const ::rtl::Reference< TemplateContent >& _rxContent ) const
{
- if ( _rxContent.isValid() )
+ if ( _rxContent.is() )
{
operator()( *_rxContent );
}
@@ -409,7 +409,7 @@ namespace svt
//---------------------------------------------------------------------
/// functor which reads a complete TemplateContent instance
struct ReadFolderContent
- :public ::std::unary_function< ::vos::ORef< TemplateContent >, void >
+ :public ::std::unary_function< ::rtl::Reference< TemplateContent >, void >
,public StorageHelper
{
uno::Reference< util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
@@ -454,9 +454,9 @@ namespace svt
}
//.................................................................
- void operator() ( const ::vos::ORef< TemplateContent >& _rxContent ) const
+ void operator() ( const ::rtl::Reference< TemplateContent >& _rxContent ) const
{
- if ( _rxContent.isValid() )
+ if ( _rxContent.is() )
{
operator()( *_rxContent );
}
@@ -501,7 +501,7 @@ namespace svt
String implParseSmart( const String& _rPath );
- sal_Bool implReadFolder( const ::vos::ORef< TemplateContent >& _rxRoot );
+ sal_Bool implReadFolder( const ::rtl::Reference< TemplateContent >& _rxRoot );
static String getCacheFileName();
static sal_Int32 getMagicNumber();
@@ -628,7 +628,7 @@ namespace svt
}
//---------------------------------------------------------------------
- sal_Bool TemplateFolderCacheImpl::implReadFolder( const ::vos::ORef< TemplateContent >& _rxRoot )
+ sal_Bool TemplateFolderCacheImpl::implReadFolder( const ::rtl::Reference< TemplateContent >& _rxRoot )
{
try
{
@@ -670,7 +670,7 @@ namespace svt
INetURLObject aSubContentURL( xContentAccess->queryContentIdentifierString() );
// a new content instance
- ::vos::ORef< TemplateContent > xChild = new TemplateContent( aSubContentURL );
+ ::rtl::Reference< TemplateContent > xChild = new TemplateContent( aSubContentURL );
// the modified date
xChild->setModDate( xRow->getTimestamp( 2 ) ); // date modified
diff --git a/vos/inc/vos/connectn.hxx b/vos/inc/vos/connectn.hxx
deleted file mode 100644
index 0e806eefabc0..000000000000
--- a/vos/inc/vos/connectn.hxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 _VOS_CONNECTN_HXX_
-#define _VOS_CONNECTN_HXX_
-
-# include <vos/ref.hxx>
-# include <rtl/ustring.hxx>
-
-namespace vos
-{
-//---------------------------------------------------------------------------
-/** abstract connection class
- */
-
-class IConnection: public ::vos::IReference
-{
-public:
-
- //---------------------------------------------------------------------------
- /** reads the specified amount of bytes from the stream. The call will block
- until nBytesToRead bytes are available.
-
- @param pData
- pointer to the buffer to fill.
-
- @param nBytesToRead
- the number of bytes to read.
-
- @returns
- the number of bytes read;
- */
-
- virtual sal_Int32 SAL_CALL read( sal_Int8* pData, sal_Int32 nBytesToRead ) = 0;
-
- //---------------------------------------------------------------------------
- /** tries to read the specified amount of bytes from the stream.
-
- @param pData
- pointer to the buffer to fill.
-
- @param nBytesToRead
- the maximum number of bytes to read.
-
- @returns
- the number of bytes read;
- */
-
- virtual sal_Int32 SAL_CALL readSomeBytes( sal_Int8* pData, sal_Int32 nBytesToRead ) = 0;
-
- //---------------------------------------------------------------------------
- /** writes the specified number of bytes to the stream.
-
- @param pData
- pointer to the buffer to read from.
-
- @param nBytesToWrite
- the number of bytes to write.
- */
-
- virtual sal_Int32 SAL_CALL write( const sal_Int8* pData , sal_Int32 nBytesToWrite ) = 0;
-
- //---------------------------------------------------------------------------
- /** flushes all output data to the stream.
- */
-
- virtual sal_Int32 SAL_CALL flush() = 0;
-
- //---------------------------------------------------------------------------
- /** closes the stream of the connection.
-
- NOTE: implementation must be able to handle more than one close calls.
- */
-
- virtual sal_Int32 SAL_CALL close() = 0;
-
- //---------------------------------------------------------------------------
- /** gets the source address
- */
- virtual ::rtl::OUString SAL_CALL getSource() = 0;
-
- //---------------------------------------------------------------------------
- /** gets the destination address
- */
- virtual ::rtl::OUString SAL_CALL getDestination() = 0;
-};
-
-}
-
-#endif // _VOS_CONNECTN_HXX_
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vos/inc/vos/ref.hxx b/vos/inc/vos/ref.hxx
deleted file mode 100644
index 08c1ec097d10..000000000000
--- a/vos/inc/vos/ref.hxx
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 _VOS_REF_HXX_
-#define _VOS_REF_HXX_
-
-/**
- ORef<T>
-
- template type to implement handle/body behaviour
- with reference-counting.
-
- Note that the template-type T MUST implement IReferenceCounter.
-
-*/
-
-#include <vos/refernce.hxx>
-#include <osl/diagnose.h>
-
-namespace vos
-{
-
-
-template <class T>
-class ORef
-{
-public:
-
- /** Creates an "empty" reference, use "create()" or
- assignment/copy-operator to make it a valid reference.
- */
- ORef();
-
- /** Creates a reference which points to pBody.
- pBodys reference is not changed!. (like create(...)).
- */
- ORef(T* pBody);
-
- /** Overload copy-constr. to implement ref-counting.
- As a result of the following code:
-
- ORef<x> h1, h2;
-
- h1.create();
- h2= h1;
-
- h1 and h2 will represent the same body.
-
- */
- ORef(const ORef<T>& handle);
-
- /** Decreases ref-count of underlying body.
- */
- inline ~ORef();
-
- /** Overload assignment-operator to implement ref-counting.
- Unbinds this instance from its body (if bound) and
- bind it to the body represented by the handle.
- */
- ORef<T>& SAL_CALL operator= (const ORef<T>& handle);
-
-
-
- /** Binds the body to this handle.
- The "pBody"s reference-count is increased.
-
- If you call bind() on an existing body,
- the old body is unbound before the new one is
- assigned.
-
- */
- void SAL_CALL bind(T* pBody);
-
- /** Unbind the body from this handle.
- Note that for a handle representing a large body,
- "handle.unbind().bind(new body());" _might_
- perform a little bit better than "handle.bind(new body());",
- since in the second case two large objects exist in memory
- (the old body and the new body).
- */
- ORef<T>& SAL_CALL unbind();
-
- /** Same as bind().
- */
- void SAL_CALL operator= (T* pBody);
-
- /** Just in case you want to call handle().someBodyOp()...
- */
- T& SAL_CALL operator() () const;
-
- /** Allows (*handle).someBodyOp().
- */
- T& SAL_CALL operator* () const;
-
- /** Probably most common used: handle->someBodyOp().
- */
- T* SAL_CALL operator->() const;
-
- /** Gives access to the handles body.
- */
- T& SAL_CALL getBody() const;
-
- /** Can be used instead of operator->.
- I.e. handle->someBodyOp() and handle.getBodyPtr()->someBodyOp()
- are the same.
- */
- T* SAL_CALL getBodyPtr() const;
-
- /** Returns True is the body is empty (the handle
- does not point to a valid body).
- */
- sal_Bool SAL_CALL isEmpty() const;
-
- /** Returns True is the body is "full" (the handle
- does point to a valid body).
- */
- sal_Bool SAL_CALL isValid() const;
-
- /** Returns True is handle points to the same body.
- */
- sal_Bool SAL_CALL isEqualBody(const ORef<T>& handle) const;
-
- /** Delegates comparison to the body.
- */
- sal_Bool SAL_CALL operator== (const ORef<T>& handle) const;
-
- /** Delegates comparison to the body.
- */
- sal_Bool SAL_CALL operator!= (const ORef<T>& handle) const;
-
- /** Returns True is "this" points to pBody.
- */
- sal_Bool SAL_CALL operator== (const T* pBody) const;
-
- /** Needed to place ORefs into STL collection.
- Delegates comparison to the body.
- */
- sal_Bool SAL_CALL operator< (const ORef<T>& handle) const;
-
- /** Needed to place ORefs into STL collection.
- Delegates comparison to the body.
- */
- sal_Bool SAL_CALL operator> (const ORef<T>& handle) const;
-
-protected:
-
- T* m_refBody;
-};
-
-// include template implementation
-#include <vos/ref.inl>
-
-}
-
-
-#endif // _VOS_REF_HXX_
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vos/inc/vos/timer.hxx b/vos/inc/vos/timer.hxx
deleted file mode 100644
index 4b518ac71970..000000000000
--- a/vos/inc/vos/timer.hxx
+++ /dev/null
@@ -1,202 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 _VOS_TIMER_HXX_
-#define _VOS_TIMER_HXX_
-
-# include <vos/refernce.hxx>
-# include <vos/mutex.hxx>
-# include <osl/time.h>
-
-
-namespace vos
-{
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// TTimeValue
-//
-
-/** <code> struct TTimeValue </code> : class for times. Times are seconds in UTC since 01.01.1970
- */
-struct TTimeValue : public TimeValue
-{
- TTimeValue()
- { Seconds = 0; Nanosec = 0; }
-
- TTimeValue(sal_uInt32 Seconds, sal_uInt32 Nano);
-
- TTimeValue(sal_uInt32 MilliSecs)
- { Seconds = MilliSecs / 1000L; Nanosec = (MilliSecs % 1000) * 1000000L; }
-
- TTimeValue(const TTimeValue& rTimeValue)
- { Seconds = rTimeValue.Seconds; Nanosec = rTimeValue.Nanosec; }
-
- TTimeValue(const TimeValue& rTimeValue)
- { Seconds = rTimeValue.Seconds; Nanosec = rTimeValue.Nanosec; }
-
- void SAL_CALL normalize();
-
- void SAL_CALL addTime(const TTimeValue& Delta);
-
- sal_Bool SAL_CALL isEmpty() const;
-};
-
-inline void TTimeValue::normalize()
-{
- if (Nanosec > 1000000000)
- {
- Seconds += Nanosec / 1000000000;
- Nanosec %= 1000000000;
- }
-}
-
-inline TTimeValue::TTimeValue(sal_uInt32 Secs, sal_uInt32 Nano)
-{
- Seconds = Secs;
- Nanosec = Nano;
-
- normalize();
-}
-
-inline void TTimeValue::addTime(const TTimeValue& Time)
-{
- Seconds += Time.Seconds;
- Nanosec += Time.Nanosec;
-
- normalize();
-}
-
-inline sal_Bool TTimeValue::isEmpty() const
-{
- return ((Seconds == 0) && (Nanosec == 0));
-}
-
-inline sal_Bool operator<(const TTimeValue& rTimeA, const TTimeValue& rTimeB)
-{
- if (rTimeA.Seconds < rTimeB.Seconds)
- return sal_True;
- else if (rTimeA.Seconds > rTimeB.Seconds)
- return sal_False;
- else
- return (rTimeA.Nanosec < rTimeB.Nanosec);
-}
-
-inline sal_Bool operator>(const TTimeValue& rTimeA, const TTimeValue& rTimeB)
-{
- if (rTimeA.Seconds > rTimeB.Seconds)
- return sal_True;
- else if (rTimeA.Seconds < rTimeB.Seconds)
- return sal_False;
- else
- return (rTimeA.Nanosec > rTimeB.Nanosec);
-}
-
-inline sal_Bool operator==(const TTimeValue& rTimeA, const TTimeValue& rTimeB)
-{
- return ((rTimeA.Seconds == rTimeB.Seconds) &&
- (rTimeA.Nanosec == rTimeB.Nanosec));
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Timer class
-//
-
-class OTimerManager;
-
-/** <code> class OTimer </code> : Interface for the Timer and handling the event
-*/
-class OTimer : virtual public OReference , virtual public OObject
-{
- VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OTimer, vos));
-
-public:
-
- /// constructor
- OTimer();
- /// constructor
- OTimer(const TTimeValue& Time);
- /// constructor
- OTimer(const TTimeValue& Time, const TTimeValue& RepeatTime);
- /// start timer.
- void SAL_CALL start();
- /// abort timer prematurely.
- void SAL_CALL stop();
- /// returns <code> sal_True </code> if timer is running.
- sal_Bool SAL_CALL isTicking() const;
- /// is the timer expired?
- sal_Bool SAL_CALL isExpired() const;
- /// does <code> pTimer </code> expires before us?
- sal_Bool SAL_CALL expiresBefore(const OTimer* pTimer) const;
- /// set the absolute time when the timer should fire
- void SAL_CALL setAbsoluteTime(const TTimeValue& Time);
- /// set the time to fire to 'now' + <code> Remaining </code>
- void SAL_CALL setRemainingTime(const TTimeValue& Remaining);
- /// set the time to fire to 'now' + <code> Remaining </code> with repeat interveal <code> Repeat </code>
- void SAL_CALL setRemainingTime(const TTimeValue& Remaining, const TTimeValue& Repeat);
- /// adds <code> Time </code> to the 'fire time'
- void SAL_CALL addTime(const TTimeValue& Time);
- /// returns the remaining time before timer expiration relative to now
- TTimeValue SAL_CALL getRemainingTime() const;
-
-protected:
-
- /// destructor
- virtual ~OTimer();
- /// what should be done when the 'timer fires'
- virtual void SAL_CALL onShot() = 0;
-
- /// holds (initial) exparation time of this timer
- TTimeValue m_TimeOut;
- /// holds the time of exparation of this timer
- TTimeValue m_Expired;
- /// holds the time interveal of successive exparations
- TTimeValue m_RepeatDelta;
- /// Pointer to the next timer (to fire)
- OTimer* m_pNext;
-
-private:
-
- /// copy constructor disabled
- OTimer(const OTimer& rTimer);
- /// assignment operator disabled
- void SAL_CALL operator=(const OTimer& rTimer);
-
- friend class OTimerManager;
-};
-
-}
-
-
-#endif //_VOS_TIMER_HXX_
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vos/source/makefile.mk b/vos/source/makefile.mk
index 95aa1d0325be..71faed51b33f 100644
--- a/vos/source/makefile.mk
+++ b/vos/source/makefile.mk
@@ -43,7 +43,6 @@ SLOFILES= $(SLO)$/mutex.obj \
$(SLO)$/thread.obj \
$(SLO)$/stream.obj \
$(SLO)$/module.obj \
- $(SLO)$/timer.obj \
$(SLO)$/process.obj \
$(SLO)$/xception.obj
@@ -55,7 +54,6 @@ OBJFILES= $(OBJ)$/mutex.obj \
$(OBJ)$/thread.obj \
$(OBJ)$/stream.obj \
$(OBJ)$/module.obj \
- $(OBJ)$/timer.obj \
$(OBJ)$/process.obj \
$(OBJ)$/xception.obj
diff --git a/vos/source/timer.cxx b/vos/source/timer.cxx
deleted file mode 100644
index 4197a0090209..000000000000
--- a/vos/source/timer.cxx
+++ /dev/null
@@ -1,504 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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.
- *
- ************************************************************************/
-
-#include <osl/time.h>
-
-#include <vos/timer.hxx>
-#include <osl/diagnose.h>
-#include <vos/ref.hxx>
-#include <vos/thread.hxx>
-#include <osl/conditn.hxx>
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Timer manager
-//
-
-class OTimerManagerCleanup;
-
-class NAMESPACE_VOS(OTimerManager) : public NAMESPACE_VOS(OThread)
-{
-
-public:
-
- ///
- OTimerManager();
-
- ///
- ~OTimerManager();
-
- /// register timer
- sal_Bool SAL_CALL registerTimer(NAMESPACE_VOS(OTimer)* pTimer);
-
- /// unregister timer
- sal_Bool SAL_CALL unregisterTimer(NAMESPACE_VOS(OTimer)* pTimer);
-
- /// lookup timer
- sal_Bool SAL_CALL lookupTimer(const NAMESPACE_VOS(OTimer)* pTimer);
-
- /// retrieves the "Singleton" TimerManager Instance
- static OTimerManager* SAL_CALL getTimerManager();
-
-
-protected:
-
- /// worker-function of thread
- virtual void SAL_CALL run();
-
- // Checking and triggering of a timer event
- void SAL_CALL checkForTimeout();
-
- // cleanup Method
- virtual void SAL_CALL onTerminated();
-
- // sorted-queue data
- NAMESPACE_VOS(OTimer)* m_pHead;
- // List Protection
- NAMESPACE_VOS(OMutex) m_Lock;
- // Signal the insertion of a timer
- osl::Condition m_notEmpty;
-
- // Synchronize access to OTimerManager
- static NAMESPACE_VOS(OMutex) m_Access;
-
- // "Singleton Pattern"
- static NAMESPACE_VOS(OTimerManager)* m_pManager;
-
- friend class OTimerManagerCleanup;
-
-};
-
-using namespace vos;
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Timer class
-//
-
-VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OTimer, vos),
- VOS_NAMESPACE(OTimer, vos),
- VOS_NAMESPACE(OObject, vos), 0);
-
-OTimer::OTimer()
-{
- m_TimeOut = 0;
- m_Expired = 0;
- m_RepeatDelta = 0;
- m_pNext = 0;
-}
-
-OTimer::OTimer(const TTimeValue& Time)
-{
- m_TimeOut = Time;
- m_RepeatDelta = 0;
- m_Expired = 0;
- m_pNext = 0;
-
- m_TimeOut.normalize();
-}
-
-OTimer::OTimer(const TTimeValue& Time, const TTimeValue& Repeat)
-{
- m_TimeOut = Time;
- m_RepeatDelta = Repeat;
- m_Expired = 0;
- m_pNext = 0;
-
- m_TimeOut.normalize();
- m_RepeatDelta.normalize();
-}
-
-OTimer::~OTimer()
-{
- stop();
-}
-
-void OTimer::start()
-{
- if (! isTicking())
- {
- if (! m_TimeOut.isEmpty())
- setRemainingTime(m_TimeOut);
-
- OTimerManager *pManager = OTimerManager::getTimerManager();
-
- OSL_ASSERT(pManager);
-
- if ( pManager != 0 )
- {
- pManager->registerTimer(this);
- }
- }
-}
-
-void OTimer::stop()
-{
- OTimerManager *pManager = OTimerManager::getTimerManager();
-
- OSL_ASSERT(pManager);
-
- if ( pManager != 0 )
- {
- pManager->unregisterTimer(this);
- }
-}
-
-sal_Bool OTimer::isTicking() const
-{
- OTimerManager *pManager = OTimerManager::getTimerManager();
-
- OSL_ASSERT(pManager);
-
- if (pManager)
- return pManager->lookupTimer(this);
- else
- return sal_False;
-
-}
-
-sal_Bool OTimer::isExpired() const
-{
- TTimeValue Now;
-
- osl_getSystemTime(&Now);
-
- return !(Now < m_Expired);
-}
-
-sal_Bool OTimer::expiresBefore(const OTimer* pTimer) const
-{
- OSL_ASSERT(pTimer);
-
- if ( pTimer != 0 )
- {
- return m_Expired < pTimer->m_Expired;
- }
- else
- {
- return sal_False;
- }
-}
-
-void OTimer::setAbsoluteTime(const TTimeValue& Time)
-{
- m_TimeOut = 0;
- m_Expired = Time;
- m_RepeatDelta = 0;
-
- m_Expired.normalize();
-}
-
-void OTimer::setRemainingTime(const TTimeValue& Remaining)
-{
- osl_getSystemTime(&m_Expired);
-
- m_Expired.addTime(Remaining);
-}
-
-void OTimer::setRemainingTime(const TTimeValue& Remaining, const TTimeValue& Repeat)
-{
- osl_getSystemTime(&m_Expired);
-
- m_Expired.addTime(Remaining);
-
- m_RepeatDelta = Repeat;
-}
-
-void OTimer::addTime(const TTimeValue& Delta)
-{
- m_Expired.addTime(Delta);
-}
-
-TTimeValue OTimer::getRemainingTime() const
-{
- TTimeValue Now;
-
- osl_getSystemTime(&Now);
-
- sal_Int32 secs = m_Expired.Seconds - Now.Seconds;
-
- if (secs < 0)
- return TTimeValue(0, 0);
-
- sal_Int32 nsecs = m_Expired.Nanosec - Now.Nanosec;
-
- if (nsecs < 0)
- {
- if (secs > 0)
- {
- secs -= 1;
- nsecs += 1000000000;
- }
- else
- return TTimeValue(0, 0);
- }
-
- return TTimeValue(secs, nsecs);
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Timer manager
-//
-
-OMutex NAMESPACE_VOS(OTimerManager)::m_Access;
-OTimerManager* NAMESPACE_VOS(OTimerManager)::m_pManager=0;
-
-OTimerManager::OTimerManager()
-{
- OGuard Guard(&m_Access);
-
- OSL_ASSERT(m_pManager == 0);
-
- m_pManager = this;
-
- m_pHead= 0;
-
- m_notEmpty.reset();
-
- // start thread
- create();
-}
-
-OTimerManager::~OTimerManager()
-{
- OGuard Guard(&m_Access);
-
- if ( m_pManager == this )
- m_pManager = 0;
-}
-
-void OTimerManager::onTerminated()
-{
- delete this; // mfe: AAARRRGGGHHH!!!
-}
-
-OTimerManager* OTimerManager::getTimerManager()
-{
- OGuard Guard(&m_Access);
-
- if (! m_pManager)
- new OTimerManager;
-
- return (m_pManager);
-}
-
-sal_Bool OTimerManager::registerTimer(OTimer* pTimer)
-{
- OSL_ASSERT(pTimer);
-
- if ( pTimer == 0 )
- {
- return sal_False;
- }
-
- OGuard Guard(&m_Lock);
-
- // try to find one with equal or lower remaining time.
- OTimer** ppIter = &m_pHead;
-
- while (*ppIter)
- {
- if (pTimer->expiresBefore(*ppIter))
- {
- // next element has higher remaining time,
- // => insert new timer before
- break;
- }
- ppIter= &((*ppIter)->m_pNext);
- }
-
- // next element has higher remaining time,
- // => insert new timer before
- pTimer->m_pNext= *ppIter;
- *ppIter = pTimer;
-
-
- if (pTimer == m_pHead)
- {
- // it was inserted as new head
- // signal it to TimerManager Thread
- m_notEmpty.set();
- }
-
- return sal_True;
-}
-
-sal_Bool OTimerManager::unregisterTimer(OTimer* pTimer)
-{
- OSL_ASSERT(pTimer);
-
- if ( pTimer == 0 )
- {
- return sal_False;
- }
-
- // lock access
- OGuard Guard(&m_Lock);
-
- OTimer** ppIter = &m_pHead;
-
- while (*ppIter)
- {
- if (pTimer == (*ppIter))
- {
- // remove timer from list
- *ppIter = (*ppIter)->m_pNext;
- return sal_True;
- }
- ppIter= &((*ppIter)->m_pNext);
- }
-
- return sal_False;
-}
-
-sal_Bool OTimerManager::lookupTimer(const OTimer* pTimer)
-{
- OSL_ASSERT(pTimer);
-
- if ( pTimer == 0 )
- {
- return sal_False;
- }
-
- // lock access
- OGuard Guard(&m_Lock);
-
- // check the list
- for (OTimer* pIter = m_pHead; pIter != 0; pIter= pIter->m_pNext)
- {
- if (pIter == pTimer)
- {
- return sal_True;
- }
- }
-
- return sal_False;
-}
-
-void OTimerManager::checkForTimeout()
-{
-
- m_Lock.acquire();
-
- if ( m_pHead == 0 )
- {
- m_Lock.release();
- return;
- }
-
- OTimer* pTimer = m_pHead;
-
- if (pTimer->isExpired())
- {
- // remove expired timer
- m_pHead = pTimer->m_pNext;
-
- pTimer->acquire();
-
- m_Lock.release();
-
- pTimer->onShot();
-
- // restart timer if specified
- if ( ! pTimer->m_RepeatDelta.isEmpty() )
- {
- TTimeValue Now;
-
- osl_getSystemTime(&Now);
-
- Now.Seconds += pTimer->m_RepeatDelta.Seconds;
- Now.Nanosec += pTimer->m_RepeatDelta.Nanosec;
-
- pTimer->m_Expired = Now;
-
- registerTimer(pTimer);
- }
- pTimer->release();
- }
- else
- {
- m_Lock.release();
- }
-
-
- return;
-}
-
-void OTimerManager::run()
-{
- setPriority(TPriority_BelowNormal);
-
- while (schedule())
- {
- TTimeValue delay;
- TTimeValue* pDelay=0;
-
-
- m_Lock.acquire();
-
- if (m_pHead != 0)
- {
- delay = m_pHead->getRemainingTime();
- pDelay=&delay;
- }
- else
- {
- pDelay=0;
- }
-
-
- m_notEmpty.reset();
-
- m_Lock.release();
-
-
- m_notEmpty.wait(pDelay);
-
- checkForTimeout();
- }
-
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Timer manager cleanup
-//
-
-// jbu:
-// The timer manager cleanup has been removed (no thread is killed anymore).
-// So the thread leaks.
-// This will result in a GPF in case the vos-library gets unloaded before
-// process termination.
-// -> TODO : rewrite this file, so that the timerManager thread gets destroyed,
-// when there are no timers anymore !
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */