mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 23:07:56 +02:00
trunk: backport eventing from 1.4.3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractDelegate.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractDelegate.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractDelegate.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the AbstractDelegate template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -48,45 +48,41 @@ namespace Poco {
|
||||
|
||||
template <class TArgs>
|
||||
class AbstractDelegate
|
||||
/// Interface for Delegate and Expire
|
||||
/// Very similar to AbstractPriorityDelegate but having two separate files (no inheritance)
|
||||
/// allows one to have compile-time checks when registering an observer
|
||||
/// instead of run-time checks.
|
||||
/// Base class for Delegate and Expire.
|
||||
{
|
||||
public:
|
||||
AbstractDelegate(void* pTarget): _pTarget(pTarget)
|
||||
AbstractDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
AbstractDelegate(const AbstractDelegate& del)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~AbstractDelegate()
|
||||
{
|
||||
poco_assert_dbg (_pTarget != 0);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractDelegate(const AbstractDelegate& del): _pTarget(del._pTarget)
|
||||
{
|
||||
poco_assert_dbg (_pTarget != 0);
|
||||
}
|
||||
virtual bool notify(const void* sender, TArgs& arguments) = 0;
|
||||
/// Invokes the delegate's callback function.
|
||||
/// Returns true if successful, or false if the delegate
|
||||
/// has been disabled or has expired.
|
||||
|
||||
virtual ~AbstractDelegate()
|
||||
{
|
||||
}
|
||||
virtual bool equals(const AbstractDelegate& other) const = 0;
|
||||
/// Compares the AbstractDelegate with the other one for equality.
|
||||
|
||||
virtual bool notify(const void* sender, TArgs& arguments) = 0;
|
||||
/// Returns false, if the Delegate is no longer valid, thus indicating an expire.
|
||||
virtual AbstractDelegate* clone() const = 0;
|
||||
/// Returns a deep copy of the AbstractDelegate.
|
||||
|
||||
virtual AbstractDelegate* clone() const = 0;
|
||||
/// Returns a deep-copy of the AbstractDelegate
|
||||
|
||||
bool operator < (const AbstractDelegate<TArgs>& other) const
|
||||
/// For comparing AbstractDelegates in a collection.
|
||||
{
|
||||
return _pTarget < other._pTarget;
|
||||
}
|
||||
|
||||
void* target() const
|
||||
{
|
||||
return _pTarget;
|
||||
}
|
||||
|
||||
protected:
|
||||
void* _pTarget;
|
||||
virtual void disable() = 0;
|
||||
/// Disables the delegate, which is done prior to removal.
|
||||
|
||||
virtual const AbstractDelegate* unwrap() const
|
||||
/// Returns the unwrapped delegate. Must be overridden by decorators
|
||||
/// like Expire.
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractEvent.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractEvent.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractEvent.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the AbstractEvent class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -53,74 +53,88 @@ namespace Poco {
|
||||
|
||||
template <class TArgs, class TStrategy, class TDelegate, class TMutex = FastMutex>
|
||||
class AbstractEvent
|
||||
/// An AbstractEvent is the super-class of all events.
|
||||
/// It works similar to the way C# handles notifications (aka events in C#).
|
||||
/// Events can be used to send information to a set of observers
|
||||
/// which are registered at the event. The type of the data is specified with
|
||||
/// the template parameter TArgs. The TStrategy parameter must be a subclass
|
||||
/// of NotificationStrategy. The parameter TDelegate can either be a subclass of AbstractDelegate
|
||||
/// or of PriorityAbstractDelegate.
|
||||
///
|
||||
/// Note that AbstractEvent should never be used directly. One ought to use
|
||||
/// one of its subclasses which set the TStrategy and TDelegate template parameters
|
||||
/// to fixed values. For most use-cases the BasicEvent template will be sufficient:
|
||||
/// #include "Poco/BasicEvent.h"
|
||||
/// #include "Poco/Delegate.h"
|
||||
///
|
||||
/// If one requires delegates to be called in the order they registered, use FIFOEvent:
|
||||
/// #include "Poco/FIFOEvent.h"
|
||||
/// #include "Poco/Delegate.h"
|
||||
///
|
||||
/// Both FIFOEvent and BasicEvent work with a standard delegate. They allow one object to register
|
||||
/// exactly one delegate at an event. In contrast, a PriorityDelegate comes with an attached priority value
|
||||
/// and allows one object to register for one priority value one delegate. Note that PriorityDelegates
|
||||
/// only work with PriorityEvents:
|
||||
/// #include "Poco/PriorityEvent.h"
|
||||
/// #include "Poco/PriorityDelegate.h"
|
||||
///
|
||||
/// An AbstractEvent is the base class of all events.
|
||||
/// It works similar to the way C# handles notifications (aka events in C#).
|
||||
///
|
||||
/// Events can be used to send information to a set of delegates
|
||||
/// which are registered with the event. The type of the data is specified with
|
||||
/// the template parameter TArgs. The TStrategy parameter must be a subclass
|
||||
/// of NotificationStrategy. The parameter TDelegate can either be a subclass of AbstractDelegate
|
||||
/// or of AbstractPriorityDelegate.
|
||||
///
|
||||
/// Note that AbstractEvent should never be used directly. One ought to use
|
||||
/// one of its subclasses which set the TStrategy and TDelegate template parameters
|
||||
/// to fixed values. For most use-cases the BasicEvent template will be sufficient:
|
||||
///
|
||||
/// #include "Poco/BasicEvent.h"
|
||||
/// #include "Poco/Delegate.h"
|
||||
///
|
||||
/// Note that as of release 1.4.2, the behavior of BasicEvent equals that of FIFOEvent,
|
||||
/// so the FIFOEvent class is no longer necessary and provided for backwards compatibility
|
||||
/// only.
|
||||
///
|
||||
/// BasicEvent works with a standard delegate. They allow one object to register
|
||||
/// onr or more delegates with an event. In contrast, a PriorityDelegate comes with an attached priority value
|
||||
/// and allows one object to register for one priority value one or more delegates. Note that PriorityDelegates
|
||||
/// only work with PriorityEvents:
|
||||
///
|
||||
/// #include "Poco/PriorityEvent.h"
|
||||
/// #include "Poco/PriorityDelegate.h"
|
||||
///
|
||||
/// Use events by adding them as public members to the object which is throwing notifications:
|
||||
///
|
||||
/// class MyData
|
||||
/// {
|
||||
/// public:
|
||||
/// Poco::BasicEvent<int> AgeChanged;
|
||||
///
|
||||
/// MyData();
|
||||
/// ...
|
||||
/// };
|
||||
///
|
||||
/// Throwing the event can be done either by the events notify() or notifyAsync() method:
|
||||
///
|
||||
///
|
||||
/// Alternatively, instead of notify(), operator () can be used.
|
||||
///
|
||||
/// void MyData::setAge(int i)
|
||||
/// {
|
||||
/// this->_age = i;
|
||||
/// AgeChanged(this, this->_age);
|
||||
/// }
|
||||
///
|
||||
/// Note that notify and notifyAsync do not catch exceptions, i.e. in case a delegate
|
||||
/// throws an exception, the notify is immediately aborted and the exception is thrown
|
||||
/// back to the caller.
|
||||
///
|
||||
/// Delegates can register methods at the event. In the case of a BasicEvent or FIFOEvent
|
||||
/// the Delegate template is used, in case of an PriorityEvent a PriorityDelegate is used.
|
||||
/// Mixing of observers, e.g. using a PriorityDelegate with a BasicEvent is not possible and
|
||||
/// checked for during compile time.
|
||||
/// Events require the observers to follow one of the following method signature:
|
||||
///
|
||||
/// void onEvent(const void* pSender, TArgs& args);
|
||||
/// void onEvent(TArgs& args);
|
||||
/// class MyData
|
||||
/// {
|
||||
/// public:
|
||||
/// Poco::BasicEvent<int> dataChanged;
|
||||
///
|
||||
/// MyData();
|
||||
/// ...
|
||||
/// void setData(int i);
|
||||
/// ...
|
||||
/// private:
|
||||
/// int _data;
|
||||
/// };
|
||||
///
|
||||
/// Firing the event is done either by calling the event's notify() or notifyAsync() method:
|
||||
///
|
||||
/// void MyData::setData(int i)
|
||||
/// {
|
||||
/// this->_data = i;
|
||||
/// dataChanged.notify(this, this->_data);
|
||||
/// }
|
||||
///
|
||||
/// Alternatively, instead of notify(), operator () can be used.
|
||||
///
|
||||
/// void MyData::setData(int i)
|
||||
/// {
|
||||
/// this->_data = i;
|
||||
/// dataChanged(this, this->_data);
|
||||
/// }
|
||||
///
|
||||
/// Note that operator (), notify() and notifyAsync() do not catch exceptions, i.e. in case a
|
||||
/// delegate throws an exception, notifying is immediately aborted and the exception is propagated
|
||||
/// back to the caller.
|
||||
///
|
||||
/// Delegates can register methods at the event. In the case of a BasicEvent
|
||||
/// the Delegate template is used, in case of an PriorityEvent a PriorityDelegate is used.
|
||||
/// Mixing of delegates, e.g. using a PriorityDelegate with a BasicEvent is not allowed and
|
||||
/// can lead to compile-time and/or run-time errors. The standalone delegate() functions
|
||||
/// can be used to construct Delegate objects.
|
||||
///
|
||||
/// Events require the observers to have one of the following method signatures:
|
||||
///
|
||||
/// void onEvent(const void* pSender, TArgs& args);
|
||||
/// void onEvent(TArgs& args);
|
||||
/// static void onEvent(const void* pSender, TArgs& args);
|
||||
/// static void onEvent(void* pSender, TArgs& args);
|
||||
/// static void onEvent(TArgs& args);
|
||||
///
|
||||
/// For performance reasons arguments are always sent by reference. This also allows observers
|
||||
/// to modify the sent argument. To prevent that, use <const TArg> as template
|
||||
/// parameter. A non-conformant method signature leads to compile errors.
|
||||
///
|
||||
/// Assuming that the observer meets the method signature requirement, it can register
|
||||
/// static void onEvent(TArgs& args);
|
||||
///
|
||||
/// For performance reasons arguments are always sent by reference. This also allows observers
|
||||
/// to modify the event argument. To prevent that, use <[const TArg]> as template
|
||||
/// parameter. A non-conformant method signature leads to compile errors.
|
||||
///
|
||||
/// Assuming that the observer meets the method signature requirement, it can register
|
||||
/// this method with the += operator:
|
||||
///
|
||||
/// class MyController
|
||||
@@ -131,34 +145,33 @@ class AbstractEvent
|
||||
/// void onDataChanged(void* pSender, int& data);
|
||||
/// ...
|
||||
/// };
|
||||
///
|
||||
/// MyController::MyController()
|
||||
/// {
|
||||
/// _data.AgeChanged += delegate(this, &MyController::onDataChanged);
|
||||
/// }
|
||||
///
|
||||
/// In some cases it might be desirable to work with automatically expiring registrations. Simply add
|
||||
/// to delegate as 3rd parameter a expireValue (in milliseconds):
|
||||
///
|
||||
/// _data.DataChanged += delegate(this, &MyController::onDataChanged, 1000);
|
||||
///
|
||||
/// This will add a delegate to the event which will automatically be removed in 1000 millisecs.
|
||||
///
|
||||
///
|
||||
/// MyController::MyController()
|
||||
/// {
|
||||
/// _data.dataChanged += delegate(this, &MyController::onDataChanged);
|
||||
/// }
|
||||
///
|
||||
/// In some cases it might be desirable to work with automatically expiring registrations. Simply add
|
||||
/// to delegate as 3rd parameter a expireValue (in milliseconds):
|
||||
///
|
||||
/// _data.dataChanged += delegate(this, &MyController::onDataChanged, 1000);
|
||||
///
|
||||
/// This will add a delegate to the event which will automatically be removed in 1000 millisecs.
|
||||
///
|
||||
/// Unregistering happens via the -= operator. Forgetting to unregister a method will lead to
|
||||
/// segmentation faults later, when one tries to send a notify to a no longer existing object.
|
||||
///
|
||||
/// MyController::~MyController()
|
||||
/// {
|
||||
/// _data.DataChanged -= delegate(this, &MyController::onDataChanged);
|
||||
/// }
|
||||
///
|
||||
/// Working with PriorityDelegates as similar to working with BasicEvent/FIFOEvent.Instead of ''delegate''
|
||||
/// simply use ''priorityDelegate''.
|
||||
///
|
||||
/// For further examples refer to the event testsuites.
|
||||
///
|
||||
/// MyController::~MyController()
|
||||
/// {
|
||||
/// _data.dataChanged -= delegate(this, &MyController::onDataChanged);
|
||||
/// }
|
||||
///
|
||||
/// Working with PriorityDelegate's as similar to working with BasicEvent.
|
||||
/// Instead of delegate(), the priorityDelegate() function must be used
|
||||
/// to create the PriorityDelegate.
|
||||
{
|
||||
public:
|
||||
AbstractEvent():
|
||||
AbstractEvent():
|
||||
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
||||
_enabled(true)
|
||||
{
|
||||
@@ -173,44 +186,51 @@ public:
|
||||
|
||||
virtual ~AbstractEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void operator += (const TDelegate& aDelegate)
|
||||
/// Adds a delegate to the event. If the observer is equal to an
|
||||
/// already existing one (determined by the < operator),
|
||||
/// it will simply replace the existing observer.
|
||||
/// This behavior is determined by the TStrategy. Current implementations
|
||||
/// (DefaultStrategy, FIFOStrategy) follow that guideline but future ones
|
||||
/// can deviate.
|
||||
{
|
||||
typename TMutex::ScopedLock lock(_mutex);
|
||||
_strategy.add(aDelegate);
|
||||
}
|
||||
|
||||
void operator -= (const TDelegate& aDelegate)
|
||||
/// Removes a delegate from the event. If the delegate is equal to an
|
||||
/// already existing one is determined by the < operator.
|
||||
/// If the observer is not found, the unregister will be ignored
|
||||
{
|
||||
typename TMutex::ScopedLock lock(_mutex);
|
||||
_strategy.remove(aDelegate);
|
||||
}
|
||||
|
||||
void operator () (const void* pSender, TArgs& args)
|
||||
{
|
||||
notify(pSender, args);
|
||||
}
|
||||
void operator += (const TDelegate& aDelegate)
|
||||
/// Adds a delegate to the event.
|
||||
///
|
||||
/// Exact behavior is determined by the TStrategy.
|
||||
{
|
||||
typename TMutex::ScopedLock lock(_mutex);
|
||||
_strategy.add(aDelegate);
|
||||
}
|
||||
|
||||
void operator -= (const TDelegate& aDelegate)
|
||||
/// Removes a delegate from the event.
|
||||
///
|
||||
/// If the delegate is not found, this function does nothing.
|
||||
{
|
||||
typename TMutex::ScopedLock lock(_mutex);
|
||||
_strategy.remove(aDelegate);
|
||||
}
|
||||
|
||||
void operator () (const void* pSender, TArgs& args)
|
||||
/// Shortcut for notify(pSender, args);
|
||||
{
|
||||
notify(pSender, args);
|
||||
}
|
||||
|
||||
void operator () (TArgs& args)
|
||||
/// Shortcut for notify(args).
|
||||
{
|
||||
notify(0, args);
|
||||
}
|
||||
|
||||
void notify(const void* pSender, TArgs& args)
|
||||
/// Sends a notification to all registered delegates. The order is
|
||||
/// determined by the TStrategy. This method is blocking. While executing,
|
||||
/// other objects can change the list of delegates. These changes don't
|
||||
/// influence the current active notifications but are activated with
|
||||
/// the next notify. If one of the delegates throws an exception, the notify
|
||||
/// method is immediately aborted and the exception is reported to the caller.
|
||||
{
|
||||
Poco::ScopedLockWithUnlock<TMutex> lock(_mutex);
|
||||
|
||||
void notify(const void* pSender, TArgs& args)
|
||||
/// Sends a notification to all registered delegates. The order is
|
||||
/// determined by the TStrategy. This method is blocking. While executing,
|
||||
/// the list of delegates may be modified. These changes don't
|
||||
/// influence the current active notifications but are activated with
|
||||
/// the next notify. If a delegate is removed during a notify(), the
|
||||
/// delegate will no longer be invoked (unless it has already been
|
||||
/// invoked prior to removal). If one of the delegates throws an exception,
|
||||
/// the notify method is immediately aborted and the exception is propagated
|
||||
/// to the caller.
|
||||
{
|
||||
Poco::ScopedLockWithUnlock<TMutex> lock(_mutex);
|
||||
|
||||
if (!_enabled) return;
|
||||
|
||||
// thread-safeness:
|
||||
@@ -225,16 +245,17 @@ public:
|
||||
/// Sends a notification to all registered delegates. The order is
|
||||
/// determined by the TStrategy. This method is not blocking and will
|
||||
/// immediately return. The delegates are invoked in a seperate thread.
|
||||
/// Call activeResult.wait() to wait until the notification has ended.
|
||||
/// While executing, other objects can change the delegate list. These changes don't
|
||||
/// influence the current active notifications but are activated with
|
||||
/// the next notify. If one of the delegates throws an exception, the execution
|
||||
/// is aborted and the exception is reported to the caller.
|
||||
{
|
||||
NotifyAsyncParams params(pSender, args);
|
||||
|
||||
{
|
||||
typename TMutex::ScopedLock lock(_mutex);
|
||||
/// Call activeResult.wait() to wait until the notification has ended.
|
||||
/// While executing, other objects can change the delegate list. These changes don't
|
||||
/// influence the current active notifications but are activated with
|
||||
/// the next notify. If a delegate is removed during a notify(), the
|
||||
/// delegate will no longer be invoked (unless it has already been
|
||||
/// invoked prior to removal). If one of the delegates throws an exception,
|
||||
/// the execution is aborted and the exception is propagated to the caller.
|
||||
{
|
||||
NotifyAsyncParams params(pSender, args);
|
||||
{
|
||||
typename TMutex::ScopedLock lock(_mutex);
|
||||
|
||||
// thread-safeness:
|
||||
// copy should be faster and safer than blocking until
|
||||
@@ -245,7 +266,6 @@ public:
|
||||
params.ptrStrat = SharedPtr<TStrategy>(new TStrategy(_strategy));
|
||||
params.enabled = _enabled;
|
||||
}
|
||||
|
||||
ActiveResult<TArgs> result = _executeAsync(params);
|
||||
return result;
|
||||
}
|
||||
@@ -291,13 +311,13 @@ protected:
|
||||
SharedPtr<TStrategy> ptrStrat;
|
||||
const void* pSender;
|
||||
TArgs args;
|
||||
bool enabled;
|
||||
|
||||
NotifyAsyncParams(const void* pSend, const TArgs& a):ptrStrat(), pSender(pSend), args(a), enabled(true)
|
||||
/// default constructor reduces the need for TArgs to have an empty constructor, only copy constructor is needed.
|
||||
{
|
||||
}
|
||||
};
|
||||
bool enabled;
|
||||
|
||||
NotifyAsyncParams(const void* pSend, const TArgs& a):ptrStrat(), pSender(pSend), args(a), enabled(true)
|
||||
/// Default constructor reduces the need for TArgs to have an empty constructor, only copy constructor is needed.
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
ActiveMethod<TArgs, NotifyAsyncParams, AbstractEvent> _executeAsync;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractObserver.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/AbstractObserver.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractObserver.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
@@ -59,10 +59,10 @@ public:
|
||||
AbstractObserver& operator = (const AbstractObserver& observer);
|
||||
|
||||
virtual void notify(Notification* pNf) const = 0;
|
||||
virtual bool equals(const AbstractObserver& observer) const = 0;
|
||||
virtual bool accepts(Notification* pNf) const = 0;
|
||||
virtual AbstractObserver* clone() const = 0;
|
||||
virtual void disable() = 0;
|
||||
virtual bool equals(const AbstractObserver& observer) const = 0;
|
||||
virtual bool accepts(Notification* pNf) const = 0;
|
||||
virtual AbstractObserver* clone() const = 0;
|
||||
virtual void disable() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractPriorityDelegate.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractPriorityDelegate.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AbstractPriorityDelegate.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the AbstractPriorityDelegate template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -41,65 +41,41 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/AbstractDelegate.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template <class TArgs>
|
||||
class AbstractPriorityDelegate
|
||||
/// Interface for PriorityDelegate and PriorityExpire.
|
||||
/// Very similar to AbstractDelegate but having two separate files (no inheritance)
|
||||
/// allows to have compile-time checks when registering an observer
|
||||
/// instead of run-time checks.
|
||||
class AbstractPriorityDelegate: public AbstractDelegate<TArgs>
|
||||
/// Base class for PriorityDelegate and PriorityExpire.
|
||||
///
|
||||
/// Extends AbstractDelegate with a priority value.
|
||||
{
|
||||
public:
|
||||
AbstractPriorityDelegate(void* pTarget, int prio):
|
||||
_pTarget(pTarget),
|
||||
_priority(prio)
|
||||
{
|
||||
}
|
||||
AbstractPriorityDelegate(int prio):
|
||||
_priority(prio)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractPriorityDelegate(const AbstractPriorityDelegate& del):
|
||||
_pTarget(del._pTarget),
|
||||
_priority(del._priority)
|
||||
{
|
||||
}
|
||||
AbstractPriorityDelegate(const AbstractPriorityDelegate& del):
|
||||
AbstractDelegate<TArgs>(del),
|
||||
_priority(del._priority)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~AbstractPriorityDelegate()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool notify(const void* sender, TArgs & arguments) = 0;
|
||||
/// Returns false, if the Delegate is no longer valid, thus indicating an expire
|
||||
|
||||
virtual AbstractPriorityDelegate* clone() const = 0;
|
||||
// Returns a deep-copy of the object.
|
||||
|
||||
bool operator < (const AbstractPriorityDelegate<TArgs>& other) const
|
||||
/// Operator used for comparing AbstractPriorityDelegates in a collection.
|
||||
{
|
||||
if (_priority == other._priority)
|
||||
{
|
||||
return _pTarget < other._pTarget;
|
||||
}
|
||||
|
||||
return (_priority < other._priority);
|
||||
}
|
||||
|
||||
void* target() const
|
||||
{
|
||||
return _pTarget;
|
||||
}
|
||||
|
||||
int priority() const
|
||||
{
|
||||
return _priority;
|
||||
}
|
||||
int priority() const
|
||||
{
|
||||
return _priority;
|
||||
}
|
||||
|
||||
protected:
|
||||
void* _pTarget;
|
||||
int _priority;
|
||||
int _priority;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AccessExpirationDecorator.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AccessExpirationDecorator.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AccessExpirationDecorator.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveDispatcher.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ActiveDispatcher.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ActiveDispatcher.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveResult.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ActiveResult.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ActiveResult.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveRunnable.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ActiveRunnable.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ActiveRunnable.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ActiveStarter.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ActiveStarter.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ActiveStarter.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Activity.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Activity.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Activity.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Any.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Any.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Any.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -54,151 +54,151 @@ class Any
|
||||
/// by Applied Informatics.
|
||||
{
|
||||
public:
|
||||
Any():
|
||||
Any():
|
||||
_content(0)
|
||||
/// Creates an empty any type.
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
Any(const ValueType& value):
|
||||
template <typename ValueType>
|
||||
Any(const ValueType& value):
|
||||
_content(new Holder<ValueType>(value))
|
||||
/// Creates an any which stores the init parameter inside.
|
||||
///
|
||||
/// Example:
|
||||
/// Any a(13);
|
||||
/// Any a(string("12345"));
|
||||
{
|
||||
}
|
||||
/// Any a(13);
|
||||
/// Any a(string("12345"));
|
||||
{
|
||||
}
|
||||
|
||||
Any(const Any& other):
|
||||
Any(const Any& other):
|
||||
_content(other._content ? other._content->clone() : 0)
|
||||
/// Copy constructor, works with empty Anys and initialized Any values.
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
~Any()
|
||||
{
|
||||
delete _content;
|
||||
}
|
||||
~Any()
|
||||
{
|
||||
delete _content;
|
||||
}
|
||||
|
||||
Any& swap(Any& rhs)
|
||||
Any& swap(Any& rhs)
|
||||
/// Swaps the content of the two Anys.
|
||||
{
|
||||
std::swap(_content, rhs._content);
|
||||
return *this;
|
||||
}
|
||||
{
|
||||
std::swap(_content, rhs._content);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
Any& operator = (const ValueType& rhs)
|
||||
template <typename ValueType>
|
||||
Any& operator = (const ValueType& rhs)
|
||||
/// Assignment operator for all types != Any.
|
||||
///
|
||||
/// Example:
|
||||
/// Any a = 13;
|
||||
/// Any a = string("12345");
|
||||
{
|
||||
Any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
/// Any a = 13;
|
||||
/// Any a = string("12345");
|
||||
{
|
||||
Any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Any& operator = (const Any& rhs)
|
||||
Any& operator = (const Any& rhs)
|
||||
/// Assignment operator for Any.
|
||||
{
|
||||
Any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
{
|
||||
Any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
bool empty() const
|
||||
/// returns true if the Any is empty
|
||||
{
|
||||
return !_content;
|
||||
}
|
||||
{
|
||||
return !_content;
|
||||
}
|
||||
|
||||
const std::type_info& type() const
|
||||
const std::type_info& type() const
|
||||
/// Returns the type information of the stored content.
|
||||
/// If the Any is empty typeid(void) is returned.
|
||||
/// It is suggested to always query an Any for its type info before trying to extract
|
||||
/// data via an AnyCast/RefAnyCast.
|
||||
{
|
||||
return _content ? _content->type() : typeid(void);
|
||||
}
|
||||
{
|
||||
return _content ? _content->type() : typeid(void);
|
||||
}
|
||||
|
||||
private:
|
||||
class Placeholder
|
||||
{
|
||||
public:
|
||||
virtual ~Placeholder()
|
||||
{
|
||||
}
|
||||
class Placeholder
|
||||
{
|
||||
public:
|
||||
virtual ~Placeholder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const = 0;
|
||||
virtual Placeholder* clone() const = 0;
|
||||
};
|
||||
virtual const std::type_info& type() const = 0;
|
||||
virtual Placeholder* clone() const = 0;
|
||||
};
|
||||
|
||||
template <typename ValueType>
|
||||
class Holder: public Placeholder
|
||||
{
|
||||
public:
|
||||
Holder(const ValueType& value):
|
||||
template <typename ValueType>
|
||||
class Holder: public Placeholder
|
||||
{
|
||||
public:
|
||||
Holder(const ValueType& value):
|
||||
_held(value)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const
|
||||
{
|
||||
return typeid(ValueType);
|
||||
}
|
||||
virtual const std::type_info& type() const
|
||||
{
|
||||
return typeid(ValueType);
|
||||
}
|
||||
|
||||
virtual Placeholder* clone() const
|
||||
{
|
||||
return new Holder(_held);
|
||||
}
|
||||
virtual Placeholder* clone() const
|
||||
{
|
||||
return new Holder(_held);
|
||||
}
|
||||
|
||||
ValueType _held;
|
||||
};
|
||||
ValueType _held;
|
||||
};
|
||||
|
||||
private:
|
||||
template <typename ValueType>
|
||||
friend ValueType* AnyCast(Any*);
|
||||
template <typename ValueType>
|
||||
friend ValueType* AnyCast(Any*);
|
||||
|
||||
template <typename ValueType>
|
||||
friend ValueType* UnsafeAnyCast(Any*);
|
||||
template <typename ValueType>
|
||||
friend ValueType* UnsafeAnyCast(Any*);
|
||||
|
||||
template <typename ValueType>
|
||||
friend ValueType& RefAnyCast(Any&);
|
||||
template <typename ValueType>
|
||||
friend ValueType& RefAnyCast(Any&);
|
||||
|
||||
template <typename ValueType>
|
||||
friend const ValueType& RefAnyCast(const Any&);
|
||||
template <typename ValueType>
|
||||
friend const ValueType& RefAnyCast(const Any&);
|
||||
|
||||
Placeholder* _content;
|
||||
Placeholder* _content;
|
||||
};
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
inline ValueType* AnyCast(Any* operand)
|
||||
/// AnyCast operator used to extract the ValueType from an Any*. Will return a pointer
|
||||
/// to the stored value.
|
||||
///
|
||||
/// AnyCast operator used to extract the ValueType from an Any*. Will return a pointer
|
||||
/// to the stored value.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||
/// MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||
/// Will return NULL if the cast fails, i.e. types don't match.
|
||||
{
|
||||
return operand && operand->type() == typeid(ValueType)
|
||||
? &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held
|
||||
: 0;
|
||||
return operand && operand->type() == typeid(ValueType)
|
||||
? &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held
|
||||
: 0;
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
inline const ValueType* AnyCast(const Any* operand)
|
||||
/// AnyCast operator used to extract a const ValueType pointer from an const Any*. Will return a const pointer
|
||||
/// to the stored value.
|
||||
///
|
||||
/// AnyCast operator used to extract a const ValueType pointer from an const Any*. Will return a const pointer
|
||||
/// to the stored value.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// const MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||
/// const MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||
/// Will return NULL if the cast fails, i.e. types don't match.
|
||||
{
|
||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||
}
|
||||
|
||||
|
||||
@@ -207,16 +207,16 @@ ValueType AnyCast(const Any& operand)
|
||||
/// AnyCast operator used to extract a copy of the ValueType from an const Any&.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// MyType tmp = AnyCast<MyType>(anAny).
|
||||
/// MyType tmp = AnyCast<MyType>(anAny).
|
||||
/// Will throw a BadCastException if the cast fails.
|
||||
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ...
|
||||
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
||||
/// these cases.
|
||||
/// these cases.
|
||||
{
|
||||
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
||||
if (!result)
|
||||
throw BadCastException("Failed to convert between const Any types");
|
||||
return *result;
|
||||
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
||||
if (!result)
|
||||
throw BadCastException("Failed to convert between const Any types");
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,30 +225,30 @@ ValueType AnyCast(Any& operand)
|
||||
/// AnyCast operator used to extract a copy of the ValueType from an Any&.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// MyType tmp = AnyCast<MyType>(anAny).
|
||||
/// MyType tmp = AnyCast<MyType>(anAny).
|
||||
/// Will throw a BadCastException if the cast fails.
|
||||
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ...
|
||||
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
||||
/// these cases.
|
||||
/// these cases.
|
||||
{
|
||||
ValueType* result = AnyCast<ValueType>(&operand);
|
||||
if (!result)
|
||||
throw BadCastException("Failed to convert between Any types");
|
||||
return *result;
|
||||
ValueType* result = AnyCast<ValueType>(&operand);
|
||||
if (!result)
|
||||
throw BadCastException("Failed to convert between Any types");
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
const ValueType& RefAnyCast(const Any& operand)
|
||||
const ValueType& RefAnyCast(const Any & operand)
|
||||
/// AnyCast operator used to return a const reference to the internal data.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||
/// Example Usage:
|
||||
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||
{
|
||||
if (operand.type() == typeid(ValueType))
|
||||
return static_cast<Any::Holder<ValueType>*>(operand._content)->_held;
|
||||
else
|
||||
throw BadCastException("RefAnyCast: Failed to convert between const Any types");
|
||||
if (operand.type() == typeid(ValueType))
|
||||
return static_cast<Any::Holder<ValueType>*>(operand._content)->_held;
|
||||
else
|
||||
throw BadCastException("RefAnyCast: Failed to convert between const Any types");
|
||||
}
|
||||
|
||||
|
||||
@@ -256,37 +256,37 @@ template <typename ValueType>
|
||||
ValueType& RefAnyCast(Any& operand)
|
||||
/// AnyCast operator used to return a reference to the internal data.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||
/// Example Usage:
|
||||
/// MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||
{
|
||||
if (operand.type() == typeid(ValueType))
|
||||
return static_cast<Any::Holder<ValueType>*>(operand._content)->_held;
|
||||
else
|
||||
throw BadCastException("RefAnyCast: Failed to convert between Any types");
|
||||
if (operand.type() == typeid(ValueType))
|
||||
return static_cast<Any::Holder<ValueType>*>(operand._content)->_held;
|
||||
else
|
||||
throw BadCastException("RefAnyCast: Failed to convert between Any types");
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
inline ValueType* UnsafeAnyCast(Any* operand)
|
||||
/// The "unsafe" versions of AnyCast are not part of the
|
||||
/// public interface and may be removed at any time. They are
|
||||
/// required where we know what type is stored in the any and can't
|
||||
/// The "unsafe" versions of AnyCast are not part of the
|
||||
/// public interface and may be removed at any time. They are
|
||||
/// required where we know what type is stored in the any and can't
|
||||
/// use typeid() comparison, e.g., when our types may travel across
|
||||
/// different shared libraries.
|
||||
{
|
||||
return &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held;
|
||||
return &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held;
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
inline const ValueType* UnsafeAnyCast(const Any* operand)
|
||||
/// The "unsafe" versions of AnyCast are not part of the
|
||||
/// public interface and may be removed at any time. They are
|
||||
/// required where we know what type is stored in the any and can't
|
||||
/// The "unsafe" versions of AnyCast are not part of the
|
||||
/// public interface and may be removed at any time. They are
|
||||
/// required where we know what type is stored in the any and can't
|
||||
/// use typeid() comparison, e.g., when our types may travel across
|
||||
/// different shared libraries.
|
||||
{
|
||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ArchiveStrategy.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ArchiveStrategy.h#5 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ArchiveStrategy.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AsyncChannel.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/AsyncChannel.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AsyncChannel.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AutoPtr.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/AutoPtr.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AutoPtr.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AutoReleasePool.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/AutoReleasePool.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/AutoReleasePool.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Base64Decoder.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Base64Decoder.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Base64Decoder.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -49,30 +49,30 @@ namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API Base64DecoderBuf: public UnbufferedStreamBuf
|
||||
/// This streambuf base64-decodes all data read
|
||||
/// from the istream connected to it.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
/// This streambuf base64-decodes all data read
|
||||
/// from the istream connected to it.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
{
|
||||
public:
|
||||
Base64DecoderBuf(std::istream& istr);
|
||||
Base64DecoderBuf(std::istream& istr);
|
||||
~Base64DecoderBuf();
|
||||
|
||||
private:
|
||||
int readFromDevice();
|
||||
int readOne();
|
||||
|
||||
unsigned char _group[3];
|
||||
int _groupLength;
|
||||
int _groupIndex;
|
||||
std::streambuf& _buf;
|
||||
|
||||
static unsigned char IN_ENCODING[256];
|
||||
static bool IN_ENCODING_INIT;
|
||||
unsigned char _group[3];
|
||||
int _groupLength;
|
||||
int _groupIndex;
|
||||
std::streambuf& _buf;
|
||||
|
||||
static unsigned char IN_ENCODING[256];
|
||||
static bool IN_ENCODING_INIT;
|
||||
|
||||
private:
|
||||
Base64DecoderBuf(const Base64DecoderBuf&);
|
||||
@@ -101,17 +101,17 @@ private:
|
||||
|
||||
|
||||
class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream
|
||||
/// This istream base64-decodes all data
|
||||
/// read from the istream connected to it.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
/// This istream base64-decodes all data
|
||||
/// read from the istream connected to it.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
{
|
||||
public:
|
||||
Base64Decoder(std::istream& istr);
|
||||
Base64Decoder(std::istream& istr);
|
||||
~Base64Decoder();
|
||||
|
||||
private:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Base64Encoder.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Base64Encoder.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Base64Encoder.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -49,17 +49,17 @@ namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API Base64EncoderBuf: public UnbufferedStreamBuf
|
||||
/// This streambuf base64-encodes all data written
|
||||
/// to it and forwards it to a connected
|
||||
/// ostream.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
/// This streambuf base64-encodes all data written
|
||||
/// to it and forwards it to a connected
|
||||
/// ostream.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
{
|
||||
public:
|
||||
Base64EncoderBuf(std::ostream& ostr);
|
||||
Base64EncoderBuf(std::ostream& ostr);
|
||||
~Base64EncoderBuf();
|
||||
|
||||
int close();
|
||||
@@ -80,13 +80,13 @@ private:
|
||||
int writeToDevice(char c);
|
||||
|
||||
unsigned char _group[3];
|
||||
int _groupLength;
|
||||
int _pos;
|
||||
int _lineLength;
|
||||
std::streambuf& _buf;
|
||||
|
||||
static const unsigned char OUT_ENCODING[64];
|
||||
|
||||
int _groupLength;
|
||||
int _pos;
|
||||
int _lineLength;
|
||||
std::streambuf& _buf;
|
||||
|
||||
static const unsigned char OUT_ENCODING[64];
|
||||
|
||||
friend class Base64DecoderBuf;
|
||||
|
||||
Base64EncoderBuf(const Base64EncoderBuf&);
|
||||
@@ -119,17 +119,17 @@ class Foundation_API Base64Encoder: public Base64EncoderIOS, public std::ostream
|
||||
/// This ostream base64-encodes all data
|
||||
/// written to it and forwards it to
|
||||
/// a connected ostream.
|
||||
/// Always call close() when done
|
||||
/// writing data, to ensure proper
|
||||
/// completion of the encoding operation.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
/// Always call close() when done
|
||||
/// writing data, to ensure proper
|
||||
/// completion of the encoding operation.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
{
|
||||
public:
|
||||
Base64Encoder(std::ostream& ostr);
|
||||
Base64Encoder(std::ostream& ostr);
|
||||
~Base64Encoder();
|
||||
|
||||
private:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BasicEvent.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/BasicEvent.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/BasicEvent.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the BasicEvent template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -36,14 +36,14 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_BasicEvent_INCLUDED
|
||||
#define Foundation_BasicEvent_INCLUDED
|
||||
#ifndef Foundation_BasicEvent_INCLUDED
|
||||
#define Foundation_BasicEvent_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/AbstractEvent.h"
|
||||
#include "Poco/DefaultStrategy.h"
|
||||
#include "Poco/AbstractDelegate.h"
|
||||
#include "Poco/CompareFunctions.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -51,22 +51,15 @@ namespace Poco {
|
||||
|
||||
template <class TArgs, class TMutex = FastMutex>
|
||||
class BasicEvent: public AbstractEvent <
|
||||
TArgs, DefaultStrategy<TArgs, AbstractDelegate<TArgs>, p_less<AbstractDelegate<TArgs> > >,
|
||||
TArgs, DefaultStrategy<TArgs, AbstractDelegate<TArgs> >,
|
||||
AbstractDelegate<TArgs>,
|
||||
TMutex
|
||||
>
|
||||
/// A BasicEvent uses internally a DefaultStrategy which
|
||||
/// invokes delegates in an arbitrary manner.
|
||||
/// Note that one object can only register one method to a BasicEvent.
|
||||
/// Subsequent registrations will overwrite the existing delegate.
|
||||
/// For example:
|
||||
/// BasicEvent<int> event;
|
||||
/// MyClass myObject;
|
||||
/// event += delegate(&myObject, &MyClass::myMethod1);
|
||||
/// event += delegate(&myObject, &MyClass::myMethod2);
|
||||
/// A BasicEvent uses the DefaultStrategy which
|
||||
/// invokes delegates in the order they have been registered.
|
||||
///
|
||||
/// The second registration will overwrite the first one. The reason is simply that
|
||||
/// function pointers can only be compared by equality but not by lower than.
|
||||
/// Please see the AbstractEvent class template documentation
|
||||
/// for more information.
|
||||
{
|
||||
public:
|
||||
BasicEvent()
|
||||
@@ -86,4 +79,4 @@ private:
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_BasicEvent_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BinaryReader.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/BinaryReader.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/BinaryReader.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -53,11 +53,11 @@ class TextConverter;
|
||||
|
||||
|
||||
class Foundation_API BinaryReader
|
||||
/// This class reads basic types (and std::vectors thereof)
|
||||
/// in binary form into an input stream.
|
||||
/// It provides an extractor-based interface similar to istream.
|
||||
/// The reader also supports automatic conversion from big-endian
|
||||
/// (network byte order) to little-endian and vice-versa.
|
||||
/// This class reads basic types (and std::vectors thereof)
|
||||
/// in binary form into an input stream.
|
||||
/// It provides an extractor-based interface similar to istream.
|
||||
/// The reader also supports automatic conversion from big-endian
|
||||
/// (network byte order) to little-endian and vice-versa.
|
||||
/// Use a BinaryWriter to create a stream suitable for a BinaryReader.
|
||||
{
|
||||
public:
|
||||
@@ -70,17 +70,17 @@ public:
|
||||
UNSPECIFIED_BYTE_ORDER = 4 /// unknown, byte-order will be determined by reading the byte-order mark
|
||||
};
|
||||
|
||||
BinaryReader(std::istream& istr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryReader.
|
||||
BinaryReader(std::istream& istr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryReader.
|
||||
|
||||
BinaryReader(std::istream& istr, TextEncoding& encoding, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryReader using the given TextEncoding.
|
||||
///
|
||||
/// Strings will be converted from the specified encoding
|
||||
/// to the currently set global encoding (see Poco::TextEncoding::global()).
|
||||
BinaryReader(std::istream& istr, TextEncoding& encoding, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryReader using the given TextEncoding.
|
||||
///
|
||||
/// Strings will be converted from the specified encoding
|
||||
/// to the currently set global encoding (see Poco::TextEncoding::global()).
|
||||
|
||||
~BinaryReader();
|
||||
/// Destroys the BinaryReader.
|
||||
~BinaryReader();
|
||||
/// Destroys the BinaryReader.
|
||||
|
||||
BinaryReader& operator >> (bool& value);
|
||||
BinaryReader& operator >> (char& value);
|
||||
@@ -100,46 +100,46 @@ public:
|
||||
BinaryReader& operator >> (UInt64& value);
|
||||
#endif
|
||||
|
||||
BinaryReader& operator >> (std::string& value);
|
||||
BinaryReader& operator >> (std::string& value);
|
||||
|
||||
template <typename T>
|
||||
BinaryReader& operator >> (std::vector<T>& value)
|
||||
{
|
||||
Poco::UInt32 size(0);
|
||||
T elem;
|
||||
template <typename T>
|
||||
BinaryReader& operator >> (std::vector<T>& value)
|
||||
{
|
||||
Poco::UInt32 size(0);
|
||||
T elem;
|
||||
|
||||
*this >> size;
|
||||
if (!good()) return *this;
|
||||
value.reserve(size);
|
||||
while (this->good() && size-- > 0)
|
||||
{
|
||||
*this >> elem;
|
||||
value.push_back(elem);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
*this >> size;
|
||||
if (!good()) return *this;
|
||||
value.reserve(size);
|
||||
while (this->good() && size-- > 0)
|
||||
{
|
||||
*this >> elem;
|
||||
value.push_back(elem);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void read7BitEncoded(UInt32& value);
|
||||
/// Reads a 32-bit unsigned integer in compressed format.
|
||||
/// See BinaryWriter::write7BitEncoded() for a description
|
||||
void read7BitEncoded(UInt32& value);
|
||||
/// Reads a 32-bit unsigned integer in compressed format.
|
||||
/// See BinaryWriter::write7BitEncoded() for a description
|
||||
/// of the compression algorithm.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
void read7BitEncoded(UInt64& value);
|
||||
/// Reads a 64-bit unsigned integer in compressed format.
|
||||
/// See BinaryWriter::write7BitEncoded() for a description
|
||||
/// of the compression algorithm.
|
||||
/// of the compression algorithm.
|
||||
#endif
|
||||
|
||||
void readRaw(std::streamsize length, std::string& value);
|
||||
/// Reads length bytes of raw data into value.
|
||||
void readRaw(std::streamsize length, std::string& value);
|
||||
/// Reads length bytes of raw data into value.
|
||||
|
||||
void readRaw(char* buffer, std::streamsize length);
|
||||
/// Reads length bytes of raw data into buffer.
|
||||
void readRaw(char* buffer, std::streamsize length);
|
||||
/// Reads length bytes of raw data into buffer.
|
||||
|
||||
void readBOM();
|
||||
/// Reads a byte-order mark from the stream and configures
|
||||
/// the reader for the encountered byte order.
|
||||
void readBOM();
|
||||
/// Reads a byte-order mark from the stream and configures
|
||||
/// the reader for the encountered byte order.
|
||||
/// A byte-order mark is a 16-bit integer with a value of 0xFEFF,
|
||||
/// written in host byte order.
|
||||
|
||||
@@ -163,9 +163,9 @@ public:
|
||||
/// either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
|
||||
|
||||
private:
|
||||
std::istream& _istr;
|
||||
bool _flipBytes;
|
||||
TextConverter* _pTextConverter;
|
||||
std::istream& _istr;
|
||||
bool _flipBytes;
|
||||
TextConverter* _pTextConverter;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Buffer.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Buffer.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Buffer.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -50,131 +50,131 @@ namespace Poco {
|
||||
|
||||
template <class T>
|
||||
class Buffer
|
||||
/// A buffer class that allocates a buffer of a given type and size.
|
||||
/// Buffer can be zero-size, resized, copy-constructed and assigned.
|
||||
/// Memory allocation, resizing and deallocation is managed automatically.
|
||||
///
|
||||
/// This class is useful everywhere where a temporary buffer
|
||||
/// is needed.
|
||||
/// A buffer class that allocates a buffer of a given type and size.
|
||||
/// Buffer can be zero-size, resized, copy-constructed and assigned.
|
||||
/// Memory allocation, resizing and deallocation is managed automatically.
|
||||
///
|
||||
/// This class is useful everywhere where a temporary buffer
|
||||
/// is needed.
|
||||
{
|
||||
public:
|
||||
Buffer(std::size_t size):
|
||||
_size(size),
|
||||
_ptr(size ? new T[size] : 0)
|
||||
/// Creates and allocates the Buffer.
|
||||
{
|
||||
}
|
||||
|
||||
Buffer(): _size(0), _ptr(0)
|
||||
/// Creates the Buffer.
|
||||
{
|
||||
}
|
||||
Buffer(std::size_t size):
|
||||
_size(size),
|
||||
_ptr(size ? new T[size] : 0)
|
||||
/// Creates and allocates the Buffer.
|
||||
{
|
||||
}
|
||||
|
||||
Buffer(): _size(0), _ptr(0)
|
||||
/// Creates the Buffer.
|
||||
{
|
||||
}
|
||||
|
||||
Buffer(const Buffer& other):
|
||||
/// Copy constructor.
|
||||
_size(other._size),
|
||||
_ptr(other._size ? new T[other._size] : 0)
|
||||
{
|
||||
if (_size)
|
||||
std::memcpy(_ptr, other._ptr, _size * sizeof(T));
|
||||
}
|
||||
|
||||
Buffer(const Buffer& other):
|
||||
/// Copy constructor.
|
||||
_size(other._size),
|
||||
_ptr(other._size ? new T[other._size] : 0)
|
||||
{
|
||||
if (_size)
|
||||
std::memcpy(_ptr, other._ptr, _size * sizeof(T));
|
||||
}
|
||||
Buffer& operator = (const Buffer& other)
|
||||
/// Assignment operator.
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
Buffer tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
|
||||
Buffer& operator = (const Buffer& other)
|
||||
/// Assignment operator.
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
Buffer tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Buffer()
|
||||
/// Destroys the Buffer.
|
||||
{
|
||||
delete [] _ptr;
|
||||
}
|
||||
|
||||
void swap(Buffer& other)
|
||||
/// Swaps the buffer with another one.
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
swap(_ptr, other._ptr);
|
||||
swap(_size, other._size);
|
||||
}
|
||||
|
||||
std::size_t size() const
|
||||
~Buffer()
|
||||
/// Destroys the Buffer.
|
||||
{
|
||||
delete [] _ptr;
|
||||
}
|
||||
|
||||
void swap(Buffer& other)
|
||||
/// Swaps the buffer with another one.
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
swap(_ptr, other._ptr);
|
||||
swap(_size, other._size);
|
||||
}
|
||||
|
||||
std::size_t size() const
|
||||
/// Returns the size of the buffer.
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
void clear()
|
||||
/// Sets the contents of the bufer to zero.
|
||||
{
|
||||
std::memset(_ptr, 0, _size * sizeof(T));
|
||||
}
|
||||
return _size;
|
||||
}
|
||||
|
||||
void clear()
|
||||
/// Sets the contents of the bufer to zero.
|
||||
{
|
||||
std::memset(_ptr, 0, _size * sizeof(T));
|
||||
}
|
||||
|
||||
void resize(std::size_t newSize, bool preserve = false)
|
||||
/// Resizes the buffer. If preserve is true, the contents
|
||||
/// of the buffer is preserved. If the newSize is smaller
|
||||
/// than the current size, data truncation will occur.
|
||||
///
|
||||
/// For efficiency sake, the default behavior is not to
|
||||
/// preserve the contents.
|
||||
{
|
||||
if (preserve)
|
||||
{
|
||||
if (_size == newSize) return;
|
||||
Buffer tmp;
|
||||
tmp = *this;
|
||||
recreate(newSize);
|
||||
std::size_t size = _size < tmp._size ? _size : tmp._size;
|
||||
std::memcpy(_ptr, tmp._ptr, size * sizeof(T));
|
||||
return;
|
||||
}
|
||||
else if (_size == newSize)
|
||||
{
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
void resize(std::size_t newSize, bool preserve = false)
|
||||
/// Resizes the buffer. If preserve is true, the contents
|
||||
/// of the buffer is preserved. If the newSize is smaller
|
||||
/// than the current size, data truncation will occur.
|
||||
///
|
||||
/// For efficiency sake, the default behavior is not to
|
||||
/// preserve the contents.
|
||||
{
|
||||
if (preserve)
|
||||
{
|
||||
if (_size == newSize) return;
|
||||
Buffer tmp;
|
||||
tmp = *this;
|
||||
recreate(newSize);
|
||||
std::size_t size = _size < tmp._size ? _size : tmp._size;
|
||||
std::memcpy(_ptr, tmp._ptr, size * sizeof(T));
|
||||
return;
|
||||
}
|
||||
else if (_size == newSize)
|
||||
{
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
recreate(newSize);
|
||||
}
|
||||
recreate(newSize);
|
||||
}
|
||||
|
||||
void append(const T* buf, std::size_t sz)
|
||||
/// Resizes this buffer and appends the argument buffer.
|
||||
{
|
||||
if (0 == sz) return;
|
||||
std::size_t oldSize = _size;
|
||||
resize(_size + sz, true);
|
||||
std::memcpy(_ptr + oldSize, buf, sz);
|
||||
}
|
||||
void append(const T* buf, std::size_t sz)
|
||||
/// Resizes this buffer and appends the argument buffer.
|
||||
{
|
||||
if (0 == sz) return;
|
||||
std::size_t oldSize = _size;
|
||||
resize(_size + sz, true);
|
||||
std::memcpy(_ptr + oldSize, buf, sz);
|
||||
}
|
||||
|
||||
void append(const Buffer& buf)
|
||||
/// Resizes this buffer and appends the argument buffer.
|
||||
{
|
||||
append(buf.begin(), buf.size());
|
||||
}
|
||||
void append(const Buffer& buf)
|
||||
/// Resizes this buffer and appends the argument buffer.
|
||||
{
|
||||
append(buf.begin(), buf.size());
|
||||
}
|
||||
|
||||
std::size_t elementSize() const
|
||||
/// Returns the size of the buffer element.
|
||||
{
|
||||
return sizeof(T);
|
||||
}
|
||||
std::size_t elementSize() const
|
||||
/// Returns the size of the buffer element.
|
||||
{
|
||||
return sizeof(T);
|
||||
}
|
||||
|
||||
std::size_t byteCount() const
|
||||
/// Returns the total length of the buffer in bytes.
|
||||
{
|
||||
return _size * sizeof(T);
|
||||
}
|
||||
std::size_t byteCount() const
|
||||
/// Returns the total length of the buffer in bytes.
|
||||
{
|
||||
return _size * sizeof(T);
|
||||
}
|
||||
|
||||
T* begin()
|
||||
/// Returns a pointer to the beginning of the buffer.
|
||||
{
|
||||
T* begin()
|
||||
/// Returns a pointer to the beginning of the buffer.
|
||||
{
|
||||
return _ptr;
|
||||
}
|
||||
|
||||
@@ -193,18 +193,18 @@ public:
|
||||
const T* end() const
|
||||
/// Returns a pointer to the end of the buffer.
|
||||
{
|
||||
return _ptr + _size;
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
/// Return true if buffer is empty.
|
||||
{
|
||||
return 0 == _size;
|
||||
}
|
||||
return _ptr + _size;
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
/// Return true if buffer is empty.
|
||||
{
|
||||
return 0 == _size;
|
||||
}
|
||||
|
||||
T& operator [] (std::size_t index)
|
||||
{
|
||||
poco_assert (index < _size);
|
||||
T& operator [] (std::size_t index)
|
||||
{
|
||||
poco_assert (index < _size);
|
||||
|
||||
return _ptr[index];
|
||||
}
|
||||
@@ -214,26 +214,26 @@ public:
|
||||
poco_assert (index < _size);
|
||||
|
||||
return _ptr[index];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void recreate(std::size_t newSize)
|
||||
{
|
||||
if (newSize != _size)
|
||||
{
|
||||
delete [] _ptr;
|
||||
if (0 == newSize)
|
||||
_ptr = 0;
|
||||
else
|
||||
_ptr = new T[newSize];
|
||||
void recreate(std::size_t newSize)
|
||||
{
|
||||
if (newSize != _size)
|
||||
{
|
||||
delete [] _ptr;
|
||||
if (0 == newSize)
|
||||
_ptr = 0;
|
||||
else
|
||||
_ptr = new T[newSize];
|
||||
|
||||
_size = newSize;
|
||||
}
|
||||
}
|
||||
_size = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t _size;
|
||||
T* _ptr;
|
||||
std::size_t _size;
|
||||
T* _ptr;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferAllocator.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/BufferAllocator.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/BufferAllocator.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferedBidirectionalStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#7 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferedStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedStreamBuf.h#6 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/BufferedStreamBuf.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Bugcheck.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Bugcheck.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Bugcheck.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -96,10 +96,10 @@ protected:
|
||||
// useful macros (these automatically supply line number and file name)
|
||||
//
|
||||
#if defined(_DEBUG)
|
||||
# define poco_assert_dbg(cond) \
|
||||
#define poco_assert_dbg(cond) \
|
||||
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
||||
#else
|
||||
# define poco_assert_dbg(cond)
|
||||
#define poco_assert_dbg(cond)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ protected:
|
||||
|
||||
#if defined(_DEBUG)
|
||||
# define poco_stdout_dbg(outstr) \
|
||||
std::cout << __FILE__ << '(' << std::dec << __LINE__ << "):" << outstr << std::endl;
|
||||
std::cout << __FILE__ << '(' << std::dec << __LINE__ << "):" << outstr << std::endl;
|
||||
#else
|
||||
# define poco_stdout_dbg(outstr)
|
||||
#endif
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ByteOrder.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ByteOrder.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ByteOrder.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Channel.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Channel.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Channel.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Checksum.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Checksum.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Checksum.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ClassLibrary.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ClassLibrary.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ClassLibrary.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: SharedLibrary
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ClassLoader.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ClassLoader.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ClassLoader.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: SharedLibrary
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Condition.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Condition.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Condition.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Config.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Config.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Config.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Configurable.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Configurable.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Configurable.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ConsoleChannel.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ConsoleChannel.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ConsoleChannel.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// CountingStream.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/CountingStream.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/CountingStream.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTime.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DateTime.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DateTime.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@@ -52,16 +52,16 @@ class Foundation_API DateTime
|
||||
/// This class represents an instant in time, expressed
|
||||
/// in years, months, days, hours, minutes, seconds
|
||||
/// and milliseconds based on the Gregorian calendar.
|
||||
/// The class is mainly useful for conversions between
|
||||
/// UTC, Julian day and Gregorian calendar dates.
|
||||
///
|
||||
/// The date and time stored in a DateTime is always in UTC
|
||||
/// (Coordinated Universal Time) and thus independent of the
|
||||
/// timezone in effect on the system.
|
||||
///
|
||||
/// Conversion calculations are based on algorithms
|
||||
/// collected and described by Peter Baum at
|
||||
/// http://vsg.cape.com/~pbaum/date/date0.htm
|
||||
/// The class is mainly useful for conversions between
|
||||
/// UTC, Julian day and Gregorian calendar dates.
|
||||
///
|
||||
/// The date and time stored in a DateTime is always in UTC
|
||||
/// (Coordinated Universal Time) and thus independent of the
|
||||
/// timezone in effect on the system.
|
||||
///
|
||||
/// Conversion calculations are based on algorithms
|
||||
/// collected and described by Peter Baum at
|
||||
/// http://vsg.cape.com/~pbaum/date/date0.htm
|
||||
///
|
||||
/// Internally, this class stores a date/time in two
|
||||
/// forms (UTC and broken down) for performance reasons. Only use
|
||||
@@ -431,16 +431,6 @@ inline void swap(DateTime& d1, DateTime& d2)
|
||||
}
|
||||
|
||||
|
||||
inline void DateTime::checkLimit(short& lower, short& higher, short limit)
|
||||
{
|
||||
if (lower >= limit)
|
||||
{
|
||||
higher += short(lower / limit);
|
||||
lower = short(lower % limit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeFormat.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DateTimeFormat.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DateTimeFormat.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeFormatter.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DateTimeFormatter.h#4 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DateTimeFormatter.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@@ -89,17 +89,17 @@ public:
|
||||
/// * %H - hour (00 .. 23)
|
||||
/// * %h - hour (00 .. 12)
|
||||
/// * %a - am/pm
|
||||
/// * %A - AM/PM
|
||||
/// * %M - minute (00 .. 59)
|
||||
/// * %S - second (00 .. 59)
|
||||
/// * %s - seconds and microseconds (equivalent to %S.%F)
|
||||
/// * %i - millisecond (000 .. 999)
|
||||
/// * %c - centisecond (0 .. 9)
|
||||
/// * %F - fractional seconds/microseconds (000000 - 999999)
|
||||
/// * %z - time zone differential in ISO 8601 format (Z or +NN.NN)
|
||||
/// * %Z - time zone differential in RFC format (GMT or +NNNN)
|
||||
/// * %% - percent sign
|
||||
///
|
||||
/// * %A - AM/PM
|
||||
/// * %M - minute (00 .. 59)
|
||||
/// * %S - second (00 .. 59)
|
||||
/// * %s - seconds and microseconds (equivalent to %S.%F)
|
||||
/// * %i - millisecond (000 .. 999)
|
||||
/// * %c - centisecond (0 .. 9)
|
||||
/// * %F - fractional seconds/microseconds (000000 - 999999)
|
||||
/// * %z - time zone differential in ISO 8601 format (Z or +NN.NN)
|
||||
/// * %Z - time zone differential in RFC format (GMT or +NNNN)
|
||||
/// * %% - percent sign
|
||||
///
|
||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||
|
||||
static std::string format(const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential = UTC);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeParser.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DateTimeParser.h#4 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DateTimeParser.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Debugger.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Debugger.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Debugger.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DefaultStrategy.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DefaultStrategy.h#5 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DefaultStrategy.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the DefaultStrategy template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -36,124 +36,100 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_DefaultStrategy_INCLUDED
|
||||
#define Foundation_DefaultStrategy_INCLUDED
|
||||
#ifndef Foundation_DefaultStrategy_INCLUDED
|
||||
#define Foundation_DefaultStrategy_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/NotificationStrategy.h"
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template <class TArgs, class TDelegate, class TCompare>
|
||||
class DefaultStrategy//: public NotificationStrategy<TArgs, TDelegate>
|
||||
/// Default notification strategy. Allows one observer
|
||||
/// to register exactly once. The observer must provide an
|
||||
/// < (less-than) operator.
|
||||
template <class TArgs, class TDelegate>
|
||||
class DefaultStrategy: public NotificationStrategy<TArgs, TDelegate>
|
||||
/// Default notification strategy.
|
||||
///
|
||||
/// Internally, a std::vector<> is used to store
|
||||
/// delegate objects. Delegates are invoked in the
|
||||
/// order in which they have been registered.
|
||||
{
|
||||
public:
|
||||
typedef std::set<TDelegate*, TCompare> Delegates;
|
||||
typedef typename Delegates::iterator Iterator;
|
||||
typedef typename Delegates::const_iterator ConstIterator;
|
||||
typedef SharedPtr<TDelegate> DelegatePtr;
|
||||
typedef std::vector<DelegatePtr> Delegates;
|
||||
typedef typename Delegates::iterator Iterator;
|
||||
|
||||
public:
|
||||
DefaultStrategy()
|
||||
{
|
||||
}
|
||||
DefaultStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
DefaultStrategy(const DefaultStrategy& s)
|
||||
{
|
||||
operator = (s);
|
||||
}
|
||||
DefaultStrategy(const DefaultStrategy& s):
|
||||
_delegates(s._delegates)
|
||||
{
|
||||
}
|
||||
|
||||
~DefaultStrategy()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
~DefaultStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
void notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
std::vector<Iterator> delMe;
|
||||
void notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it)
|
||||
{
|
||||
(*it)->notify(sender, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator it = _observers.begin(); it != _observers.end(); ++it)
|
||||
{
|
||||
if (!(*it)->notify(sender, arguments))
|
||||
{
|
||||
// schedule for deletion
|
||||
delMe.push_back(it);
|
||||
}
|
||||
}
|
||||
|
||||
while (!delMe.empty())
|
||||
{
|
||||
typename std::vector<Iterator>::iterator vit = delMe.end();
|
||||
--vit;
|
||||
delete **vit;
|
||||
_observers.erase(*vit);
|
||||
delMe.pop_back();
|
||||
}
|
||||
}
|
||||
void add(const TDelegate& delegate)
|
||||
{
|
||||
_delegates.push_back(DelegatePtr(static_cast<TDelegate*>(delegate.clone())));
|
||||
}
|
||||
|
||||
void add(const TDelegate& delegate)
|
||||
{
|
||||
Iterator it = _observers.find(const_cast<TDelegate*>(&delegate));
|
||||
if (it != _observers.end())
|
||||
{
|
||||
delete *it;
|
||||
_observers.erase(it);
|
||||
}
|
||||
std::auto_ptr<TDelegate> pDelegate(delegate.clone());
|
||||
bool tmp = _observers.insert(pDelegate.get()).second;
|
||||
poco_assert (tmp);
|
||||
pDelegate.release();
|
||||
}
|
||||
|
||||
void remove(const TDelegate& delegate)
|
||||
{
|
||||
Iterator it = _observers.find(const_cast<TDelegate*>(&delegate));
|
||||
if (it != _observers.end())
|
||||
{
|
||||
delete *it;
|
||||
_observers.erase(it);
|
||||
}
|
||||
}
|
||||
void remove(const TDelegate& delegate)
|
||||
{
|
||||
for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it)
|
||||
{
|
||||
if (delegate.equals(**it))
|
||||
{
|
||||
(*it)->disable();
|
||||
_delegates.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DefaultStrategy& operator = (const DefaultStrategy& s)
|
||||
{
|
||||
if (this != &s)
|
||||
{
|
||||
for (ConstIterator it = s._observers.begin(); it != s._observers.end(); ++it)
|
||||
{
|
||||
add(**it);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
{
|
||||
if (this != &s)
|
||||
{
|
||||
_delegates = s._delegates;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for (Iterator it = _observers.begin(); it != _observers.end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
_observers.clear();
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it)
|
||||
{
|
||||
(*it)->disable();
|
||||
}
|
||||
_delegates.clear();
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return _observers.empty();
|
||||
}
|
||||
bool empty() const
|
||||
{
|
||||
return _delegates.empty();
|
||||
}
|
||||
|
||||
protected:
|
||||
Delegates _observers;
|
||||
Delegates _delegates;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_DefaultStrategy_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Delegate.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Delegate.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Delegate.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the Delegate template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -44,22 +44,22 @@
|
||||
#include "Poco/AbstractDelegate.h"
|
||||
#include "Poco/FunctionDelegate.h"
|
||||
#include "Poco/Expire.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template <class TObj, class TArgs, bool withSender=true>
|
||||
template <class TObj, class TArgs, bool withSender = true>
|
||||
class Delegate: public AbstractDelegate<TArgs>
|
||||
{
|
||||
public:
|
||||
typedef void (TObj::*NotifyMethod)(const void*, TArgs&);
|
||||
typedef void (TObj::*NotifyMethod)(const void*, TArgs&);
|
||||
|
||||
Delegate(TObj* obj, NotifyMethod method):
|
||||
AbstractDelegate<TArgs>(obj),
|
||||
_receiverObject(obj),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
Delegate(TObj* obj, NotifyMethod method):
|
||||
_receiverObject(obj),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
Delegate(const Delegate& delegate):
|
||||
@@ -74,33 +74,50 @@ public:
|
||||
}
|
||||
|
||||
Delegate& operator = (const Delegate& delegate)
|
||||
{
|
||||
if (&delegate != this)
|
||||
{
|
||||
this->_pTarget = delegate._pTarget;
|
||||
this->_receiverObject = delegate._receiverObject;
|
||||
this->_receiverMethod = delegate._receiverMethod;
|
||||
}
|
||||
{
|
||||
if (&delegate != this)
|
||||
{
|
||||
this->_receiverObject = delegate._receiverObject;
|
||||
this->_receiverMethod = delegate._receiverMethod;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(_receiverObject->*_receiverMethod)(sender, arguments);
|
||||
return true; // a "standard" delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverObject)
|
||||
{
|
||||
(_receiverObject->*_receiverMethod)(sender, arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const Delegate* pOtherDelegate = reinterpret_cast<const Delegate*>(other.unwrap());
|
||||
return pOtherDelegate && _receiverObject == pOtherDelegate->_receiverObject && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new Delegate(*this);
|
||||
}
|
||||
return new Delegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverObject = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
TObj* _receiverObject;
|
||||
NotifyMethod _receiverMethod;
|
||||
TObj* _receiverObject;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
Delegate();
|
||||
Delegate();
|
||||
};
|
||||
|
||||
|
||||
@@ -108,13 +125,12 @@ template <class TObj, class TArgs>
|
||||
class Delegate<TObj, TArgs, false>: public AbstractDelegate<TArgs>
|
||||
{
|
||||
public:
|
||||
typedef void (TObj::*NotifyMethod)(TArgs&);
|
||||
typedef void (TObj::*NotifyMethod)(TArgs&);
|
||||
|
||||
Delegate(TObj* obj, NotifyMethod method):
|
||||
AbstractDelegate<TArgs>(obj),
|
||||
_receiverObject(obj),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
Delegate(TObj* obj, NotifyMethod method):
|
||||
_receiverObject(obj),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
Delegate(const Delegate& delegate):
|
||||
@@ -139,23 +155,41 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool notify(const void*, TArgs& arguments)
|
||||
{
|
||||
(_receiverObject->*_receiverMethod)(arguments);
|
||||
return true; // a "standard" delegate never expires
|
||||
}
|
||||
bool notify(const void*, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverObject)
|
||||
{
|
||||
(_receiverObject->*_receiverMethod)(arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const Delegate* pOtherDelegate = reinterpret_cast<const Delegate*>(other.unwrap());
|
||||
return pOtherDelegate && _receiverObject == pOtherDelegate->_receiverObject && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new Delegate(*this);
|
||||
}
|
||||
return new Delegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverObject = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
TObj* _receiverObject;
|
||||
NotifyMethod _receiverMethod;
|
||||
TObj* _receiverObject;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
Delegate();
|
||||
Delegate();
|
||||
};
|
||||
|
||||
|
||||
@@ -173,7 +207,6 @@ static Delegate<TObj, TArgs, false> delegate(TObj* pObj, void (TObj::*NotifyMeth
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class TObj, class TArgs>
|
||||
static Expire<TArgs> delegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||
{
|
||||
@@ -205,7 +238,7 @@ static Expire<TArgs> delegate(void (*NotifyMethod)(void*, TArgs&), Timestamp::Ti
|
||||
template <class TArgs>
|
||||
static Expire<TArgs> delegate(void (*NotifyMethod)(TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||
{
|
||||
return Expire<TArgs>(FunctionDelegate<TArgs, false>( NotifyMethod), expireMillisecs);
|
||||
return Expire<TArgs>(FunctionDelegate<TArgs, false>(NotifyMethod), expireMillisecs);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DigestEngine.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DigestEngine.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DigestEngine.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
@@ -82,15 +82,15 @@ public:
|
||||
/// The returned reference is valid until the next
|
||||
/// time digest() is called, or the engine object is destroyed.
|
||||
|
||||
static std::string digestToHex(const Digest& bytes);
|
||||
/// Converts a message digest into a string of hexadecimal numbers.
|
||||
static std::string digestToHex(const Digest& bytes);
|
||||
/// Converts a message digest into a string of hexadecimal numbers.
|
||||
|
||||
static Digest digestFromHex(const std::string& digest);
|
||||
/// Converts a string created by digestToHex back to its Digest presentation
|
||||
static Digest digestFromHex(const std::string& digest);
|
||||
/// Converts a string created by digestToHex back to its Digest presentation
|
||||
|
||||
protected:
|
||||
virtual void updateImpl(const void* data, unsigned length) = 0;
|
||||
/// Updates the digest with the given data. Must be implemented
|
||||
virtual void updateImpl(const void* data, unsigned length) = 0;
|
||||
/// Updates the digest with the given data. Must be implemented
|
||||
/// by subclasses.
|
||||
|
||||
private:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DigestStream.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DigestStream.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DigestStream.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DirectoryIterator.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DirectoryIterator.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_UNIX.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DirectoryIterator_UNIX.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DirectoryIterator_UNIX.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_VMS.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DirectoryIterator_VMS.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DirectoryIterator_VMS.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_WIN32.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DirectoryIterator_WIN32.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DirectoryIterator_WIN32.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_WIN32U.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DirectoryIterator_WIN32U.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DirectoryIterator_WIN32U.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicFactory.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/DynamicFactory.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/DynamicFactory.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Environment.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -71,22 +71,22 @@ public:
|
||||
/// Sets the environment variable with the given name
|
||||
/// to the given value.
|
||||
|
||||
static std::string osName();
|
||||
/// Returns the operating system name.
|
||||
|
||||
static std::string osDisplayName();
|
||||
/// Returns the operating system name in a
|
||||
/// "user-friendly" way.
|
||||
///
|
||||
/// Currently this is only implemented for
|
||||
/// Windows. There it will return names like
|
||||
/// "Windows XP" or "Windows 7/Server 2008 SP2".
|
||||
/// On other platform, returns the same as
|
||||
/// osName().
|
||||
|
||||
static std::string osVersion();
|
||||
/// Returns the operating system version.
|
||||
|
||||
static std::string osName();
|
||||
/// Returns the operating system name.
|
||||
|
||||
static std::string osDisplayName();
|
||||
/// Returns the operating system name in a
|
||||
/// "user-friendly" way.
|
||||
///
|
||||
/// Currently this is only implemented for
|
||||
/// Windows. There it will return names like
|
||||
/// "Windows XP" or "Windows 7/Server 2008 SP2".
|
||||
/// On other platform, returns the same as
|
||||
/// osName().
|
||||
|
||||
static std::string osVersion();
|
||||
/// Returns the operating system version.
|
||||
|
||||
static std::string osArchitecture();
|
||||
/// Returns the operating system architecture.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment_UNIX.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Environment_UNIX.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_UNIX.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -54,13 +54,13 @@ public:
|
||||
typedef UInt8 NodeId[6]; /// Ethernet address.
|
||||
|
||||
static std::string getImpl(const std::string& name);
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static void nodeIdImpl(NodeId& id);
|
||||
static unsigned processorCountImpl();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment_VMS.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Environment_VMS.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_VMS.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -53,13 +53,13 @@ public:
|
||||
typedef UInt8 NodeId[6]; /// Ethernet address.
|
||||
|
||||
static std::string getImpl(const std::string& name);
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static void nodeIdImpl(NodeId& id);
|
||||
static unsigned processorCountImpl();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment_VX.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_VX.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_VX.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -54,13 +54,13 @@ public:
|
||||
typedef UInt8 NodeId[6]; /// Ethernet address.
|
||||
|
||||
static std::string getImpl(const std::string& name);
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static void nodeIdImpl(NodeId& id);
|
||||
static unsigned processorCountImpl();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment_WIN32.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Environment_WIN32.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_WIN32.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -52,13 +52,13 @@ public:
|
||||
typedef UInt8 NodeId[6]; /// Ethernet address.
|
||||
|
||||
static std::string getImpl(const std::string& name);
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static void nodeIdImpl(NodeId& id);
|
||||
static unsigned processorCountImpl();
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment_WIN32U.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Environment_WIN32U.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_WIN32U.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -52,13 +52,13 @@ public:
|
||||
typedef UInt8 NodeId[6]; /// Ethernet address.
|
||||
|
||||
static std::string getImpl(const std::string& name);
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static void nodeIdImpl(NodeId& id);
|
||||
static unsigned processorCountImpl();
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Environment_WINCE.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_WINCE.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Environment_WINCE.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -52,13 +52,13 @@ public:
|
||||
typedef UInt8 NodeId[6]; /// Ethernet address.
|
||||
|
||||
static std::string getImpl(const std::string& name);
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static bool hasImpl(const std::string& name);
|
||||
static void setImpl(const std::string& name, const std::string& value);
|
||||
static std::string osNameImpl();
|
||||
static std::string osDisplayNameImpl();
|
||||
static std::string osVersionImpl();
|
||||
static std::string osArchitectureImpl();
|
||||
static std::string nodeNameImpl();
|
||||
static void nodeIdImpl(NodeId& id);
|
||||
static unsigned processorCountImpl();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ErrorHandler.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/ErrorHandler.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/ErrorHandler.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -56,13 +56,13 @@ class Foundation_API ErrorHandler
|
||||
/// about it.
|
||||
///
|
||||
/// The Thread class provides the possibility to register a
|
||||
/// global ErrorHandler that is invoked whenever a thread has
|
||||
/// been terminated by an unhandled exception.
|
||||
/// The ErrorHandler must be derived from this class and can
|
||||
/// provide implementations of all three handleException() overloads.
|
||||
///
|
||||
/// The ErrorHandler is always invoked within the context of
|
||||
/// the offending thread.
|
||||
/// global ErrorHandler that is invoked whenever a thread has
|
||||
/// been terminated by an unhandled exception.
|
||||
/// The ErrorHandler must be derived from this class and can
|
||||
/// provide implementations of all three exception() overloads.
|
||||
///
|
||||
/// The ErrorHandler is always invoked within the context of
|
||||
/// the offending thread.
|
||||
{
|
||||
public:
|
||||
ErrorHandler();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Event.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Event.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Event.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// EventLogChannel.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/EventLogChannel.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/EventLogChannel.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Event_POSIX.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Event_POSIX.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Event_POSIX.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Event_WIN32.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Event_WIN32.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Event_WIN32.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -51,10 +51,10 @@ namespace Poco {
|
||||
class Foundation_API EventImpl
|
||||
{
|
||||
protected:
|
||||
EventImpl(bool autoReset = false);
|
||||
~EventImpl();
|
||||
void setImpl();
|
||||
void waitImpl();
|
||||
EventImpl(bool autoReset);
|
||||
~EventImpl();
|
||||
void setImpl();
|
||||
void waitImpl();
|
||||
bool waitImpl(long milliseconds);
|
||||
void resetImpl();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Expire.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Expire.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Expire.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the Expire template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -36,8 +36,8 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Expire_INCLUDED
|
||||
#define Foundation_Expire_INCLUDED
|
||||
#ifndef Foundation_Expire_INCLUDED
|
||||
#define Foundation_Expire_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
@@ -50,15 +50,14 @@ namespace Poco {
|
||||
|
||||
template <class TArgs>
|
||||
class Expire: public AbstractDelegate<TArgs>
|
||||
/// Decorator for AbstractDelegate adding automatic
|
||||
/// expiring of registrations to AbstractDelegates.
|
||||
/// Decorator for AbstractDelegate adding automatic
|
||||
/// expiration of registrations to AbstractDelegate's.
|
||||
{
|
||||
public:
|
||||
Expire(const AbstractDelegate<TArgs>& p, Timestamp::TimeDiff expireMillisecs):
|
||||
AbstractDelegate<TArgs>(p),
|
||||
_pDelegate(p.clone()),
|
||||
_expire(expireMillisecs*1000)
|
||||
{
|
||||
Expire(const AbstractDelegate<TArgs>& p, Timestamp::TimeDiff expireMillisecs):
|
||||
_pDelegate(p.clone()),
|
||||
_expire(expireMillisecs*1000)
|
||||
{
|
||||
}
|
||||
|
||||
Expire(const Expire& expire):
|
||||
@@ -69,12 +68,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~Expire()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
Expire& operator = (const Expire& expire)
|
||||
~Expire()
|
||||
{
|
||||
delete _pDelegate;
|
||||
}
|
||||
|
||||
Expire& operator = (const Expire& expire)
|
||||
{
|
||||
if (&expire != this)
|
||||
{
|
||||
@@ -92,24 +91,28 @@ public:
|
||||
if (!expired())
|
||||
return this->_pDelegate->notify(sender, arguments);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new Expire(*this);
|
||||
}
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
return other.equals(*_pDelegate);
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
delete this->_pDelegate;
|
||||
this->_pDelegate = 0;
|
||||
}
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new Expire(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
_pDelegate->disable();
|
||||
}
|
||||
|
||||
const AbstractDelegate<TArgs>& getDelegate() const
|
||||
{
|
||||
return *this->_pDelegate;
|
||||
}
|
||||
const AbstractDelegate<TArgs>* unwrap() const
|
||||
{
|
||||
return this->_pDelegate;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool expired() const
|
||||
@@ -129,4 +132,4 @@ private:
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_Expire_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FIFOEvent.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FIFOEvent.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FIFOEvent.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the FIFOEvent template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -36,42 +36,36 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FIFOEvent_INCLUDED
|
||||
#define Foundation_FIFOEvent_INCLUDED
|
||||
#ifndef Foundation_FIFOEvent_INCLUDED
|
||||
#define Foundation_FIFOEvent_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/AbstractEvent.h"
|
||||
#include "Poco/FIFOStrategy.h"
|
||||
#include "Poco/AbstractDelegate.h"
|
||||
#include "Poco/CompareFunctions.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
//@ deprecated
|
||||
template <class TArgs, class TMutex = FastMutex>
|
||||
class FIFOEvent: public AbstractEvent <
|
||||
TArgs,
|
||||
FIFOStrategy<TArgs, AbstractDelegate<TArgs>, p_less<AbstractDelegate< TArgs> > >,
|
||||
AbstractDelegate<TArgs>,
|
||||
TMutex
|
||||
TArgs,
|
||||
FIFOStrategy<TArgs, AbstractDelegate<TArgs> >,
|
||||
AbstractDelegate<TArgs>,
|
||||
TMutex
|
||||
>
|
||||
/// A FIFOEvent uses internally a FIFOStrategy which guarantees
|
||||
/// that delegates are invoked in the order they were added to
|
||||
/// the event.
|
||||
///
|
||||
/// Note that one object can only register one method to a FIFOEvent.
|
||||
/// Subsequent registrations will overwrite the existing delegate.
|
||||
/// For example:
|
||||
/// FIFOEvent<int> tmp;
|
||||
/// MyClass myObject;
|
||||
/// tmp += delegate(&myObject, &MyClass::myMethod1);
|
||||
/// tmp += delegate(&myObject, &MyClass::myMethod2);
|
||||
///
|
||||
/// The second registration will overwrite the first one.
|
||||
/// that delegates are invoked in the order they were added to
|
||||
/// the event.
|
||||
///
|
||||
/// Note that as of release 1.4.2, this is the default behavior
|
||||
/// implemented by BasicEvent, so this class is provided
|
||||
/// for backwards compatibility only.
|
||||
{
|
||||
public:
|
||||
FIFOEvent()
|
||||
FIFOEvent()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -88,4 +82,4 @@ private:
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_FIFOEvent_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FIFOStrategy.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FIFOStrategy.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FIFOStrategy.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the FIFOStrategy template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -35,132 +35,47 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef Foundation_FIFOStrategy_INCLUDED
|
||||
#define Foundation_FIFOStrategy_INCLUDED
|
||||
|
||||
#ifndef Foundation_FIFOStrategy_INCLUDED
|
||||
#define Foundation_FIFOStrategy_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/NotificationStrategy.h"
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include "Poco/DefaultStrategy.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template <class TArgs, class TDelegate, class TCompare>
|
||||
class FIFOStrategy//: public NotificationStrategy<TArgs, TDelegate>
|
||||
//@ deprecated
|
||||
template <class TArgs, class TDelegate>
|
||||
class FIFOStrategy: public DefaultStrategy<TArgs, TDelegate>
|
||||
/// Note: As of release 1.4.2, DefaultStrategy already
|
||||
/// implements FIFO behavior, so this class is provided
|
||||
/// for backwards compatibility only.
|
||||
{
|
||||
public:
|
||||
typedef std::list<TDelegate*> Delegates;
|
||||
typedef typename Delegates::iterator Iterator;
|
||||
typedef typename Delegates::const_iterator ConstIterator;
|
||||
typedef std::map<TDelegate*, Iterator, TCompare> DelegateIndex;
|
||||
typedef typename DelegateIndex::iterator IndexIterator;
|
||||
typedef typename DelegateIndex::const_iterator ConstIndexIterator;
|
||||
FIFOStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
FIFOStrategy()
|
||||
{
|
||||
}
|
||||
FIFOStrategy(const FIFOStrategy& s):
|
||||
DefaultStrategy<TArgs, TDelegate>(s)
|
||||
{
|
||||
}
|
||||
|
||||
FIFOStrategy(const FIFOStrategy& s)
|
||||
{
|
||||
operator = (s);
|
||||
}
|
||||
~FIFOStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
~FIFOStrategy()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
std::vector<Iterator> delMe;
|
||||
Iterator it = _observers.begin();
|
||||
Iterator itEnd = _observers.end();
|
||||
|
||||
for (; it != itEnd; ++it)
|
||||
{
|
||||
if (!(*it)->notify(sender, arguments))
|
||||
{
|
||||
// schedule for deletion
|
||||
delMe.push_back(it);
|
||||
}
|
||||
}
|
||||
|
||||
while (!delMe.empty())
|
||||
{
|
||||
typename std::vector<Iterator>::iterator vit = delMe.end();
|
||||
--vit;
|
||||
delete **vit;
|
||||
_observers.erase(*vit);
|
||||
delMe.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void add(const TDelegate& delegate)
|
||||
{
|
||||
IndexIterator it = _observerIndex.find(const_cast<TDelegate*>(&delegate));
|
||||
if (it != _observerIndex.end())
|
||||
{
|
||||
delete *it->second;
|
||||
_observers.erase(it->second);
|
||||
_observerIndex.erase(it);
|
||||
}
|
||||
std::auto_ptr<TDelegate> pDelegate(delegate.clone());
|
||||
_observers.push_back(pDelegate.get());
|
||||
bool tmp = _observerIndex.insert(make_pair(pDelegate.get(), --_observers.end())).second;
|
||||
poco_assert (tmp);
|
||||
pDelegate.release();
|
||||
}
|
||||
|
||||
void remove(const TDelegate& delegate)
|
||||
{
|
||||
IndexIterator it = _observerIndex.find(const_cast<TDelegate*>(&delegate));
|
||||
|
||||
if (it != _observerIndex.end())
|
||||
{
|
||||
delete *it->second;
|
||||
_observers.erase(it->second);
|
||||
_observerIndex.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
FIFOStrategy& operator = (const FIFOStrategy& s)
|
||||
{
|
||||
if (this != &s)
|
||||
{
|
||||
for (ConstIterator it = s._observers.begin(); it != s._observers.end(); ++it)
|
||||
{
|
||||
add(**it);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for (Iterator it = _observers.begin(); it != _observers.end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
||||
_observers.clear();
|
||||
_observerIndex.clear();
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return _observers.empty();
|
||||
}
|
||||
|
||||
protected:
|
||||
Delegates _observers; /// Stores the delegates in the order they were added.
|
||||
DelegateIndex _observerIndex; /// For faster lookup when add/remove is used.
|
||||
FIFOStrategy& operator = (const FIFOStrategy& s)
|
||||
{
|
||||
DefaultStrategy<TArgs, TDelegate>::operator = (s);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_FIFOStrategy_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FPEnvironment.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FPEnvironment.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FPEnvironment_C99.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FPEnvironment_C99.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_C99.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FPEnvironment_DEC.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FPEnvironment_DEC.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_DEC.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FPEnvironment_DUMMY.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FPEnvironment_DUMMY.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_DUMMY.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FPEnvironment_SUN.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FPEnvironment_SUN.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_SUN.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FPEnvironment_WIN32.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FPEnvironment_WIN32.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FPEnvironment_WIN32.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// File.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File.h#9 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/File.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@@ -157,33 +157,33 @@ public:
|
||||
/// On such platforms, created() returns
|
||||
/// the time of the last inode modification.
|
||||
|
||||
Timestamp getLastModified() const;
|
||||
/// Returns the modification date of the file.
|
||||
|
||||
File& setLastModified(const Timestamp& ts);
|
||||
/// Sets the modification date of the file.
|
||||
|
||||
FileSize getSize() const;
|
||||
/// Returns the size of the file in bytes.
|
||||
|
||||
File& setSize(FileSize size);
|
||||
/// Sets the size of the file in bytes. Can be used
|
||||
/// to truncate a file.
|
||||
|
||||
File& setWriteable(bool flag = true);
|
||||
/// Makes the file writeable (if flag is true), or
|
||||
/// non-writeable (if flag is false) by setting the
|
||||
/// file's flags in the filesystem accordingly.
|
||||
|
||||
File& setReadOnly(bool flag = true);
|
||||
/// Makes the file non-writeable (if flag is true), or
|
||||
/// writeable (if flag is false) by setting the
|
||||
/// file's flags in the filesystem accordingly.
|
||||
|
||||
File& setExecutable(bool flag = true);
|
||||
/// Makes the file executable (if flag is true), or
|
||||
/// non-executable (if flag is false) by setting
|
||||
/// the file's permission bits accordingly.
|
||||
Timestamp getLastModified() const;
|
||||
/// Returns the modification date of the file.
|
||||
|
||||
File& setLastModified(const Timestamp& ts);
|
||||
/// Sets the modification date of the file.
|
||||
|
||||
FileSize getSize() const;
|
||||
/// Returns the size of the file in bytes.
|
||||
|
||||
File& setSize(FileSize size);
|
||||
/// Sets the size of the file in bytes. Can be used
|
||||
/// to truncate a file.
|
||||
|
||||
File& setWriteable(bool flag = true);
|
||||
/// Makes the file writeable (if flag is true), or
|
||||
/// non-writeable (if flag is false) by setting the
|
||||
/// file's flags in the filesystem accordingly.
|
||||
|
||||
File& setReadOnly(bool flag = true);
|
||||
/// Makes the file non-writeable (if flag is true), or
|
||||
/// writeable (if flag is false) by setting the
|
||||
/// file's flags in the filesystem accordingly.
|
||||
|
||||
File& setExecutable(bool flag = true);
|
||||
/// Makes the file executable (if flag is true), or
|
||||
/// non-executable (if flag is false) by setting
|
||||
/// the file's permission bits accordingly.
|
||||
///
|
||||
/// Does nothing on Windows and OpenVMS.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileChannel.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/FileChannel.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FileChannel.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@@ -137,13 +137,13 @@ class Foundation_API FileChannel: public Channel
|
||||
/// for the "times" property are supported:
|
||||
///
|
||||
/// * utc: Rotation strategy is based on UTC time (default).
|
||||
/// * local: Rotation strategy is based on local time.
|
||||
///
|
||||
/// Archived log files can be compressed using the gzip compression
|
||||
/// method. Compressing can be controlled with the "compression"
|
||||
/// property. The following values for the "compress" property
|
||||
/// are supported:
|
||||
///
|
||||
/// * local: Rotation strategy is based on local time.
|
||||
///
|
||||
/// Archived log files can be compressed using the gzip compression
|
||||
/// method. Compressing can be controlled with the "compression"
|
||||
/// property. The following values for the "compress" property
|
||||
/// are supported:
|
||||
///
|
||||
/// * true: Compress archived log files.
|
||||
/// * false: Do not compress archived log files.
|
||||
///
|
||||
@@ -151,23 +151,23 @@ class Foundation_API FileChannel: public Channel
|
||||
/// they reach a certain age, or if the number of archived
|
||||
/// log files reaches a given maximum number. This is
|
||||
/// controlled by the purgeAge and purgeCount properties.
|
||||
///
|
||||
/// The purgeAge property can have the following values:
|
||||
///
|
||||
/// * "none" or "" no purging
|
||||
/// * <n> [seconds] the maximum age is <n> seconds.
|
||||
/// * <n> minutes: the maximum age is <n> minutes.
|
||||
/// * <n> hours: the maximum age is <n> hours.
|
||||
///
|
||||
/// The purgeAge property can have the following values:
|
||||
///
|
||||
/// * "none" or "" no purging
|
||||
/// * <n> [seconds] the maximum age is <n> seconds.
|
||||
/// * <n> minutes: the maximum age is <n> minutes.
|
||||
/// * <n> hours: the maximum age is <n> hours.
|
||||
/// * <n> days: the maximum age is <n> days.
|
||||
/// * <n> weeks: the maximum age is <n> weeks.
|
||||
/// * <n> months: the maximum age is <n> months, where a month has 30 days.
|
||||
///
|
||||
/// The purgeCount property has an integer value that specifies the maximum number
|
||||
/// of archived log files. If the number is exceeded, archived log files are
|
||||
/// deleted, starting with the oldest. When "none" or empty string are
|
||||
/// supplied, they reset purgeCount to none (no purging).
|
||||
///
|
||||
/// For a more lightweight file channel class, see SimpleFileChannel.
|
||||
/// * <n> weeks: the maximum age is <n> weeks.
|
||||
/// * <n> months: the maximum age is <n> months, where a month has 30 days.
|
||||
///
|
||||
/// The purgeCount property has an integer value that specifies the maximum number
|
||||
/// of archived log files. If the number is exceeded, archived log files are
|
||||
/// deleted, starting with the oldest. When "none" or empty string are
|
||||
/// supplied, they reset purgeCount to none (no purging).
|
||||
///
|
||||
/// For a more lightweight file channel class, see SimpleFileChannel.
|
||||
{
|
||||
public:
|
||||
FileChannel();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileStream.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FileStream.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FileStream.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileStreamFactory.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FileStreamFactory.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FileStreamFactory.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: URI
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileStream_POSIX.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FileStream_POSIX.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FileStream_POSIX.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileStream_WIN32.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FileStream_WIN32.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FileStream_WIN32.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -58,15 +58,15 @@ public:
|
||||
~FileStreamBuf();
|
||||
/// Destroys the FileStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the given file in the given mode.
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the given file in the given mode.
|
||||
|
||||
bool close();
|
||||
/// Closes the File stream buffer. Returns true if successful,
|
||||
/// false otherwise.
|
||||
bool close();
|
||||
/// Closes the File stream buffer. Returns true if successful,
|
||||
/// false otherwise.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// change position by offset, according to way and mode
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// change position by offset, according to way and mode
|
||||
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// change to specified position, according to mode
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_UNIX.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_UNIX.h#6 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/File_UNIX.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_VMS.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_VMS.h#6 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/File_VMS.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_WIN32.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_WIN32.h#6 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/File_WIN32.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_WIN32U.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_WIN32U.h#6 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/File_WIN32U.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Format.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Format.h#1 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Format.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -106,18 +106,18 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
|
||||
/// If the number of characters in the output value is less than the specified width, blanks or
|
||||
/// leading zeros are added, according to the specified flags (-, +, 0).
|
||||
///
|
||||
/// Precision is a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters
|
||||
/// to be printed, the number of decimal places, or the number of significant digits.
|
||||
///
|
||||
/// Throws an InvalidArgumentException if an argument index is out of range.
|
||||
///
|
||||
/// Starting with release 1.4.3, an argument that does not match the format
|
||||
/// specifier no longer results in a BadCastException. The string [ERRFMT] is
|
||||
/// written to the result string instead.
|
||||
///
|
||||
/// If there are more format specifiers than values, the format specifiers without a corresponding value
|
||||
/// are copied verbatim to output.
|
||||
///
|
||||
/// Precision is a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters
|
||||
/// to be printed, the number of decimal places, or the number of significant digits.
|
||||
///
|
||||
/// Throws an InvalidArgumentException if an argument index is out of range.
|
||||
///
|
||||
/// Starting with release 1.4.3, an argument that does not match the format
|
||||
/// specifier no longer results in a BadCastException. The string [ERRFMT] is
|
||||
/// written to the result string instead.
|
||||
///
|
||||
/// If there are more format specifiers than values, the format specifiers without a corresponding value
|
||||
/// are copied verbatim to output.
|
||||
///
|
||||
/// If there are more values than format specifiers, the superfluous values are ignored.
|
||||
///
|
||||
/// Usage Examples:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Formatter.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Formatter.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Formatter.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FormattingChannel.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FormattingChannel.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FormattingChannel.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FunctionDelegate.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FunctionDelegate.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FunctionDelegate.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the FunctionDelegate template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -36,12 +36,13 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FunctionDelegate_INCLUDED
|
||||
#define Foundation_FunctionDelegate_INCLUDED
|
||||
#ifndef Foundation_FunctionDelegate_INCLUDED
|
||||
#define Foundation_FunctionDelegate_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/AbstractDelegate.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -49,17 +50,16 @@ namespace Poco {
|
||||
|
||||
template <class TArgs, bool hasSender = true, bool senderIsConst = true>
|
||||
class FunctionDelegate: public AbstractDelegate<TArgs>
|
||||
/// Wraps a C style function (or a C++ static function) to be used as
|
||||
/// a delegate
|
||||
/// Wraps a freestanding function or static member function
|
||||
/// for use as a Delegate.
|
||||
{
|
||||
public:
|
||||
typedef void (*NotifyMethod)(const void*, TArgs&);
|
||||
typedef void (*NotifyMethod)(const void*, TArgs&);
|
||||
|
||||
FunctionDelegate(NotifyMethod method):
|
||||
AbstractDelegate<TArgs>(*reinterpret_cast<void**>(&method)),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
FunctionDelegate(NotifyMethod method):
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionDelegate(const FunctionDelegate& delegate):
|
||||
AbstractDelegate<TArgs>(delegate),
|
||||
@@ -81,22 +81,40 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(*_receiverMethod)(sender, arguments);
|
||||
return true; // a "standard" delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverMethod)
|
||||
{
|
||||
(*_receiverMethod)(sender, arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const FunctionDelegate* pOtherDelegate = dynamic_cast<const FunctionDelegate*>(other.unwrap());
|
||||
return pOtherDelegate && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionDelegate(*this);
|
||||
}
|
||||
return new FunctionDelegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverMethod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
NotifyMethod _receiverMethod;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
FunctionDelegate();
|
||||
FunctionDelegate();
|
||||
};
|
||||
|
||||
|
||||
@@ -104,13 +122,12 @@ template <class TArgs>
|
||||
class FunctionDelegate<TArgs, true, false>: public AbstractDelegate<TArgs>
|
||||
{
|
||||
public:
|
||||
typedef void (*NotifyMethod)(void*, TArgs&);
|
||||
typedef void (*NotifyMethod)(void*, TArgs&);
|
||||
|
||||
FunctionDelegate(NotifyMethod method):
|
||||
AbstractDelegate<TArgs>(*reinterpret_cast<void**>(&method)),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
FunctionDelegate(NotifyMethod method):
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionDelegate(const FunctionDelegate& delegate):
|
||||
AbstractDelegate<TArgs>(delegate),
|
||||
@@ -132,22 +149,40 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(*_receiverMethod)(const_cast<void*>(sender), arguments);
|
||||
return true; // a "standard" delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverMethod)
|
||||
{
|
||||
(*_receiverMethod)(const_cast<void*>(sender), arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const FunctionDelegate* pOtherDelegate = dynamic_cast<const FunctionDelegate*>(other.unwrap());
|
||||
return pOtherDelegate && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionDelegate(*this);
|
||||
}
|
||||
return new FunctionDelegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverMethod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
NotifyMethod _receiverMethod;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
FunctionDelegate();
|
||||
FunctionDelegate();
|
||||
};
|
||||
|
||||
|
||||
@@ -155,13 +190,12 @@ template <class TArgs, bool senderIsConst>
|
||||
class FunctionDelegate<TArgs, false, senderIsConst>: public AbstractDelegate<TArgs>
|
||||
{
|
||||
public:
|
||||
typedef void (*NotifyMethod)(TArgs&);
|
||||
typedef void (*NotifyMethod)(TArgs&);
|
||||
|
||||
FunctionDelegate(NotifyMethod method):
|
||||
AbstractDelegate<TArgs>(*reinterpret_cast<void**>(&method)),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
FunctionDelegate(NotifyMethod method):
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionDelegate(const FunctionDelegate& delegate):
|
||||
AbstractDelegate<TArgs>(delegate),
|
||||
@@ -183,26 +217,44 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(*_receiverMethod)(arguments);
|
||||
return true; // a "standard" delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverMethod)
|
||||
{
|
||||
(*_receiverMethod)(arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const FunctionDelegate* pOtherDelegate = dynamic_cast<const FunctionDelegate*>(other.unwrap());
|
||||
return pOtherDelegate && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionDelegate(*this);
|
||||
}
|
||||
return new FunctionDelegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverMethod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
NotifyMethod _receiverMethod;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
FunctionDelegate();
|
||||
FunctionDelegate();
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_FunctionDelegate_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FunctionPriorityDelegate.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/FunctionPriorityDelegate.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/FunctionPriorityDelegate.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Events
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Implementation of the FunctionPriorityDelegate template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -36,12 +36,13 @@
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FunctionPriorityDelegate_INCLUDED
|
||||
#define Foundation_FunctionPriorityDelegate_INCLUDED
|
||||
#ifndef Foundation_FunctionPriorityDelegate_INCLUDED
|
||||
#define Foundation_FunctionPriorityDelegate_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/AbstractPriorityDelegate.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -49,23 +50,23 @@ namespace Poco {
|
||||
|
||||
template <class TArgs, bool useSender = true, bool senderIsConst = true>
|
||||
class FunctionPriorityDelegate: public AbstractPriorityDelegate<TArgs>
|
||||
/// Wraps a C style function (or a C++ static fucntion) to be used as
|
||||
/// a priority delegate
|
||||
/// Wraps a freestanding function or static member function
|
||||
/// for use as a PriorityDelegate.
|
||||
{
|
||||
public:
|
||||
typedef void (*NotifyMethod)(const void*, TArgs&);
|
||||
typedef void (*NotifyMethod)(const void*, TArgs&);
|
||||
|
||||
FunctionPriorityDelegate(NotifyMethod method, int prio):
|
||||
AbstractPriorityDelegate<TArgs>(*reinterpret_cast<void**>(&method), prio),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
|
||||
AbstractPriorityDelegate<TArgs>(delegate._pTarget, delegate._priority),
|
||||
_receiverMethod(delegate._receiverMethod)
|
||||
{
|
||||
}
|
||||
FunctionPriorityDelegate(NotifyMethod method, int prio):
|
||||
AbstractPriorityDelegate<TArgs>(prio),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
|
||||
AbstractPriorityDelegate<TArgs>(delegate),
|
||||
_receiverMethod(delegate._receiverMethod)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate)
|
||||
{
|
||||
@@ -82,22 +83,40 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(*_receiverMethod)(sender, arguments);
|
||||
return true; // per default the delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverMethod)
|
||||
{
|
||||
(*_receiverMethod)(sender, arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractPriorityDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionPriorityDelegate(*this);
|
||||
}
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap());
|
||||
return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionPriorityDelegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverMethod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
NotifyMethod _receiverMethod;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
FunctionPriorityDelegate();
|
||||
FunctionPriorityDelegate();
|
||||
};
|
||||
|
||||
|
||||
@@ -105,19 +124,19 @@ template <class TArgs>
|
||||
class FunctionPriorityDelegate<TArgs, true, false>: public AbstractPriorityDelegate<TArgs>
|
||||
{
|
||||
public:
|
||||
typedef void (*NotifyMethod)(void*, TArgs&);
|
||||
typedef void (*NotifyMethod)(void*, TArgs&);
|
||||
|
||||
FunctionPriorityDelegate(NotifyMethod method, int prio):
|
||||
AbstractPriorityDelegate<TArgs>(*reinterpret_cast<void**>(&method), prio),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
|
||||
AbstractPriorityDelegate<TArgs>(delegate._pTarget, delegate._priority),
|
||||
_receiverMethod(delegate._receiverMethod)
|
||||
{
|
||||
}
|
||||
FunctionPriorityDelegate(NotifyMethod method, int prio):
|
||||
AbstractPriorityDelegate<TArgs>(prio),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
|
||||
AbstractPriorityDelegate<TArgs>(delegate),
|
||||
_receiverMethod(delegate._receiverMethod)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate)
|
||||
{
|
||||
@@ -134,43 +153,60 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(*_receiverMethod)(const_cast<void*>(sender), arguments);
|
||||
return true; // per default the delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverMethod)
|
||||
{
|
||||
(*_receiverMethod)(const_cast<void*>(sender), arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractPriorityDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionPriorityDelegate(*this);
|
||||
}
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap());
|
||||
return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionPriorityDelegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverMethod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
NotifyMethod _receiverMethod;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
FunctionPriorityDelegate();
|
||||
FunctionPriorityDelegate();
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class TArgs>
|
||||
class FunctionPriorityDelegate<TArgs, false>: public AbstractPriorityDelegate<TArgs>
|
||||
{
|
||||
public:
|
||||
typedef void (*NotifyMethod)(TArgs&);
|
||||
typedef void (*NotifyMethod)(TArgs&);
|
||||
|
||||
FunctionPriorityDelegate(NotifyMethod method, int prio):
|
||||
AbstractPriorityDelegate<TArgs>(*reinterpret_cast<void**>(&method), prio),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
|
||||
AbstractPriorityDelegate<TArgs>(delegate._pTarget, delegate._priority),
|
||||
_receiverMethod(delegate._receiverMethod)
|
||||
{
|
||||
}
|
||||
FunctionPriorityDelegate(NotifyMethod method, int prio):
|
||||
AbstractPriorityDelegate<TArgs>(prio),
|
||||
_receiverMethod(method)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
|
||||
AbstractPriorityDelegate<TArgs>(delegate),
|
||||
_receiverMethod(delegate._receiverMethod)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate)
|
||||
{
|
||||
@@ -187,26 +223,44 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
(*_receiverMethod)(arguments);
|
||||
return true; // per default the delegate never expires
|
||||
}
|
||||
bool notify(const void* sender, TArgs& arguments)
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_receiverMethod)
|
||||
{
|
||||
(*_receiverMethod)(arguments);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
AbstractPriorityDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionPriorityDelegate(*this);
|
||||
}
|
||||
bool equals(const AbstractDelegate<TArgs>& other) const
|
||||
{
|
||||
const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap());
|
||||
return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverMethod == pOtherDelegate->_receiverMethod;
|
||||
}
|
||||
|
||||
AbstractDelegate<TArgs>* clone() const
|
||||
{
|
||||
return new FunctionPriorityDelegate(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
_receiverMethod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
NotifyMethod _receiverMethod;
|
||||
NotifyMethod _receiverMethod;
|
||||
Mutex _mutex;
|
||||
|
||||
private:
|
||||
FunctionPriorityDelegate();
|
||||
FunctionPriorityDelegate();
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif
|
||||
#endif // Foundation_FunctionPriorityDelegate_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Glob.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Glob.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Glob.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HMACEngine.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HMACEngine.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HMACEngine.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
|
@@ -1,127 +1,127 @@
|
||||
//
|
||||
// Hash.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Hash.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
// Module: Hash
|
||||
//
|
||||
// Definition of the Hash class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Hash_INCLUDED
|
||||
#define Foundation_Hash_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
std::size_t Foundation_API hash(Int8 n);
|
||||
std::size_t Foundation_API hash(UInt8 n);
|
||||
std::size_t Foundation_API hash(Int16 n);
|
||||
std::size_t Foundation_API hash(UInt16 n);
|
||||
std::size_t Foundation_API hash(Int32 n);
|
||||
std::size_t Foundation_API hash(UInt32 n);
|
||||
std::size_t Foundation_API hash(Int64 n);
|
||||
std::size_t Foundation_API hash(UInt64 n);
|
||||
std::size_t Foundation_API hash(const std::string& str);
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Hash
|
||||
/// A generic hash function.
|
||||
{
|
||||
std::size_t operator () (T value) const
|
||||
/// Returns the hash for the given value.
|
||||
{
|
||||
return Poco::hash(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline std::size_t hash(Int8 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt8 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(Int16 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt16 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(Int32 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt32 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(Int64 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt64 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Hash_INCLUDED
|
||||
//
|
||||
// Hash.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Hash.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
// Module: Hash
|
||||
//
|
||||
// Definition of the Hash class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Hash_INCLUDED
|
||||
#define Foundation_Hash_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
std::size_t Foundation_API hash(Int8 n);
|
||||
std::size_t Foundation_API hash(UInt8 n);
|
||||
std::size_t Foundation_API hash(Int16 n);
|
||||
std::size_t Foundation_API hash(UInt16 n);
|
||||
std::size_t Foundation_API hash(Int32 n);
|
||||
std::size_t Foundation_API hash(UInt32 n);
|
||||
std::size_t Foundation_API hash(Int64 n);
|
||||
std::size_t Foundation_API hash(UInt64 n);
|
||||
std::size_t Foundation_API hash(const std::string& str);
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Hash
|
||||
/// A generic hash function.
|
||||
{
|
||||
std::size_t operator () (T value) const
|
||||
/// Returns the hash for the given value.
|
||||
{
|
||||
return Poco::hash(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline std::size_t hash(Int8 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt8 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(Int16 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt16 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(Int32 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt32 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(Int64 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
inline std::size_t hash(UInt64 n)
|
||||
{
|
||||
return static_cast<std::size_t>(n)*2654435761U;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Hash_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashFunction.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HashFunction.h#5 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HashFunction.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashMap.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HashMap.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HashMap.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashSet.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HashSet.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HashSet.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashStatistic.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HashStatistic.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HashStatistic.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashTable.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HashTable.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HashTable.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
@@ -77,13 +77,13 @@ public:
|
||||
_entries(0),
|
||||
_size(0),
|
||||
_maxCapacity(initialSize)
|
||||
/// Creates the HashTable.
|
||||
{
|
||||
_entries = new HashEntryMap*[initialSize];
|
||||
std::memset(_entries, '\0', sizeof(HashEntryMap*)*initialSize);
|
||||
}
|
||||
/// Creates the HashTable.
|
||||
{
|
||||
_entries = new HashEntryMap*[initialSize];
|
||||
std::memset(_entries, '\0', sizeof(HashEntryMap*)*initialSize);
|
||||
}
|
||||
|
||||
HashTable(const HashTable& ht):
|
||||
HashTable(const HashTable& ht):
|
||||
_entries(new HashEntryMap*[ht._maxCapacity]),
|
||||
_size(ht._size),
|
||||
_maxCapacity(ht._maxCapacity)
|
||||
@@ -312,13 +312,13 @@ public:
|
||||
{
|
||||
HashTableVector cpy = _entries;
|
||||
_entries = 0;
|
||||
UInt32 oldSize = _maxCapacity;
|
||||
_maxCapacity = newSize;
|
||||
_entries = new HashEntryMap*[_maxCapacity];
|
||||
std::memset(_entries, '\0', sizeof(HashEntryMap*)*_maxCapacity);
|
||||
UInt32 oldSize = _maxCapacity;
|
||||
_maxCapacity = newSize;
|
||||
_entries = new HashEntryMap*[_maxCapacity];
|
||||
std::memset(_entries, '\0', sizeof(HashEntryMap*)*_maxCapacity);
|
||||
|
||||
if (_size == 0)
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
// no data was yet inserted
|
||||
delete[] cpy;
|
||||
return;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HexBinaryDecoder.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HexBinaryDecoder.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HexBinaryDecoder.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -52,25 +52,25 @@ class Foundation_API HexBinaryDecoderBuf: public UnbufferedStreamBuf
|
||||
/// This streambuf decodes all hexBinary-encoded data read
|
||||
/// from the istream connected to it.
|
||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
{
|
||||
public:
|
||||
HexBinaryDecoderBuf(std::istream& istr);
|
||||
HexBinaryDecoderBuf(std::istream& istr);
|
||||
~HexBinaryDecoderBuf();
|
||||
|
||||
private:
|
||||
int readFromDevice();
|
||||
int readOne();
|
||||
int readFromDevice();
|
||||
int readOne();
|
||||
|
||||
std::streambuf& _buf;
|
||||
std::streambuf& _buf;
|
||||
};
|
||||
|
||||
|
||||
@@ -94,18 +94,18 @@ class Foundation_API HexBinaryDecoder: public HexBinaryDecoderIOS, public std::i
|
||||
/// This istream decodes all hexBinary-encoded data read
|
||||
/// from the istream connected to it.
|
||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: For performance reasons, the characters
|
||||
/// are read directly from the given istream's
|
||||
/// underlying streambuf, so the state
|
||||
/// of the istream will not reflect that of
|
||||
/// its streambuf.
|
||||
{
|
||||
public:
|
||||
HexBinaryDecoder(std::istream& istr);
|
||||
HexBinaryDecoder(std::istream& istr);
|
||||
~HexBinaryDecoder();
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HexBinaryEncoder.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/HexBinaryEncoder.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/HexBinaryEncoder.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@@ -53,17 +53,17 @@ class Foundation_API HexBinaryEncoderBuf: public UnbufferedStreamBuf
|
||||
/// to it in hexBinary encoding and forwards it to a connected
|
||||
/// ostream.
|
||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
{
|
||||
public:
|
||||
HexBinaryEncoderBuf(std::ostream& ostr);
|
||||
HexBinaryEncoderBuf(std::ostream& ostr);
|
||||
~HexBinaryEncoderBuf();
|
||||
|
||||
int close();
|
||||
@@ -86,10 +86,10 @@ public:
|
||||
private:
|
||||
int writeToDevice(char c);
|
||||
|
||||
int _pos;
|
||||
int _lineLength;
|
||||
int _uppercase;
|
||||
std::streambuf& _buf;
|
||||
int _pos;
|
||||
int _lineLength;
|
||||
int _uppercase;
|
||||
std::streambuf& _buf;
|
||||
};
|
||||
|
||||
|
||||
@@ -118,17 +118,17 @@ class Foundation_API HexBinaryEncoder: public HexBinaryEncoderIOS, public std::o
|
||||
/// writing data, to ensure proper
|
||||
/// completion of the encoding operation.
|
||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||
/// section 3.2.15.
|
||||
///
|
||||
/// Note: The characters are directly written
|
||||
/// to the ostream's streambuf, thus bypassing
|
||||
/// the ostream. The ostream's state is therefore
|
||||
/// not updated to match the buffer's state.
|
||||
{
|
||||
public:
|
||||
HexBinaryEncoder(std::ostream& ostr);
|
||||
HexBinaryEncoder(std::ostream& ostr);
|
||||
~HexBinaryEncoder();
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Instantiator.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Instantiator.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Instantiator.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// KeyValueArgs.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/KeyValueArgs.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/KeyValueArgs.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// LRUCache.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/LRUCache.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/LRUCache.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@@ -51,13 +51,13 @@ template <
|
||||
class TKey,
|
||||
class TValue,
|
||||
class TMutex = FastMutex,
|
||||
class TEventMutex = FastMutex
|
||||
class TEventMutex = FastMutex
|
||||
>
|
||||
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TMutex, TEventMutex>
|
||||
/// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries.
|
||||
/// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries.
|
||||
{
|
||||
public:
|
||||
LRUCache(long size = 1024):
|
||||
LRUCache(long size = 1024):
|
||||
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TMutex, TEventMutex>(LRUStrategy<TKey, TValue>(size))
|
||||
{
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Latin9Encoding.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/Latin9Encoding.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/Latin9Encoding.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// LineEndingConverter.h
|
||||
//
|
||||
// $Id: //poco/svn/Foundation/include/Poco/LineEndingConverter.h#2 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/LineEndingConverter.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user