mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 03:03:23 +02:00
latest sources from main repository
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="iphlpapi.lib"
|
AdditionalDependencies="iphlpapi.lib unicows.lib"
|
||||||
OutputFile="..\bin\PocoFoundationd.dll"
|
OutputFile="..\bin\PocoFoundationd.dll"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="iphlpapi.lib"
|
AdditionalDependencies="iphlpapi.lib unicows.lib"
|
||||||
OutputFile="..\bin\PocoFoundation.dll"
|
OutputFile="..\bin\PocoFoundation.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
@@ -3497,6 +3497,12 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\FIFOStrategy.h">
|
RelativePath=".\include\Poco\FIFOStrategy.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\FunctionDelegate.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\FunctionPriorityDelegate.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\NotificationStrategy.h">
|
RelativePath=".\include\Poco\NotificationStrategy.h">
|
||||||
</File>
|
</File>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8,00"
|
||||||
Name="Foundation"
|
Name="Foundation"
|
||||||
ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
||||||
RootNamespace="Foundation"
|
RootNamespace="Foundation"
|
||||||
@@ -4551,6 +4551,14 @@
|
|||||||
RelativePath=".\include\Poco\FIFOStrategy.h"
|
RelativePath=".\include\Poco\FIFOStrategy.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\FunctionDelegate.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\FunctionPriorityDelegate.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\NotificationStrategy.h"
|
RelativePath=".\include\Poco\NotificationStrategy.h"
|
||||||
>
|
>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// AbstractDelegate.h
|
// AbstractDelegate.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/AbstractDelegate.h#3 $
|
// $Id: //poco/Main/Foundation/include/Poco/AbstractDelegate.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
poco_assert_dbg (_pTarget != 0);
|
poco_assert_dbg (_pTarget != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDelegate(const AbstractDelegate& del):_pTarget(del._pTarget)
|
AbstractDelegate(const AbstractDelegate& del): _pTarget(del._pTarget)
|
||||||
{
|
{
|
||||||
poco_assert_dbg (_pTarget != 0);
|
poco_assert_dbg (_pTarget != 0);
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// AbstractEvent.h
|
// AbstractEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/AbstractEvent.h#8 $
|
// $Id: //poco/Main/Foundation/include/Poco/AbstractEvent.h#9 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -53,7 +53,7 @@ namespace Poco {
|
|||||||
|
|
||||||
template <class TArgs, class TStrategy, class TDelegate>
|
template <class TArgs, class TStrategy, class TDelegate>
|
||||||
class AbstractEvent
|
class AbstractEvent
|
||||||
/// An abstractEvent is the super-class of all events.
|
/// An AbstractEvent is the super-class of all events.
|
||||||
/// It works similar to the way C# handles notifications (aka events in C#).
|
/// 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
|
/// 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
|
/// which are registered at the event. The type of the data is specified with
|
||||||
@@ -63,7 +63,20 @@ class AbstractEvent
|
|||||||
///
|
///
|
||||||
/// Note that AbstractEvent should never be used directly. One ought to use
|
/// Note that AbstractEvent should never be used directly. One ought to use
|
||||||
/// one of its subclasses which set the TStrategy and TDelegate template parameters
|
/// 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.
|
/// 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"
|
||||||
///
|
///
|
||||||
/// Use events by adding them as public members to the object which is throwing notifications:
|
/// Use events by adding them as public members to the object which is throwing notifications:
|
||||||
///
|
///
|
||||||
@@ -95,9 +108,13 @@ class AbstractEvent
|
|||||||
/// the Delegate template is used, in case of an PriorityEvent a PriorityDelegate is used.
|
/// 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
|
/// Mixing of observers, e.g. using a PriorityDelegate with a BasicEvent is not possible and
|
||||||
/// checked for during compile time.
|
/// checked for during compile time.
|
||||||
/// Events require the observers to follow the following method signature:
|
/// Events require the observers to follow one of the following method signature:
|
||||||
///
|
///
|
||||||
/// void onEvent(const void* pSender, TArgs& args);
|
/// 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
|
/// 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
|
/// to modify the sent argument. To prevent that, use <const TArg> as template
|
||||||
@@ -117,12 +134,13 @@ class AbstractEvent
|
|||||||
///
|
///
|
||||||
/// MyController::MyController()
|
/// MyController::MyController()
|
||||||
/// {
|
/// {
|
||||||
/// _data.AgeChanged += Delegate<MyController, int>(this, &MyController::onDataChanged);
|
/// _data.AgeChanged += delegate(this, &MyController::onDataChanged);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// In some cases it might be desirable to work with automatically expiring registrations:
|
/// 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 += Expire<int>(Delegate<MyController, int>(this, &MyController::onDataChanged), 1000);
|
/// _data.DataChanged += delegate(this, &MyController::onDataChanged, 1000);
|
||||||
///
|
///
|
||||||
/// This will add a delegate to the event which will automatically be removed in 1000 millisecs.
|
/// This will add a delegate to the event which will automatically be removed in 1000 millisecs.
|
||||||
///
|
///
|
||||||
@@ -131,9 +149,12 @@ class AbstractEvent
|
|||||||
///
|
///
|
||||||
/// MyController::~MyController()
|
/// MyController::~MyController()
|
||||||
/// {
|
/// {
|
||||||
/// _data.DataChanged -= Delegate<MyController, int>(this, &MyController::onDataChanged);
|
/// _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.
|
/// For further examples refer to the event testsuites.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveMethod.h
|
// ActiveMethod.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveMethod.h#3 $
|
// $Id: //poco/Main/Foundation/include/Poco/ActiveMethod.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
@@ -125,6 +125,81 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class ResultType, class OwnerType, class StarterType>
|
||||||
|
class ActiveMethod <ResultType, void, OwnerType, StarterType>
|
||||||
|
/// An active method is a method that, when called, executes
|
||||||
|
/// in its own thread. ActiveMethod's take exactly one
|
||||||
|
/// argument and can return a value. To pass more than one
|
||||||
|
/// argument to the method, use a struct.
|
||||||
|
/// The following example shows how to add an ActiveMethod
|
||||||
|
/// to a class:
|
||||||
|
///
|
||||||
|
/// class ActiveObject
|
||||||
|
/// {
|
||||||
|
/// public:
|
||||||
|
/// ActiveObject():
|
||||||
|
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
||||||
|
/// {
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;
|
||||||
|
///
|
||||||
|
/// protected:
|
||||||
|
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
||||||
|
/// {
|
||||||
|
/// ...
|
||||||
|
/// }
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
/// And following is an example that shows how to invoke an ActiveMethod.
|
||||||
|
///
|
||||||
|
/// ActiveObject myActiveObject;
|
||||||
|
/// ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
|
||||||
|
/// ...
|
||||||
|
/// result.wait();
|
||||||
|
/// std::cout << result.data() << std::endl;
|
||||||
|
///
|
||||||
|
/// The way an ActiveMethod is started can be changed by passing a StarterType
|
||||||
|
/// template argument with a corresponding class. The default ActiveStarter
|
||||||
|
/// starts the method in its own thread, obtained from a thread pool.
|
||||||
|
///
|
||||||
|
/// For an alternative implementation of StarterType, see ActiveDispatcher.
|
||||||
|
///
|
||||||
|
/// For methods that do not require an argument or a return value, simply use void.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef ResultType (OwnerType::*Callback)(void);
|
||||||
|
typedef ActiveResult<ResultType> ActiveResultType;
|
||||||
|
typedef ActiveRunnable<ResultType, void, OwnerType> ActiveRunnableType;
|
||||||
|
|
||||||
|
ActiveMethod(OwnerType* pOwner, Callback method):
|
||||||
|
_pOwner(pOwner),
|
||||||
|
_method(method)
|
||||||
|
/// Creates an ActiveMethod object.
|
||||||
|
{
|
||||||
|
poco_check_ptr (pOwner);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveResultType operator () (void)
|
||||||
|
/// Invokes the ActiveMethod.
|
||||||
|
{
|
||||||
|
ActiveResultType result(new ActiveResultHolder<ResultType>());
|
||||||
|
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, result));
|
||||||
|
StarterType::start(_pOwner, pRunnable);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ActiveMethod();
|
||||||
|
ActiveMethod(const ActiveMethod&);
|
||||||
|
ActiveMethod& operator = (const ActiveMethod&);
|
||||||
|
|
||||||
|
OwnerType* _pOwner;
|
||||||
|
Callback _method;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveResult.h
|
// ActiveResult.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveResult.h#5 $
|
// $Id: //poco/Main/Foundation/include/Poco/ActiveResult.h#6 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
@@ -162,6 +162,97 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class ActiveResultHolder<void>: public RefCountedObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActiveResultHolder():
|
||||||
|
_pExc(0),
|
||||||
|
_event(false)
|
||||||
|
/// Creates an ActiveResultHolder.
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wait()
|
||||||
|
/// Pauses the caller until the result becomes available.
|
||||||
|
{
|
||||||
|
_event.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tryWait(long milliseconds)
|
||||||
|
/// Waits up to the specified interval for the result to
|
||||||
|
/// become available. Returns true if the result became
|
||||||
|
/// available, false otherwise.
|
||||||
|
{
|
||||||
|
return _event.tryWait(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wait(long milliseconds)
|
||||||
|
/// Waits up to the specified interval for the result to
|
||||||
|
/// become available. Throws a TimeoutException if the
|
||||||
|
/// result did not became available.
|
||||||
|
{
|
||||||
|
_event.wait(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void notify()
|
||||||
|
/// Notifies the invoking thread that the result became available.
|
||||||
|
{
|
||||||
|
_event.set();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool failed() const
|
||||||
|
/// Returns true if the active method failed (and threw an exception).
|
||||||
|
/// Information about the exception can be obtained by calling error().
|
||||||
|
{
|
||||||
|
return _pExc != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string error() const
|
||||||
|
/// If the active method threw an exception, a textual representation
|
||||||
|
/// of the exception is returned. An empty string is returned if the
|
||||||
|
/// active method completed successfully.
|
||||||
|
{
|
||||||
|
if (_pExc)
|
||||||
|
return _pExc->message();
|
||||||
|
else
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
Exception* exception() const
|
||||||
|
/// If the active method threw an exception, a clone of the exception
|
||||||
|
/// object is returned, otherwise null.
|
||||||
|
{
|
||||||
|
return _pExc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(const Exception& exc)
|
||||||
|
/// Sets the exception.
|
||||||
|
{
|
||||||
|
delete _pExc;
|
||||||
|
_pExc = exc.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(const std::string& msg)
|
||||||
|
/// Sets the exception.
|
||||||
|
{
|
||||||
|
delete _pExc;
|
||||||
|
_pExc = new UnhandledException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~ActiveResultHolder()
|
||||||
|
{
|
||||||
|
delete _pExc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Exception* _pExc;
|
||||||
|
Event _event;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class RT>
|
template <class RT>
|
||||||
class ActiveResult
|
class ActiveResult
|
||||||
/// This class holds the result of an asynchronous method
|
/// This class holds the result of an asynchronous method
|
||||||
@@ -300,6 +391,126 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class ActiveResult<void>
|
||||||
|
/// This class holds the result of an asynchronous method
|
||||||
|
/// invocation (see class ActiveMethod). It is used to pass the
|
||||||
|
/// result from the execution thread back to the invocation thread.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef ActiveResultHolder<void> ActiveResultHolderType;
|
||||||
|
|
||||||
|
ActiveResult(ActiveResultHolderType* pHolder):
|
||||||
|
_pHolder(pHolder)
|
||||||
|
/// Creates the active result. For internal use only.
|
||||||
|
{
|
||||||
|
poco_check_ptr (pHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveResult(const ActiveResult& result)
|
||||||
|
/// Copy constructor.
|
||||||
|
{
|
||||||
|
_pHolder = result._pHolder;
|
||||||
|
_pHolder->duplicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
~ActiveResult()
|
||||||
|
/// Destroys the result.
|
||||||
|
{
|
||||||
|
_pHolder->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveResult& operator = (const ActiveResult& result)
|
||||||
|
/// Assignment operator.
|
||||||
|
{
|
||||||
|
ActiveResult tmp(result);
|
||||||
|
swap(tmp);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(ActiveResult& result)
|
||||||
|
{
|
||||||
|
using std::swap;
|
||||||
|
swap(_pHolder, result._pHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wait()
|
||||||
|
/// Pauses the caller until the result becomes available.
|
||||||
|
{
|
||||||
|
_pHolder->wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tryWait(long milliseconds)
|
||||||
|
/// Waits up to the specified interval for the result to
|
||||||
|
/// become available. Returns true if the result became
|
||||||
|
/// available, false otherwise.
|
||||||
|
{
|
||||||
|
return _pHolder->tryWait(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wait(long milliseconds)
|
||||||
|
/// Waits up to the specified interval for the result to
|
||||||
|
/// become available. Throws a TimeoutException if the
|
||||||
|
/// result did not became available.
|
||||||
|
{
|
||||||
|
_pHolder->wait(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool available() const
|
||||||
|
/// Returns true if a result is available.
|
||||||
|
{
|
||||||
|
return _pHolder->tryWait(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool failed() const
|
||||||
|
/// Returns true if the active method failed (and threw an exception).
|
||||||
|
/// Information about the exception can be obtained by calling error().
|
||||||
|
{
|
||||||
|
return _pHolder->failed();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string error() const
|
||||||
|
/// If the active method threw an exception, a textual representation
|
||||||
|
/// of the exception is returned. An empty string is returned if the
|
||||||
|
/// active method completed successfully.
|
||||||
|
{
|
||||||
|
return _pHolder->error();
|
||||||
|
}
|
||||||
|
|
||||||
|
Exception* exception() const
|
||||||
|
/// If the active method threw an exception, a clone of the exception
|
||||||
|
/// object is returned, otherwise null.
|
||||||
|
{
|
||||||
|
return _pHolder->exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
void notify()
|
||||||
|
/// Notifies the invoking thread that the result became available.
|
||||||
|
/// For internal use only.
|
||||||
|
{
|
||||||
|
_pHolder->notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(const std::string& msg)
|
||||||
|
/// Sets the failed flag and the exception message.
|
||||||
|
{
|
||||||
|
_pHolder->error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(const Exception& exc)
|
||||||
|
/// Sets the failed flag and the exception message.
|
||||||
|
{
|
||||||
|
_pHolder->error(exc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ActiveResult();
|
||||||
|
|
||||||
|
ActiveResultHolderType* _pHolder;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveRunnable.h
|
// ActiveRunnable.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/ActiveRunnable.h#4 $
|
// $Id: //poco/Main/Foundation/include/Poco/ActiveRunnable.h#6 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
@@ -107,6 +107,146 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class ArgType, class OwnerType>
|
||||||
|
class ActiveRunnable<void, ArgType, OwnerType>: public ActiveRunnableBase
|
||||||
|
/// This class is used by ActiveMethod.
|
||||||
|
/// See the ActiveMethod class for more information.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (OwnerType::*Callback)(const ArgType&);
|
||||||
|
typedef ActiveResult<void> ActiveResultType;
|
||||||
|
|
||||||
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result):
|
||||||
|
_pOwner(pOwner),
|
||||||
|
_method(method),
|
||||||
|
_arg(arg),
|
||||||
|
_result(result)
|
||||||
|
{
|
||||||
|
poco_check_ptr (pOwner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(_pOwner->*_method)(_arg);
|
||||||
|
}
|
||||||
|
catch (Exception& e)
|
||||||
|
{
|
||||||
|
_result.error(e);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
_result.error(e.what());
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
_result.error("unknown exception");
|
||||||
|
}
|
||||||
|
_result.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
OwnerType* _pOwner;
|
||||||
|
Callback _method;
|
||||||
|
ArgType _arg;
|
||||||
|
ActiveResultType _result;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class ResultType, class OwnerType>
|
||||||
|
class ActiveRunnable<ResultType, void, OwnerType>: public ActiveRunnableBase
|
||||||
|
/// This class is used by ActiveMethod.
|
||||||
|
/// See the ActiveMethod class for more information.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef ResultType (OwnerType::*Callback)();
|
||||||
|
typedef ActiveResult<ResultType> ActiveResultType;
|
||||||
|
|
||||||
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
|
||||||
|
_pOwner(pOwner),
|
||||||
|
_method(method),
|
||||||
|
_result(result)
|
||||||
|
{
|
||||||
|
poco_check_ptr (pOwner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_result.data(new ResultType((_pOwner->*_method)()));
|
||||||
|
}
|
||||||
|
catch (Exception& e)
|
||||||
|
{
|
||||||
|
_result.error(e);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
_result.error(e.what());
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
_result.error("unknown exception");
|
||||||
|
}
|
||||||
|
_result.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
OwnerType* _pOwner;
|
||||||
|
Callback _method;
|
||||||
|
ActiveResultType _result;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class OwnerType>
|
||||||
|
class ActiveRunnable<void, void, OwnerType>: public ActiveRunnableBase
|
||||||
|
/// This class is used by ActiveMethod.
|
||||||
|
/// See the ActiveMethod class for more information.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (OwnerType::*Callback)();
|
||||||
|
typedef ActiveResult<void> ActiveResultType;
|
||||||
|
|
||||||
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
|
||||||
|
_pOwner(pOwner),
|
||||||
|
_method(method),
|
||||||
|
_result(result)
|
||||||
|
{
|
||||||
|
poco_check_ptr (pOwner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(_pOwner->*_method)();
|
||||||
|
}
|
||||||
|
catch (Exception& e)
|
||||||
|
{
|
||||||
|
_result.error(e);
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
_result.error(e.what());
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
_result.error("unknown exception");
|
||||||
|
}
|
||||||
|
_result.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
OwnerType* _pOwner;
|
||||||
|
Callback _method;
|
||||||
|
ActiveResultType _result;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// BasicEvent.h
|
// BasicEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/BasicEvent.h#2 $
|
// $Id: //poco/Main/Foundation/include/Poco/BasicEvent.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -61,8 +61,8 @@ class BasicEvent: public AbstractEvent <
|
|||||||
/// For example:
|
/// For example:
|
||||||
/// BasicEvent<int> event;
|
/// BasicEvent<int> event;
|
||||||
/// MyClass myObject;
|
/// MyClass myObject;
|
||||||
/// event += Delegate<MyClass, int>(&myObject, &MyClass::myMethod1);
|
/// event += delegate(&myObject, &MyClass::myMethod1);
|
||||||
/// event += Delegate<MyClass, int>(&myObject, &MyClass::myMethod2);
|
/// event += delegate(&myObject, &MyClass::myMethod2);
|
||||||
///
|
///
|
||||||
/// The second registration will overwrite the first one. The reason is simply that
|
/// 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.
|
/// function pointers can only be compared by equality but not by lower than.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DefaultStrategy.h
|
// DefaultStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/DefaultStrategy.h#2 $
|
// $Id: //poco/Main/Foundation/include/Poco/DefaultStrategy.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -143,6 +143,11 @@ public:
|
|||||||
_observers.clear();
|
_observers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty() const
|
||||||
|
{
|
||||||
|
return _observers.empty();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Delegates _observers;
|
Delegates _observers;
|
||||||
};
|
};
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Delegate.h
|
// Delegate.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/Delegate.h#5 $
|
// $Id: //poco/Main/Foundation/include/Poco/Delegate.h#7 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -42,13 +42,14 @@
|
|||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/AbstractDelegate.h"
|
#include "Poco/AbstractDelegate.h"
|
||||||
|
#include "Poco/FunctionDelegate.h"
|
||||||
#include "Poco/Expire.h"
|
#include "Poco/Expire.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TObj, class TArgs>
|
template <class TObj, class TArgs, bool withSender=true>
|
||||||
class Delegate: public AbstractDelegate<TArgs>
|
class Delegate: public AbstractDelegate<TArgs>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -103,6 +104,132 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
class Delegate<TObj, TArgs, false>: public AbstractDelegate<TArgs>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (TObj::*NotifyMethod)(TArgs&);
|
||||||
|
|
||||||
|
Delegate(TObj* obj, NotifyMethod method):
|
||||||
|
AbstractDelegate<TArgs>(obj),
|
||||||
|
_receiverObject(obj),
|
||||||
|
_receiverMethod(method)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Delegate(const Delegate& delegate):
|
||||||
|
AbstractDelegate<TArgs>(delegate),
|
||||||
|
_receiverObject(delegate._receiverObject),
|
||||||
|
_receiverMethod(delegate._receiverMethod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~Delegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Delegate& operator = (const Delegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverObject = delegate._receiverObject;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void*, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(_receiverObject->*_receiverMethod)(arguments);
|
||||||
|
return true; // a "standard" delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new Delegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TObj* _receiverObject;
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Delegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static Delegate<TObj, TArgs, true> delegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&))
|
||||||
|
{
|
||||||
|
return Delegate<TObj, TArgs, true>(pObj, NotifyMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static Delegate<TObj, TArgs, false> delegate(TObj* pObj, void (TObj::*NotifyMethod)(TArgs&))
|
||||||
|
{
|
||||||
|
return Delegate<TObj, TArgs, false>(pObj, NotifyMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static Expire<TArgs> delegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||||
|
{
|
||||||
|
return Expire<TArgs>(Delegate<TObj, TArgs, true>(pObj, NotifyMethod), expireMillisecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static Expire<TArgs> delegate(TObj* pObj, void (TObj::*NotifyMethod)(TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||||
|
{
|
||||||
|
return Expire<TArgs>(Delegate<TObj, TArgs, false>(pObj, NotifyMethod), expireMillisecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static Expire<TArgs> delegate(void (*NotifyMethod)(const void*, TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||||
|
{
|
||||||
|
return Expire<TArgs>(FunctionDelegate<TArgs, true, true>(NotifyMethod), expireMillisecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static Expire<TArgs> delegate(void (*NotifyMethod)(void*, TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||||
|
{
|
||||||
|
return Expire<TArgs>(FunctionDelegate<TArgs, true, false>(NotifyMethod), expireMillisecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static Expire<TArgs> delegate(void (*NotifyMethod)(TArgs&), Timestamp::TimeDiff expireMillisecs)
|
||||||
|
{
|
||||||
|
return Expire<TArgs>(FunctionDelegate<TArgs, false>( NotifyMethod), expireMillisecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static FunctionDelegate<TArgs, true, true> delegate(void (*NotifyMethod)(const void*, TArgs&))
|
||||||
|
{
|
||||||
|
return FunctionDelegate<TArgs, true, true>(NotifyMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static FunctionDelegate<TArgs, true, false> delegate(void (*NotifyMethod)(void*, TArgs&))
|
||||||
|
{
|
||||||
|
return FunctionDelegate<TArgs, true, false>(NotifyMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static FunctionDelegate<TArgs, false> delegate(void (*NotifyMethod)(TArgs&))
|
||||||
|
{
|
||||||
|
return FunctionDelegate<TArgs, false>(NotifyMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAny.h
|
// DynamicAny.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#8 $
|
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#9 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@@ -162,6 +162,14 @@ public:
|
|||||||
throw BadCastException();
|
throw BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicAny& operator = (const DynamicAny& other)
|
||||||
|
/// Assignment operator
|
||||||
|
{
|
||||||
|
DynamicAny tmp(other);
|
||||||
|
swap(tmp);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
DynamicAny& operator = (const T& other)
|
DynamicAny& operator = (const T& other)
|
||||||
/// Assignment operator
|
/// Assignment operator
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAnyHolder.h
|
// DynamicAnyHolder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAnyHolder.h#7 $
|
// $Id: //poco/Main/Foundation/include/Poco/DynamicAnyHolder.h#9 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
@@ -474,7 +474,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertToSmaller(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -571,7 +573,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertToSmaller(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -668,7 +672,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertToSmaller(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -765,7 +771,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertUnsignedToSigned(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -862,7 +870,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertUnsignedToSigned(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -959,7 +969,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertUnsignedToSigned(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -1056,7 +1068,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertUnsignedToSigned(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -1251,7 +1265,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertToSmaller(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -1355,7 +1371,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertToSmaller(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -1402,37 +1420,37 @@ public:
|
|||||||
|
|
||||||
void convert(Int16& val) const
|
void convert(Int16& val) const
|
||||||
{
|
{
|
||||||
val = static_cast<Int16>(_val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int32& val) const
|
void convert(Int32& val) const
|
||||||
{
|
{
|
||||||
val = static_cast<Int32>(_val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int64& val) const
|
void convert(Int64& val) const
|
||||||
{
|
{
|
||||||
val = static_cast<Int64>(_val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt8& val) const
|
void convert(UInt8& val) const
|
||||||
{
|
{
|
||||||
convertSignedToUnsigned(_val, val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt16& val) const
|
void convert(UInt16& val) const
|
||||||
{
|
{
|
||||||
convertSignedToUnsigned(_val, val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt32& val) const
|
void convert(UInt32& val) const
|
||||||
{
|
{
|
||||||
convertSignedToUnsigned(_val, val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt64& val) const
|
void convert(UInt64& val) const
|
||||||
{
|
{
|
||||||
convertSignedToUnsigned(_val, val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
@@ -1667,7 +1685,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertToSmaller(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
@@ -1764,7 +1784,9 @@ public:
|
|||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
convertUnsignedToSigned(_val, val);
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Expire.h
|
// Expire.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/Expire.h#4 $
|
// $Id: //poco/Main/Foundation/include/Poco/Expire.h#6 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FIFOEvent.h
|
// FIFOEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/FIFOEvent.h#2 $
|
// $Id: //poco/Main/Foundation/include/Poco/FIFOEvent.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -64,8 +64,8 @@ class FIFOEvent: public AbstractEvent <
|
|||||||
/// For example:
|
/// For example:
|
||||||
/// FIFOEvent<int> tmp;
|
/// FIFOEvent<int> tmp;
|
||||||
/// MyClass myObject;
|
/// MyClass myObject;
|
||||||
/// tmp += Delegate<MyClass, int>(&myObject, &MyClass::myMethod1);
|
/// tmp += delegate(&myObject, &MyClass::myMethod1);
|
||||||
/// tmp += Delegate<MyClass, int>(&myObject, &MyClass::myMethod2);
|
/// tmp += delegate(&myObject, &MyClass::myMethod2);
|
||||||
///
|
///
|
||||||
/// The second registration will overwrite the first one.
|
/// The second registration will overwrite the first one.
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FIFOStrategy.h
|
// FIFOStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/FIFOStrategy.h#3 $
|
// $Id: //poco/Main/Foundation/include/Poco/FIFOStrategy.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -148,6 +148,11 @@ public:
|
|||||||
_observerIndex.clear();
|
_observerIndex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty() const
|
||||||
|
{
|
||||||
|
return _observers.empty();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Delegates _observers; /// Stores the delegates in the order they were added.
|
Delegates _observers; /// Stores the delegates in the order they were added.
|
||||||
DelegateIndex _observerIndex; /// For faster lookup when add/remove is used.
|
DelegateIndex _observerIndex; /// For faster lookup when add/remove is used.
|
||||||
|
208
Foundation/include/Poco/FunctionDelegate.h
Normal file
208
Foundation/include/Poco/FunctionDelegate.h
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
//
|
||||||
|
// FunctionDelegate.h
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/Foundation/include/Poco/FunctionDelegate.h#5 $
|
||||||
|
//
|
||||||
|
// Library: Foundation
|
||||||
|
// Package: Events
|
||||||
|
// Module: FunctionDelegate
|
||||||
|
//
|
||||||
|
// Implementation of the FunctionDelegate template.
|
||||||
|
//
|
||||||
|
// 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_FunctionDelegate_INCLUDED
|
||||||
|
#define Foundation_FunctionDelegate_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/Foundation.h"
|
||||||
|
#include "Poco/AbstractDelegate.h"
|
||||||
|
|
||||||
|
|
||||||
|
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 fucntion) to be used as
|
||||||
|
/// a delegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (*NotifyMethod)(const void*, TArgs&);
|
||||||
|
|
||||||
|
FunctionDelegate(NotifyMethod method):
|
||||||
|
AbstractDelegate<TArgs>(*reinterpret_cast<void**>(&method)),
|
||||||
|
_receiverMethod(method)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionDelegate(const FunctionDelegate& delegate):
|
||||||
|
AbstractDelegate<TArgs>(delegate),
|
||||||
|
_receiverMethod(delegate._receiverMethod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~FunctionDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionDelegate& operator = (const FunctionDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(*_receiverMethod)(sender, arguments);
|
||||||
|
return true; // a "standard" delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new FunctionDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
class FunctionDelegate<TArgs, true, false>: public AbstractDelegate<TArgs>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (*NotifyMethod)(void*, TArgs&);
|
||||||
|
|
||||||
|
FunctionDelegate(NotifyMethod method):
|
||||||
|
AbstractDelegate<TArgs>(*reinterpret_cast<void**>(&method)),
|
||||||
|
_receiverMethod(method)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionDelegate(const FunctionDelegate& delegate):
|
||||||
|
AbstractDelegate<TArgs>(delegate),
|
||||||
|
_receiverMethod(delegate._receiverMethod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~FunctionDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionDelegate& operator = (const FunctionDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(*_receiverMethod)(const_cast<void*>(sender), arguments);
|
||||||
|
return true; // a "standard" delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new FunctionDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs, bool senderIsConst>
|
||||||
|
class FunctionDelegate<TArgs, false, senderIsConst>: public AbstractDelegate<TArgs>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (*NotifyMethod)(TArgs&);
|
||||||
|
|
||||||
|
FunctionDelegate(NotifyMethod method):
|
||||||
|
AbstractDelegate<TArgs>(*reinterpret_cast<void**>(&method)),
|
||||||
|
_receiverMethod(method)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionDelegate(const FunctionDelegate& delegate):
|
||||||
|
AbstractDelegate<TArgs>(delegate),
|
||||||
|
_receiverMethod(delegate._receiverMethod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~FunctionDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionDelegate& operator = (const FunctionDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(*_receiverMethod)(arguments);
|
||||||
|
return true; // a "standard" delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new FunctionDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
212
Foundation/include/Poco/FunctionPriorityDelegate.h
Normal file
212
Foundation/include/Poco/FunctionPriorityDelegate.h
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
//
|
||||||
|
// FunctionPriorityDelegate.h
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/Foundation/include/Poco/FunctionPriorityDelegate.h#5 $
|
||||||
|
//
|
||||||
|
// Library: Foundation
|
||||||
|
// Package: Events
|
||||||
|
// Module: FunctionPriorityDelegate
|
||||||
|
//
|
||||||
|
// Implementation of the FunctionPriorityDelegate template.
|
||||||
|
//
|
||||||
|
// 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_FunctionPriorityDelegate_INCLUDED
|
||||||
|
#define Foundation_FunctionPriorityDelegate_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/Foundation.h"
|
||||||
|
#include "Poco/AbstractPriorityDelegate.h"
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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& operator = (const FunctionPriorityDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
this->_priority = delegate._priority;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~FunctionPriorityDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(*_receiverMethod)(sender, arguments);
|
||||||
|
return true; // per default the delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPriorityDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new FunctionPriorityDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionPriorityDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
class FunctionPriorityDelegate<TArgs, true, false>: public AbstractPriorityDelegate<TArgs>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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& operator = (const FunctionPriorityDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
this->_priority = delegate._priority;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~FunctionPriorityDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(*_receiverMethod)(const_cast<void*>(sender), arguments);
|
||||||
|
return true; // per default the delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPriorityDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new FunctionPriorityDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionPriorityDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
class FunctionPriorityDelegate<TArgs, false>: public AbstractPriorityDelegate<TArgs>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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& operator = (const FunctionPriorityDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
this->_priority = delegate._priority;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~FunctionPriorityDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(*_receiverMethod)(arguments);
|
||||||
|
return true; // per default the delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPriorityDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new FunctionPriorityDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FunctionPriorityDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// LinearHashTable.h
|
// LinearHashTable.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/LinearHashTable.h#9 $
|
// $Id: //poco/Main/Foundation/include/Poco/LinearHashTable.h#11 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Hashing
|
// Package: Hashing
|
||||||
@@ -87,6 +87,9 @@ public:
|
|||||||
typedef std::vector<Value> Bucket;
|
typedef std::vector<Value> Bucket;
|
||||||
typedef std::vector<Bucket> BucketVec;
|
typedef std::vector<Bucket> BucketVec;
|
||||||
|
|
||||||
|
template <class VecIt, class BuckIt>
|
||||||
|
class BasicConstIterator;
|
||||||
|
|
||||||
template <class VecIt, class BuckIt>
|
template <class VecIt, class BuckIt>
|
||||||
class BasicIterator
|
class BasicIterator
|
||||||
{
|
{
|
||||||
@@ -111,7 +114,7 @@ public:
|
|||||||
|
|
||||||
BasicIterator& operator = (const BasicIterator& it)
|
BasicIterator& operator = (const BasicIterator& it)
|
||||||
{
|
{
|
||||||
Iterator tmp(it);
|
BasicIterator tmp(it);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -170,7 +173,110 @@ public:
|
|||||||
|
|
||||||
BasicIterator operator ++ (int) // postfix
|
BasicIterator operator ++ (int) // postfix
|
||||||
{
|
{
|
||||||
Iterator tmp(*this);
|
BasicIterator tmp(*this);
|
||||||
|
++*this;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VecIt _vecIt;
|
||||||
|
VecIt _endIt;
|
||||||
|
BuckIt _buckIt;
|
||||||
|
|
||||||
|
friend class LinearHashTable;
|
||||||
|
template <class, class> friend class BasicConstIterator;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef BasicIterator<typename BucketVec::iterator, typename Bucket::iterator> Iterator;
|
||||||
|
|
||||||
|
template <class VecIt, class BuckIt>
|
||||||
|
class BasicConstIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BasicConstIterator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator(const VecIt& vecIt, const VecIt& endIt, const BuckIt& buckIt):
|
||||||
|
_vecIt(vecIt),
|
||||||
|
_endIt(endIt),
|
||||||
|
_buckIt(buckIt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator(const BasicConstIterator& it):
|
||||||
|
_vecIt(it._vecIt),
|
||||||
|
_endIt(it._endIt),
|
||||||
|
_buckIt(it._buckIt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator(const Iterator& it):
|
||||||
|
_vecIt(it._vecIt),
|
||||||
|
_endIt(it._endIt),
|
||||||
|
_buckIt(it._buckIt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator& operator = (const BasicConstIterator& it)
|
||||||
|
{
|
||||||
|
BasicConstIterator tmp(it);
|
||||||
|
swap(tmp);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator& operator = (const Iterator& it)
|
||||||
|
{
|
||||||
|
BasicConstIterator tmp(it);
|
||||||
|
swap(tmp);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(BasicConstIterator& it)
|
||||||
|
{
|
||||||
|
using std::swap;
|
||||||
|
swap(_vecIt, it._vecIt);
|
||||||
|
swap(_endIt, it._endIt);
|
||||||
|
swap(_buckIt, it._buckIt);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const BasicConstIterator& it) const
|
||||||
|
{
|
||||||
|
return _vecIt == it._vecIt && (_vecIt == _endIt || _buckIt == it._buckIt);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator != (const BasicConstIterator& it) const
|
||||||
|
{
|
||||||
|
return _vecIt != it._vecIt || (_vecIt != _endIt && _buckIt != it._buckIt);
|
||||||
|
}
|
||||||
|
|
||||||
|
const typename Bucket::value_type& operator * () const
|
||||||
|
{
|
||||||
|
return *_buckIt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const typename Bucket::value_type* operator -> () const
|
||||||
|
{
|
||||||
|
return &*_buckIt;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator& operator ++ () // prefix
|
||||||
|
{
|
||||||
|
if (_vecIt != _endIt)
|
||||||
|
{
|
||||||
|
++_buckIt;
|
||||||
|
while (_vecIt != _endIt && _buckIt == _vecIt->end())
|
||||||
|
{
|
||||||
|
++_vecIt;
|
||||||
|
if (_vecIt != _endIt) _buckIt = _vecIt->begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicConstIterator operator ++ (int) // postfix
|
||||||
|
{
|
||||||
|
BasicConstIterator tmp(*this);
|
||||||
++*this;
|
++*this;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@@ -182,9 +288,8 @@ public:
|
|||||||
|
|
||||||
friend class LinearHashTable;
|
friend class LinearHashTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef BasicIterator<typename BucketVec::iterator, typename Bucket::iterator> Iterator;
|
typedef BasicConstIterator<typename BucketVec::const_iterator, typename Bucket::const_iterator> ConstIterator;
|
||||||
typedef const BasicIterator<typename BucketVec::const_iterator, typename Bucket::const_iterator> ConstIterator;
|
|
||||||
|
|
||||||
LinearHashTable(std::size_t initialReserve = 64):
|
LinearHashTable(std::size_t initialReserve = 64):
|
||||||
_split(0),
|
_split(0),
|
||||||
@@ -231,8 +336,8 @@ public:
|
|||||||
ConstIterator begin() const
|
ConstIterator begin() const
|
||||||
/// Returns an iterator pointing to the first entry, if one exists.
|
/// Returns an iterator pointing to the first entry, if one exists.
|
||||||
{
|
{
|
||||||
typename BucketVec::iterator it = _buckets.begin();
|
typename BucketVec::const_iterator it = _buckets.begin();
|
||||||
typename BucketVec::iterator end = _buckets.end();
|
typename BucketVec::const_iterator end = _buckets.end();
|
||||||
while (it != end && it->empty())
|
while (it != end && it->empty())
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// NotificationStrategy.h
|
// NotificationStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/NotificationStrategy.h#2 $
|
// $Id: //poco/Main/Foundation/include/Poco/NotificationStrategy.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -70,6 +70,9 @@ public:
|
|||||||
|
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
/// Removes all delegates from the strategy.
|
/// Removes all delegates from the strategy.
|
||||||
|
|
||||||
|
virtual bool empty() const = 0;
|
||||||
|
/// Returns false if the strategy contains at least one delegate.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PriorityDelegate.h
|
// PriorityDelegate.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/PriorityDelegate.h#5 $
|
// $Id: //poco/Main/Foundation/include/Poco/PriorityDelegate.h#7 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -43,12 +43,13 @@
|
|||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/AbstractPriorityDelegate.h"
|
#include "Poco/AbstractPriorityDelegate.h"
|
||||||
#include "Poco/PriorityExpire.h"
|
#include "Poco/PriorityExpire.h"
|
||||||
|
#include "Poco/FunctionPriorityDelegate.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TObj, class TArgs>
|
template <class TObj, class TArgs, bool useSender = true>
|
||||||
class PriorityDelegate: public AbstractPriorityDelegate<TArgs>
|
class PriorityDelegate: public AbstractPriorityDelegate<TArgs>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -104,6 +105,133 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
class PriorityDelegate<TObj, TArgs, false>: public AbstractPriorityDelegate<TArgs>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (TObj::*NotifyMethod)(TArgs&);
|
||||||
|
|
||||||
|
PriorityDelegate(TObj* obj, NotifyMethod method, int prio):
|
||||||
|
AbstractPriorityDelegate<TArgs>(obj, prio),
|
||||||
|
_receiverObject(obj),
|
||||||
|
_receiverMethod(method)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PriorityDelegate(const PriorityDelegate& delegate):
|
||||||
|
AbstractPriorityDelegate<TArgs>(delegate._pTarget, delegate._priority),
|
||||||
|
_receiverObject(delegate._receiverObject),
|
||||||
|
_receiverMethod(delegate._receiverMethod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PriorityDelegate& operator = (const PriorityDelegate& delegate)
|
||||||
|
{
|
||||||
|
if (&delegate != this)
|
||||||
|
{
|
||||||
|
this->_pTarget = delegate._pTarget;
|
||||||
|
this->_receiverObject = delegate._receiverObject;
|
||||||
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
|
this->_priority = delegate._priority;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~PriorityDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
|
{
|
||||||
|
(_receiverObject->*_receiverMethod)(arguments);
|
||||||
|
return true; // per default the delegate never expires
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPriorityDelegate<TArgs>* clone() const
|
||||||
|
{
|
||||||
|
return new PriorityDelegate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TObj* _receiverObject;
|
||||||
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PriorityDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static PriorityDelegate<TObj, TArgs, true> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&), int prio)
|
||||||
|
{
|
||||||
|
return PriorityDelegate<TObj, TArgs, true>(pObj, NotifyMethod, prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static PriorityDelegate<TObj, TArgs, false> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(TArgs&), int prio)
|
||||||
|
{
|
||||||
|
return PriorityDelegate<TObj, TArgs, false>(pObj, NotifyMethod, prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static PriorityExpire<TArgs> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&), int prio, Timestamp::TimeDiff expireMilliSec)
|
||||||
|
{
|
||||||
|
return PriorityExpire<TArgs>(PriorityDelegate<TObj, TArgs, true>(pObj, NotifyMethod, prio), expireMilliSec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TObj, class TArgs>
|
||||||
|
static PriorityExpire<TArgs> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(TArgs&), int prio, Timestamp::TimeDiff expireMilliSec)
|
||||||
|
{
|
||||||
|
return PriorityExpire<TArgs>(PriorityDelegate<TObj, TArgs, false>(pObj, NotifyMethod, prio), expireMilliSec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static PriorityExpire<TArgs> priorityDelegate(void (*NotifyMethod)(const void*, TArgs&), int prio, Timestamp::TimeDiff expireMilliSec)
|
||||||
|
{
|
||||||
|
return PriorityExpire<TArgs>(FunctionPriorityDelegate<TArgs, true, true>(NotifyMethod, prio), expireMilliSec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static PriorityExpire<TArgs> priorityDelegate(void (*NotifyMethod)(void*, TArgs&), int prio, Timestamp::TimeDiff expireMilliSec)
|
||||||
|
{
|
||||||
|
return PriorityExpire<TArgs>(FunctionPriorityDelegate<TArgs, true, false>(NotifyMethod, prio), expireMilliSec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static PriorityExpire<TArgs> priorityDelegate(void (*NotifyMethod)(TArgs&), int prio, Timestamp::TimeDiff expireMilliSec)
|
||||||
|
{
|
||||||
|
return PriorityExpire<TArgs>(FunctionPriorityDelegate<TArgs, false>(NotifyMethod, prio), expireMilliSec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static FunctionPriorityDelegate<TArgs, true, true> priorityDelegate(void (*NotifyMethod)(const void*, TArgs&), int prio)
|
||||||
|
{
|
||||||
|
return FunctionPriorityDelegate<TArgs, true, true>(NotifyMethod, prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static FunctionPriorityDelegate<TArgs, true, false> priorityDelegate(void (*NotifyMethod)(void*, TArgs&), int prio)
|
||||||
|
{
|
||||||
|
return FunctionPriorityDelegate<TArgs, true, false>(NotifyMethod, prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TArgs>
|
||||||
|
static FunctionPriorityDelegate<TArgs, false> priorityDelegate(void (*NotifyMethod)(TArgs&), int prio)
|
||||||
|
{
|
||||||
|
return FunctionPriorityDelegate<TArgs, false>(NotifyMethod, prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PriorityEvent.h
|
// PriorityEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/PriorityEvent.h#2 $
|
// $Id: //poco/Main/Foundation/include/Poco/PriorityEvent.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
@@ -66,8 +66,8 @@ class PriorityEvent: public AbstractEvent <
|
|||||||
/// in their priority value:
|
/// in their priority value:
|
||||||
/// PriorityEvent<int> tmp;
|
/// PriorityEvent<int> tmp;
|
||||||
/// MyClass myObject;
|
/// MyClass myObject;
|
||||||
/// tmp += PriorityDelegate<MyClass, int>(&myObject, &MyClass::myMethod1, 1);
|
/// tmp += priorityDelegate(&myObject, &MyClass::myMethod1, 1);
|
||||||
/// tmp += PriorityDelegate<MyClass, int>(&myObject, &MyClass::myMethod2, 2);
|
/// tmp += priorityDelegate(&myObject, &MyClass::myMethod2, 2);
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PriorityEvent()
|
PriorityEvent()
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PriorityExpire.h
|
// PriorityExpire.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/include/Poco/PriorityExpire.h#4 $
|
// $Id: //poco/Main/Foundation/include/Poco/PriorityExpire.h#6 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// SignalHandler.cpp
|
// SignalHandler.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/src/SignalHandler.cpp#8 $
|
// $Id: //poco/Main/Foundation/src/SignalHandler.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "Poco/Thread.h"
|
#include "Poco/Thread.h"
|
||||||
#include "Poco/NumberFormatter.h"
|
#include "Poco/NumberFormatter.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
#include <cstdlib>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -108,6 +109,9 @@ void SignalHandler::handleSignal(int sig)
|
|||||||
JumpBufferVec& jb = jumpBufferVec();
|
JumpBufferVec& jb = jumpBufferVec();
|
||||||
if (!jb.empty())
|
if (!jb.empty())
|
||||||
siglongjmp(jb.back().buf, sig);
|
siglongjmp(jb.back().buf, sig);
|
||||||
|
|
||||||
|
// Abort if no jump buffer registered
|
||||||
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// pocomsg.mc[.h]
|
// pocomsg.mc[.h]
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/src/pocomsg.h#24 $
|
// $Id: //poco/Main/Foundation/src/pocomsg.mc#7 $
|
||||||
//
|
//
|
||||||
// The Poco message source/header file.
|
// The Poco message source/header file.
|
||||||
//
|
//
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveDispatcherTest.cpp
|
// ActiveDispatcherTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/ActiveDispatcherTest.cpp#4 $
|
// $Id: //poco/Main/Foundation/testsuite/src/ActiveDispatcherTest.cpp#6 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
@@ -68,7 +68,10 @@ namespace
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActiveObject():
|
ActiveObject():
|
||||||
testMethod(this, &ActiveObject::testMethodImpl)
|
testMethod(this, &ActiveObject::testMethodImpl),
|
||||||
|
testVoid(this, &ActiveObject::testVoidImpl),
|
||||||
|
testVoidInOut(this, &ActiveObject::testVoidInOutImpl),
|
||||||
|
testVoidIn(this, &ActiveObject::testVoidInImpl)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +80,12 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActiveMethod<int, int, ActiveObject, ActiveStarter<ActiveDispatcher> > testMethod;
|
ActiveMethod<int, int, ActiveObject, ActiveStarter<ActiveDispatcher> > testMethod;
|
||||||
|
|
||||||
|
ActiveMethod<void, int, ActiveObject, ActiveStarter<ActiveDispatcher> > testVoid;
|
||||||
|
|
||||||
|
ActiveMethod<void, void, ActiveObject, ActiveStarter<ActiveDispatcher> > testVoidInOut;
|
||||||
|
|
||||||
|
ActiveMethod<int, void, ActiveObject, ActiveStarter<ActiveDispatcher> > testVoidIn;
|
||||||
|
|
||||||
void cont()
|
void cont()
|
||||||
{
|
{
|
||||||
@@ -85,11 +94,28 @@ namespace
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int testMethodImpl(const int& n)
|
int testMethodImpl(const int& n)
|
||||||
{
|
{
|
||||||
if (n == 100) throw Exception("n == 100");
|
if (n == 100) throw Exception("n == 100");
|
||||||
_continue.wait();
|
_continue.wait();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testVoidImpl(const int& n)
|
||||||
|
{
|
||||||
|
if (n == 100) throw Exception("n == 100");
|
||||||
|
_continue.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void testVoidInOutImpl()
|
||||||
|
{
|
||||||
|
_continue.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
int testVoidInImpl()
|
||||||
|
{
|
||||||
|
_continue.wait();
|
||||||
|
return 123;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Event _continue;
|
Event _continue;
|
||||||
@@ -167,6 +193,43 @@ void ActiveDispatcherTest::testFailure()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ActiveDispatcherTest::testVoid()
|
||||||
|
{
|
||||||
|
ActiveObject activeObj;
|
||||||
|
ActiveResult<void> result = activeObj.testVoid(123);
|
||||||
|
assert (!result.available());
|
||||||
|
activeObj.cont();
|
||||||
|
result.wait();
|
||||||
|
assert (result.available());
|
||||||
|
assert (!result.failed());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ActiveDispatcherTest::testVoidInOut()
|
||||||
|
{
|
||||||
|
ActiveObject activeObj;
|
||||||
|
ActiveResult<void> result = activeObj.testVoidInOut();
|
||||||
|
assert (!result.available());
|
||||||
|
activeObj.cont();
|
||||||
|
result.wait();
|
||||||
|
assert (result.available());
|
||||||
|
assert (!result.failed());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ActiveDispatcherTest::testVoidIn()
|
||||||
|
{
|
||||||
|
ActiveObject activeObj;
|
||||||
|
ActiveResult<int> result = activeObj.testVoidIn();
|
||||||
|
assert (!result.available());
|
||||||
|
activeObj.cont();
|
||||||
|
result.wait();
|
||||||
|
assert (result.available());
|
||||||
|
assert (!result.failed());
|
||||||
|
assert (result.data() == 123);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ActiveDispatcherTest::setUp()
|
void ActiveDispatcherTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -185,6 +248,9 @@ CppUnit::Test* ActiveDispatcherTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ActiveDispatcherTest, testWaitInterval);
|
CppUnit_addTest(pSuite, ActiveDispatcherTest, testWaitInterval);
|
||||||
CppUnit_addTest(pSuite, ActiveDispatcherTest, testTryWait);
|
CppUnit_addTest(pSuite, ActiveDispatcherTest, testTryWait);
|
||||||
CppUnit_addTest(pSuite, ActiveDispatcherTest, testFailure);
|
CppUnit_addTest(pSuite, ActiveDispatcherTest, testFailure);
|
||||||
|
CppUnit_addTest(pSuite, ActiveDispatcherTest, testVoid);
|
||||||
|
CppUnit_addTest(pSuite, ActiveDispatcherTest, testVoidIn);
|
||||||
|
CppUnit_addTest(pSuite, ActiveDispatcherTest, testVoidInOut);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveDispatcherTest.h
|
// ActiveDispatcherTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/ActiveDispatcherTest.h#2 $
|
// $Id: //poco/Main/Foundation/testsuite/src/ActiveDispatcherTest.h#4 $
|
||||||
//
|
//
|
||||||
// Definition of the ActiveDispatcherTest class.
|
// Definition of the ActiveDispatcherTest class.
|
||||||
//
|
//
|
||||||
@@ -63,6 +63,9 @@ public:
|
|||||||
void testWaitInterval();
|
void testWaitInterval();
|
||||||
void testTryWait();
|
void testTryWait();
|
||||||
void testFailure();
|
void testFailure();
|
||||||
|
void testVoid();
|
||||||
|
void testVoidIn();
|
||||||
|
void testVoidInOut();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveMethodTest.cpp
|
// ActiveMethodTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/ActiveMethodTest.cpp#11 $
|
// $Id: //poco/Main/Foundation/testsuite/src/ActiveMethodTest.cpp#13 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -52,7 +52,10 @@ namespace
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActiveObject():
|
ActiveObject():
|
||||||
testMethod(this, &ActiveObject::testMethodImpl)
|
testMethod(this, &ActiveObject::testMethodImpl),
|
||||||
|
testVoid(this,&ActiveObject::testVoidOutImpl),
|
||||||
|
testVoidInOut(this,&ActiveObject::testVoidInOutImpl),
|
||||||
|
testVoidIn(this,&ActiveObject::testVoidInImpl)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +64,12 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActiveMethod<int, int, ActiveObject> testMethod;
|
ActiveMethod<int, int, ActiveObject> testMethod;
|
||||||
|
|
||||||
|
ActiveMethod<void, int, ActiveObject> testVoid;
|
||||||
|
|
||||||
|
ActiveMethod<void, void, ActiveObject> testVoidInOut;
|
||||||
|
|
||||||
|
ActiveMethod<int, void, ActiveObject> testVoidIn;
|
||||||
|
|
||||||
void cont()
|
void cont()
|
||||||
{
|
{
|
||||||
@@ -69,11 +78,28 @@ namespace
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int testMethodImpl(const int& n)
|
int testMethodImpl(const int& n)
|
||||||
{
|
{
|
||||||
if (n == 100) throw Exception("n == 100");
|
if (n == 100) throw Exception("n == 100");
|
||||||
_continue.wait();
|
_continue.wait();
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testVoidOutImpl(const int& n)
|
||||||
|
{
|
||||||
|
if (n == 100) throw Exception("n == 100");
|
||||||
|
_continue.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void testVoidInOutImpl()
|
||||||
|
{
|
||||||
|
_continue.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
int testVoidInImpl()
|
||||||
|
{
|
||||||
|
_continue.wait();
|
||||||
|
return 123;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Event _continue;
|
Event _continue;
|
||||||
@@ -151,6 +177,40 @@ void ActiveMethodTest::testFailure()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ActiveMethodTest::testVoidOut()
|
||||||
|
{
|
||||||
|
ActiveObject activeObj;
|
||||||
|
ActiveResult<void> result = activeObj.testVoid(101);
|
||||||
|
activeObj.cont();
|
||||||
|
result.wait();
|
||||||
|
assert (result.available());
|
||||||
|
assert (!result.failed());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ActiveMethodTest::testVoidInOut()
|
||||||
|
{
|
||||||
|
ActiveObject activeObj;
|
||||||
|
ActiveResult<void> result = activeObj.testVoidInOut();
|
||||||
|
activeObj.cont();
|
||||||
|
result.wait();
|
||||||
|
assert (result.available());
|
||||||
|
assert (!result.failed());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ActiveMethodTest::testVoidIn()
|
||||||
|
{
|
||||||
|
ActiveObject activeObj;
|
||||||
|
ActiveResult<int> result = activeObj.testVoidIn();
|
||||||
|
activeObj.cont();
|
||||||
|
result.wait();
|
||||||
|
assert (result.available());
|
||||||
|
assert (!result.failed());
|
||||||
|
assert (result.data() == 123);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ActiveMethodTest::setUp()
|
void ActiveMethodTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -169,6 +229,9 @@ CppUnit::Test* ActiveMethodTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ActiveMethodTest, testWaitInterval);
|
CppUnit_addTest(pSuite, ActiveMethodTest, testWaitInterval);
|
||||||
CppUnit_addTest(pSuite, ActiveMethodTest, testTryWait);
|
CppUnit_addTest(pSuite, ActiveMethodTest, testTryWait);
|
||||||
CppUnit_addTest(pSuite, ActiveMethodTest, testFailure);
|
CppUnit_addTest(pSuite, ActiveMethodTest, testFailure);
|
||||||
|
CppUnit_addTest(pSuite, ActiveMethodTest, testVoidOut);
|
||||||
|
CppUnit_addTest(pSuite, ActiveMethodTest, testVoidIn);
|
||||||
|
CppUnit_addTest(pSuite, ActiveMethodTest, testVoidInOut);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ActiveMethodTest.h
|
// ActiveMethodTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/ActiveMethodTest.h#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/ActiveMethodTest.h#10 $
|
||||||
//
|
//
|
||||||
// Definition of the ActiveMethodTest class.
|
// Definition of the ActiveMethodTest class.
|
||||||
//
|
//
|
||||||
@@ -50,6 +50,9 @@ public:
|
|||||||
void testWaitInterval();
|
void testWaitInterval();
|
||||||
void testTryWait();
|
void testTryWait();
|
||||||
void testFailure();
|
void testFailure();
|
||||||
|
void testVoidOut();
|
||||||
|
void testVoidInOut();
|
||||||
|
void testVoidIn();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// BasicEventTest.cpp
|
// BasicEventTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/BasicEventTest.cpp#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/BasicEventTest.cpp#9 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -34,8 +34,9 @@
|
|||||||
#include "DummyDelegate.h"
|
#include "DummyDelegate.h"
|
||||||
#include "CppUnit/TestCaller.h"
|
#include "CppUnit/TestCaller.h"
|
||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
#include "Poco/Delegate.h"
|
|
||||||
#include "Poco/Expire.h"
|
#include "Poco/Expire.h"
|
||||||
|
#include "Poco/Delegate.h"
|
||||||
|
#include "Poco/FunctionDelegate.h"
|
||||||
#include "Poco/Thread.h"
|
#include "Poco/Thread.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
@@ -64,38 +65,52 @@ void BasicEventTest::testNoDelegate()
|
|||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple -= delegate(this, &BasicEventTest::onSimple);
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 0);
|
||||||
|
|
||||||
|
Simple += delegate(this, &BasicEventTest::onSimpleNoSender);
|
||||||
|
Simple -= delegate(this, &BasicEventTest::onSimpleNoSender);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
ConstSimple += delegate(this, &BasicEventTest::onConstSimple);
|
||||||
ConstSimple -= Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
ConstSimple -= delegate(this, &BasicEventTest::onConstSimple);
|
||||||
ConstSimple.notify(this, tmp);
|
ConstSimple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
//Note: passing &args will not work due to &
|
//Note: passing &args will not work due to &
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
Complex += delegate(this, &BasicEventTest::onComplex);
|
||||||
Complex -= Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
Complex -= delegate(this, &BasicEventTest::onComplex);
|
||||||
Complex.notify(this, pArgs);
|
Complex.notify(this, pArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
Complex2 += delegate(this, &BasicEventTest::onComplex2);
|
||||||
Complex2 -= Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
Complex2 -= delegate(this, &BasicEventTest::onComplex2);
|
||||||
Complex2.notify(this, args);
|
Complex2.notify(this, args);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
ConstComplex += delegate(this, &BasicEventTest::onConstComplex);
|
||||||
ConstComplex -= Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
ConstComplex -= delegate(this, &BasicEventTest::onConstComplex);
|
||||||
ConstComplex.notify(this, pCArgs);
|
ConstComplex.notify(this, pCArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
Const2Complex += delegate(this, &BasicEventTest::onConst2Complex);
|
||||||
Const2Complex -= Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
Const2Complex -= delegate(this, &BasicEventTest::onConst2Complex);
|
||||||
Const2Complex.notify(this, pArgs);
|
Const2Complex.notify(this, pArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple);
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple);
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple2);
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple3);
|
||||||
|
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 2);
|
||||||
|
Simple -= delegate(BasicEventTest::onStaticSimple);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testSingleDelegate()
|
void BasicEventTest::testSingleDelegate()
|
||||||
@@ -105,29 +120,29 @@ void BasicEventTest::testSingleDelegate()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
ConstSimple += Delegate<BasicEventTest, const int>(this, &BasicEventTest::onConstSimple);
|
ConstSimple += delegate(this, &BasicEventTest::onConstSimple);
|
||||||
ConstSimple.notify(this, tmp);
|
ConstSimple.notify(this, tmp);
|
||||||
assert (_count == 2);
|
assert (_count == 2);
|
||||||
|
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate<BasicEventTest, Poco::EventArgs*>(this, &BasicEventTest::onComplex);
|
Complex += delegate(this, &BasicEventTest::onComplex);
|
||||||
Complex.notify(this, pArgs);
|
Complex.notify(this, pArgs);
|
||||||
assert (_count == 3);
|
assert (_count == 3);
|
||||||
|
|
||||||
Complex2 += Delegate<BasicEventTest, Poco::EventArgs>(this, &BasicEventTest::onComplex2);
|
Complex2 += delegate(this, &BasicEventTest::onComplex2);
|
||||||
Complex2.notify(this, args);
|
Complex2.notify(this, args);
|
||||||
assert (_count == 4);
|
assert (_count == 4);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += Delegate<BasicEventTest, const Poco::EventArgs*>(this, &BasicEventTest::onConstComplex);
|
ConstComplex += delegate(this, &BasicEventTest::onConstComplex);
|
||||||
ConstComplex.notify(this, pCArgs);
|
ConstComplex.notify(this, pCArgs);
|
||||||
assert (_count == 5);
|
assert (_count == 5);
|
||||||
|
|
||||||
Const2Complex += Delegate<BasicEventTest, const Poco::EventArgs* const>(this, &BasicEventTest::onConst2Complex);
|
Const2Complex += delegate(this, &BasicEventTest::onConst2Complex);
|
||||||
Const2Complex.notify(this, pArgs);
|
Const2Complex.notify(this, pArgs);
|
||||||
assert (_count == 6);
|
assert (_count == 6);
|
||||||
// check if 2nd notify also works
|
// check if 2nd notify also works
|
||||||
@@ -142,11 +157,11 @@ void BasicEventTest::testDuplicateRegister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple -= delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
@@ -158,19 +173,19 @@ void BasicEventTest::testDuplicateUnregister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple); // should work
|
Simple -= delegate(this, &BasicEventTest::onSimple); // should work
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple -= delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple -= delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
@@ -181,7 +196,7 @@ void BasicEventTest::testDisabling()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple += delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.disable();
|
Simple.disable();
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
@@ -191,7 +206,7 @@ void BasicEventTest::testDisabling()
|
|||||||
|
|
||||||
// unregister should also work with disabled event
|
// unregister should also work with disabled event
|
||||||
Simple.disable();
|
Simple.disable();
|
||||||
Simple -= Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple);
|
Simple -= delegate(this, &BasicEventTest::onSimple);
|
||||||
Simple.enable();
|
Simple.enable();
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
@@ -203,12 +218,22 @@ void BasicEventTest::testExpire()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
Simple += delegate(this, &BasicEventTest::onSimple, 500);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep(700);
|
Poco::Thread::sleep(700);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple, 400);
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple, 400);
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple2, 400);
|
||||||
|
Simple += delegate(&BasicEventTest::onStaticSimple3, 400);
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 3);
|
||||||
|
Poco::Thread::sleep(700);
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicEventTest::testExpireReRegister()
|
void BasicEventTest::testExpireReRegister()
|
||||||
@@ -217,14 +242,14 @@ void BasicEventTest::testExpireReRegister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 500);
|
Simple += delegate(this, &BasicEventTest::onSimple, 500);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep(200);
|
Poco::Thread::sleep(200);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 2);
|
assert (_count == 2);
|
||||||
// renew registration
|
// renew registration
|
||||||
Simple += Expire<int>(Delegate<BasicEventTest, int>(this, &BasicEventTest::onSimple), 600);
|
Simple += delegate(this, &BasicEventTest::onSimple, 600);
|
||||||
Poco::Thread::sleep(400);
|
Poco::Thread::sleep(400);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 3);
|
assert (_count == 3);
|
||||||
@@ -236,7 +261,7 @@ void BasicEventTest::testExpireReRegister()
|
|||||||
void BasicEventTest::testReturnParams()
|
void BasicEventTest::testReturnParams()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
@@ -246,15 +271,15 @@ void BasicEventTest::testReturnParams()
|
|||||||
void BasicEventTest::testOverwriteDelegate()
|
void BasicEventTest::testOverwriteDelegate()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2);
|
Simple += delegate(&o1, &DummyDelegate::onSimple2);
|
||||||
// o1 can only have one entry, thus the next line will replace the entry
|
// o1 can only have one entry, thus the next line will replace the entry
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
int tmp = 0; // onsimple requires 0 as input
|
int tmp = 0; // onsimple requires 0 as input
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 1);
|
assert (tmp == 1);
|
||||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
Simple += delegate(&o1, &DummyDelegate::onSimple2, 23000);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
}
|
}
|
||||||
@@ -262,7 +287,7 @@ void BasicEventTest::testOverwriteDelegate()
|
|||||||
void BasicEventTest::testAsyncNotify()
|
void BasicEventTest::testAsyncNotify()
|
||||||
{
|
{
|
||||||
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
|
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
|
||||||
(*pSimple) += Delegate<BasicEventTest, int>(this, &BasicEventTest::onAsync);
|
(*pSimple) += delegate(this, &BasicEventTest::onAsync);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||||
@@ -274,11 +299,38 @@ void BasicEventTest::testAsyncNotify()
|
|||||||
assert (_count == LARGEINC);
|
assert (_count == LARGEINC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BasicEventTest::onSimpleNoSender(int& i)
|
||||||
|
{
|
||||||
|
_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BasicEventTest::onSimple(const void* pSender, int& i)
|
void BasicEventTest::onSimple(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BasicEventTest::onStaticSimple(const void* pSender, int& i)
|
||||||
|
{
|
||||||
|
BasicEventTest* p = const_cast<BasicEventTest*>(reinterpret_cast<const BasicEventTest*>(pSender));
|
||||||
|
p->_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BasicEventTest::onStaticSimple2(void* pSender, int& i)
|
||||||
|
{
|
||||||
|
BasicEventTest* p = reinterpret_cast<BasicEventTest*>(pSender);
|
||||||
|
p->_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BasicEventTest::onStaticSimple3(int& i)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BasicEventTest::onSimpleOther(const void* pSender, int& i)
|
void BasicEventTest::onSimpleOther(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count+=100;
|
_count+=100;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// BasicEventTest.h
|
// BasicEventTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/BasicEventTest.h#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/BasicEventTest.h#9 $
|
||||||
//
|
//
|
||||||
// Tests for BasicEvent
|
// Tests for BasicEvent
|
||||||
//
|
//
|
||||||
@@ -71,6 +71,10 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
static void onStaticSimple(const void* pSender, int& i);
|
||||||
|
static void onStaticSimple2(void* pSender, int& i);
|
||||||
|
static void onStaticSimple3(int& i);
|
||||||
|
void onSimpleNoSender(int& i);
|
||||||
void onSimple(const void* pSender, int& i);
|
void onSimple(const void* pSender, int& i);
|
||||||
void onSimpleOther(const void* pSender, int& i);
|
void onSimpleOther(const void* pSender, int& i);
|
||||||
void onConstSimple(const void* pSender, const int& i);
|
void onConstSimple(const void* pSender, const int& i);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAnyTest.cpp
|
// DynamicAnyTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#7 $
|
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#9 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -1139,12 +1139,6 @@ void DynamicAnyTest::testLimitsInt()
|
|||||||
testLimitsFloatToInt<float, Int8>();
|
testLimitsFloatToInt<float, Int8>();
|
||||||
testLimitsFloatToInt<double, Int8>();
|
testLimitsFloatToInt<double, Int8>();
|
||||||
|
|
||||||
testLimitsSigned<Int16, char>();
|
|
||||||
testLimitsSigned<Int32, char>();
|
|
||||||
testLimitsSigned<Int64, char>();
|
|
||||||
testLimitsFloatToInt<float, char>();
|
|
||||||
testLimitsFloatToInt<double, char>();
|
|
||||||
|
|
||||||
testLimitsSigned<Int32, Int16>();
|
testLimitsSigned<Int32, Int16>();
|
||||||
testLimitsSigned<Int64, Int16>();
|
testLimitsSigned<Int64, Int16>();
|
||||||
testLimitsFloatToInt<float, Int16>();
|
testLimitsFloatToInt<float, Int16>();
|
||||||
@@ -1211,6 +1205,22 @@ void DynamicAnyTest::testLimitsFloat()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DynamicAnyTest::testCtor()
|
||||||
|
{
|
||||||
|
// this is mainly to test a reported compiler error with assignment on HP aCC.
|
||||||
|
// (SF# 1733964)
|
||||||
|
|
||||||
|
DynamicAny a1(42);
|
||||||
|
DynamicAny a2(a1);
|
||||||
|
DynamicAny a3;
|
||||||
|
|
||||||
|
a3 = a1;
|
||||||
|
|
||||||
|
assert (a2 == 42);
|
||||||
|
assert (a3 == 42);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicAnyTest::setUp()
|
void DynamicAnyTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1243,6 +1253,7 @@ CppUnit::Test* DynamicAnyTest::suite()
|
|||||||
CppUnit_addTest(pSuite, DynamicAnyTest, testConversionOperator);
|
CppUnit_addTest(pSuite, DynamicAnyTest, testConversionOperator);
|
||||||
CppUnit_addTest(pSuite, DynamicAnyTest, testLimitsInt);
|
CppUnit_addTest(pSuite, DynamicAnyTest, testLimitsInt);
|
||||||
CppUnit_addTest(pSuite, DynamicAnyTest, testLimitsFloat);
|
CppUnit_addTest(pSuite, DynamicAnyTest, testLimitsFloat);
|
||||||
|
CppUnit_addTest(pSuite, DynamicAnyTest, testCtor);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DynamicAnyTest.h
|
// DynamicAnyTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.h#3 $
|
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.h#4 $
|
||||||
//
|
//
|
||||||
// Tests for Any types
|
// Tests for Any types
|
||||||
//
|
//
|
||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
void testConversionOperator();
|
void testConversionOperator();
|
||||||
void testLimitsInt();
|
void testLimitsInt();
|
||||||
void testLimitsFloat();
|
void testLimitsFloat();
|
||||||
|
void testCtor();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FIFOEventTest.cpp
|
// FIFOEventTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/FIFOEventTest.cpp#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/FIFOEventTest.cpp#9 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -64,36 +64,36 @@ void FIFOEventTest::testNoDelegate()
|
|||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple -= delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
ConstSimple += delegate(this, &FIFOEventTest::onConstSimple);
|
||||||
ConstSimple -= Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
ConstSimple -= delegate(this, &FIFOEventTest::onConstSimple);
|
||||||
ConstSimple.notify(this, tmp);
|
ConstSimple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
//Note: passing &args will not work due to &
|
//Note: passing &args will not work due to &
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
Complex += delegate(this, &FIFOEventTest::onComplex);
|
||||||
Complex -= Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
Complex -= delegate(this, &FIFOEventTest::onComplex);
|
||||||
Complex.notify(this, pArgs);
|
Complex.notify(this, pArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
Complex2 += delegate(this, &FIFOEventTest::onComplex2);
|
||||||
Complex2 -= Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
Complex2 -= delegate(this, &FIFOEventTest::onComplex2);
|
||||||
Complex2.notify(this, args);
|
Complex2.notify(this, args);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
ConstComplex += delegate(this, &FIFOEventTest::onConstComplex);
|
||||||
ConstComplex -= Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
ConstComplex -= delegate(this, &FIFOEventTest::onConstComplex);
|
||||||
ConstComplex.notify(this, pCArgs);
|
ConstComplex.notify(this, pCArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
Const2Complex += delegate(this, &FIFOEventTest::onConst2Complex);
|
||||||
Const2Complex -= Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
Const2Complex -= delegate(this, &FIFOEventTest::onConst2Complex);
|
||||||
Const2Complex.notify(this, pArgs);
|
Const2Complex.notify(this, pArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
}
|
}
|
||||||
@@ -105,29 +105,29 @@ void FIFOEventTest::testSingleDelegate()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
ConstSimple += Delegate<FIFOEventTest, const int>(this, &FIFOEventTest::onConstSimple);
|
ConstSimple += delegate(this, &FIFOEventTest::onConstSimple);
|
||||||
ConstSimple.notify(this, tmp);
|
ConstSimple.notify(this, tmp);
|
||||||
assert (_count == 2);
|
assert (_count == 2);
|
||||||
|
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += Delegate<FIFOEventTest, Poco::EventArgs*>(this, &FIFOEventTest::onComplex);
|
Complex += delegate(this, &FIFOEventTest::onComplex);
|
||||||
Complex.notify(this, pArgs);
|
Complex.notify(this, pArgs);
|
||||||
assert (_count == 3);
|
assert (_count == 3);
|
||||||
|
|
||||||
Complex2 += Delegate<FIFOEventTest, Poco::EventArgs>(this, &FIFOEventTest::onComplex2);
|
Complex2 += delegate(this, &FIFOEventTest::onComplex2);
|
||||||
Complex2.notify(this, args);
|
Complex2.notify(this, args);
|
||||||
assert (_count == 4);
|
assert (_count == 4);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += Delegate<FIFOEventTest, const Poco::EventArgs*>(this, &FIFOEventTest::onConstComplex);
|
ConstComplex += delegate(this, &FIFOEventTest::onConstComplex);
|
||||||
ConstComplex.notify(this, pCArgs);
|
ConstComplex.notify(this, pCArgs);
|
||||||
assert (_count == 5);
|
assert (_count == 5);
|
||||||
|
|
||||||
Const2Complex += Delegate<FIFOEventTest, const Poco::EventArgs* const>(this, &FIFOEventTest::onConst2Complex);
|
Const2Complex += delegate(this, &FIFOEventTest::onConst2Complex);
|
||||||
Const2Complex.notify(this, pArgs);
|
Const2Complex.notify(this, pArgs);
|
||||||
assert (_count == 6);
|
assert (_count == 6);
|
||||||
// check if 2nd notify also works
|
// check if 2nd notify also works
|
||||||
@@ -142,11 +142,11 @@ void FIFOEventTest::testDuplicateRegister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple -= delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
@@ -158,19 +158,19 @@ void FIFOEventTest::testDuplicateUnregister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple); // should work
|
Simple -= delegate(this, &FIFOEventTest::onSimple); // should work
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple -= delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple -= delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ void FIFOEventTest::testDisabling()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple += delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.disable();
|
Simple.disable();
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
@@ -192,7 +192,7 @@ void FIFOEventTest::testDisabling()
|
|||||||
|
|
||||||
// unregister should also work with disabled event
|
// unregister should also work with disabled event
|
||||||
Simple.disable();
|
Simple.disable();
|
||||||
Simple -= Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple);
|
Simple -= delegate(this, &FIFOEventTest::onSimple);
|
||||||
Simple.enable();
|
Simple.enable();
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
@@ -205,18 +205,18 @@ void FIFOEventTest::testFIFOOrder()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
Simple += Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
Simple += delegate(&o2, &DummyDelegate::onSimple2);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple -= delegate(&o1, &DummyDelegate::onSimple);
|
||||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
Simple += delegate(&o2, &DummyDelegate::onSimple2);
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -237,34 +237,34 @@ void FIFOEventTest::testFIFOOrderExpire()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 5000);
|
Simple += delegate(&o1, &DummyDelegate::onSimple, 5000);
|
||||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
// both ways of unregistering should work
|
// both ways of unregistering should work
|
||||||
Simple -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
Simple -= delegate(&o1, &DummyDelegate::onSimple, 6000);
|
||||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now start mixing of expire and non expire
|
// now start mixing of expire and non expire
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2);
|
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
|
||||||
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
|
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
|
||||||
Simple -= Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple), 6000);
|
Simple -= delegate(&o1, &DummyDelegate::onSimple, 6000);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2), 5000);
|
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -285,7 +285,7 @@ void FIFOEventTest::testExpire()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
Simple += delegate(this, &FIFOEventTest::onSimple, 500);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep(700);
|
Poco::Thread::sleep(700);
|
||||||
@@ -300,14 +300,14 @@ void FIFOEventTest::testExpireReRegister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 500);
|
Simple += delegate(this, &FIFOEventTest::onSimple, 500);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep(200);
|
Poco::Thread::sleep(200);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 2);
|
assert (_count == 2);
|
||||||
// renew registration
|
// renew registration
|
||||||
Simple += Expire<int>(Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onSimple), 600);
|
Simple += delegate(this, &FIFOEventTest::onSimple, 600);
|
||||||
Poco::Thread::sleep(400);
|
Poco::Thread::sleep(400);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 3);
|
assert (_count == 3);
|
||||||
@@ -320,7 +320,7 @@ void FIFOEventTest::testExpireReRegister()
|
|||||||
void FIFOEventTest::testReturnParams()
|
void FIFOEventTest::testReturnParams()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
@@ -330,15 +330,15 @@ void FIFOEventTest::testReturnParams()
|
|||||||
void FIFOEventTest::testOverwriteDelegate()
|
void FIFOEventTest::testOverwriteDelegate()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2);
|
Simple += delegate(&o1, &DummyDelegate::onSimple2);
|
||||||
// o1 can only have one entry, thus the next line will replace the entry
|
// o1 can only have one entry, thus the next line will replace the entry
|
||||||
Simple += Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple);
|
Simple += delegate(&o1, &DummyDelegate::onSimple);
|
||||||
|
|
||||||
int tmp = 0; // onsimple requires 0 as input
|
int tmp = 0; // onsimple requires 0 as input
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 1);
|
assert (tmp == 1);
|
||||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||||
Simple += Expire<int>(Delegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2), 23000);
|
Simple += delegate(&o1, &DummyDelegate::onSimple2, 23000);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ void FIFOEventTest::testOverwriteDelegate()
|
|||||||
void FIFOEventTest::testAsyncNotify()
|
void FIFOEventTest::testAsyncNotify()
|
||||||
{
|
{
|
||||||
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
|
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
|
||||||
(*pSimple) += Delegate<FIFOEventTest, int>(this, &FIFOEventTest::onAsync);
|
(*pSimple) += delegate(this, &FIFOEventTest::onAsync);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FIFOEventTest.h
|
// FIFOEventTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/FIFOEventTest.h#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/FIFOEventTest.h#9 $
|
||||||
//
|
//
|
||||||
// Definition of the FIFOEventTest class.
|
// Definition of the FIFOEventTest class.
|
||||||
//
|
//
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HashMapTest.cpp
|
// HashMapTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/HashMapTest.cpp#1 $
|
// $Id: //poco/Main/Foundation/testsuite/src/HashMapTest.cpp#2 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -167,6 +167,31 @@ void HashMapTest::testIterator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HashMapTest::testConstIterator()
|
||||||
|
{
|
||||||
|
const int N = 1000;
|
||||||
|
|
||||||
|
typedef HashMap<int, int> IntMap;
|
||||||
|
IntMap hm;
|
||||||
|
|
||||||
|
for (int i = 0; i < N; ++i)
|
||||||
|
{
|
||||||
|
hm.insert(IntMap::ValueType(i, i*2));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<int, int> values;
|
||||||
|
IntMap::ConstIterator it = hm.begin();
|
||||||
|
while (it != hm.end())
|
||||||
|
{
|
||||||
|
assert (values.find(it->first) == values.end());
|
||||||
|
values[it->first] = it->second;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (values.size() == N);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HashMapTest::testIndex()
|
void HashMapTest::testIndex()
|
||||||
{
|
{
|
||||||
typedef HashMap<int, int> IntMap;
|
typedef HashMap<int, int> IntMap;
|
||||||
@@ -210,6 +235,7 @@ CppUnit::Test* HashMapTest::suite()
|
|||||||
CppUnit_addTest(pSuite, HashMapTest, testInsert);
|
CppUnit_addTest(pSuite, HashMapTest, testInsert);
|
||||||
CppUnit_addTest(pSuite, HashMapTest, testErase);
|
CppUnit_addTest(pSuite, HashMapTest, testErase);
|
||||||
CppUnit_addTest(pSuite, HashMapTest, testIterator);
|
CppUnit_addTest(pSuite, HashMapTest, testIterator);
|
||||||
|
CppUnit_addTest(pSuite, HashMapTest, testConstIterator);
|
||||||
CppUnit_addTest(pSuite, HashMapTest, testIndex);
|
CppUnit_addTest(pSuite, HashMapTest, testIndex);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HashMapTest.h
|
// HashMapTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/HashMapTest.h#1 $
|
// $Id: //poco/Main/Foundation/testsuite/src/HashMapTest.h#2 $
|
||||||
//
|
//
|
||||||
// Definition of the HashMapTest class.
|
// Definition of the HashMapTest class.
|
||||||
//
|
//
|
||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
void testInsert();
|
void testInsert();
|
||||||
void testErase();
|
void testErase();
|
||||||
void testIterator();
|
void testIterator();
|
||||||
|
void testConstIterator();
|
||||||
void testIndex();
|
void testIndex();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HashSetTest.cpp
|
// HashSetTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/HashSetTest.cpp#1 $
|
// $Id: //poco/Main/Foundation/testsuite/src/HashSetTest.cpp#2 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -158,6 +158,30 @@ void HashSetTest::testIterator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HashSetTest::testConstIterator()
|
||||||
|
{
|
||||||
|
const int N = 1000;
|
||||||
|
|
||||||
|
HashSet<int> hs;
|
||||||
|
|
||||||
|
for (int i = 0; i < N; ++i)
|
||||||
|
{
|
||||||
|
hs.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<int> values;
|
||||||
|
HashSet<int>::ConstIterator it = hs.begin();
|
||||||
|
while (it != hs.end())
|
||||||
|
{
|
||||||
|
assert (values.find(*it) == values.end());
|
||||||
|
values.insert(*it);
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (values.size() == N);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HashSetTest::setUp()
|
void HashSetTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -175,6 +199,7 @@ CppUnit::Test* HashSetTest::suite()
|
|||||||
CppUnit_addTest(pSuite, HashSetTest, testInsert);
|
CppUnit_addTest(pSuite, HashSetTest, testInsert);
|
||||||
CppUnit_addTest(pSuite, HashSetTest, testErase);
|
CppUnit_addTest(pSuite, HashSetTest, testErase);
|
||||||
CppUnit_addTest(pSuite, HashSetTest, testIterator);
|
CppUnit_addTest(pSuite, HashSetTest, testIterator);
|
||||||
|
CppUnit_addTest(pSuite, HashSetTest, testConstIterator);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HashSetTest.h
|
// HashSetTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/HashSetTest.h#1 $
|
// $Id: //poco/Main/Foundation/testsuite/src/HashSetTest.h#2 $
|
||||||
//
|
//
|
||||||
// Definition of the HashSetTest class.
|
// Definition of the HashSetTest class.
|
||||||
//
|
//
|
||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
void testInsert();
|
void testInsert();
|
||||||
void testErase();
|
void testErase();
|
||||||
void testIterator();
|
void testIterator();
|
||||||
|
void testConstIterator();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// LinearHashTableTest.cpp
|
// LinearHashTableTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/LinearHashTableTest.cpp#1 $
|
// $Id: //poco/Main/Foundation/testsuite/src/LinearHashTableTest.cpp#2 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -165,6 +165,43 @@ void LinearHashTableTest::testIterator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LinearHashTableTest::testConstIterator()
|
||||||
|
{
|
||||||
|
const int N = 1000;
|
||||||
|
|
||||||
|
LinearHashTable<int> ht;
|
||||||
|
|
||||||
|
for (int i = 0; i < N; ++i)
|
||||||
|
{
|
||||||
|
ht.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<int> values;
|
||||||
|
LinearHashTable<int>::ConstIterator it = ht.begin();
|
||||||
|
while (it != ht.end())
|
||||||
|
{
|
||||||
|
assert (values.find(*it) == values.end());
|
||||||
|
values.insert(*it);
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (values.size() == N);
|
||||||
|
|
||||||
|
values.clear();
|
||||||
|
const LinearHashTable<int> cht(ht);
|
||||||
|
|
||||||
|
LinearHashTable<int>::ConstIterator cit = cht.begin();
|
||||||
|
while (cit != cht.end())
|
||||||
|
{
|
||||||
|
assert (values.find(*cit) == values.end());
|
||||||
|
values.insert(*cit);
|
||||||
|
++cit;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (values.size() == N);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LinearHashTableTest::testPerformanceInt()
|
void LinearHashTableTest::testPerformanceInt()
|
||||||
{
|
{
|
||||||
const int N = 5000000;
|
const int N = 5000000;
|
||||||
@@ -329,6 +366,7 @@ CppUnit::Test* LinearHashTableTest::suite()
|
|||||||
CppUnit_addTest(pSuite, LinearHashTableTest, testInsert);
|
CppUnit_addTest(pSuite, LinearHashTableTest, testInsert);
|
||||||
CppUnit_addTest(pSuite, LinearHashTableTest, testErase);
|
CppUnit_addTest(pSuite, LinearHashTableTest, testErase);
|
||||||
CppUnit_addTest(pSuite, LinearHashTableTest, testIterator);
|
CppUnit_addTest(pSuite, LinearHashTableTest, testIterator);
|
||||||
|
CppUnit_addTest(pSuite, LinearHashTableTest, testConstIterator);
|
||||||
//CppUnit_addTest(pSuite, LinearHashTableTest, testPerformanceInt);
|
//CppUnit_addTest(pSuite, LinearHashTableTest, testPerformanceInt);
|
||||||
//CppUnit_addTest(pSuite, LinearHashTableTest, testPerformanceStr);
|
//CppUnit_addTest(pSuite, LinearHashTableTest, testPerformanceStr);
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// LinearHashTableTest.h
|
// LinearHashTableTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/LinearHashTableTest.h#1 $
|
// $Id: //poco/Main/Foundation/testsuite/src/LinearHashTableTest.h#2 $
|
||||||
//
|
//
|
||||||
// Definition of the LinearHashTableTest class.
|
// Definition of the LinearHashTableTest class.
|
||||||
//
|
//
|
||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
void testInsert();
|
void testInsert();
|
||||||
void testErase();
|
void testErase();
|
||||||
void testIterator();
|
void testIterator();
|
||||||
|
void testConstIterator();
|
||||||
void testPerformanceInt();
|
void testPerformanceInt();
|
||||||
void testPerformanceStr();
|
void testPerformanceStr();
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PriorityEventTest.cpp
|
// PriorityEventTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/PriorityEventTest.cpp#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/PriorityEventTest.cpp#9 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -64,38 +64,53 @@ void PriorityEventTest::testNoDelegate()
|
|||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 0);
|
||||||
|
|
||||||
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimpleNoSender, 0);
|
||||||
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimpleNoSender, 0);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
ConstSimple += priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
|
||||||
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
ConstSimple -= priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
|
||||||
ConstSimple.notify(this, tmp);
|
ConstSimple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
//Note: passing &args will not work due to &
|
//Note: passing &args will not work due to &
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
Complex += priorityDelegate(this, &PriorityEventTest::onComplex, 0);
|
||||||
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
Complex -= priorityDelegate(this, &PriorityEventTest::onComplex, 0);
|
||||||
Complex.notify(this, pArgs);
|
Complex.notify(this, pArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
Complex2 += priorityDelegate(this, &PriorityEventTest::onComplex2, 0);
|
||||||
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
Complex2 -= priorityDelegate(this, &PriorityEventTest::onComplex2, 0);
|
||||||
Complex2.notify(this, args);
|
Complex2.notify(this, args);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
ConstComplex += priorityDelegate(this, &PriorityEventTest::onConstComplex, 0);
|
||||||
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
ConstComplex -= priorityDelegate(this, &PriorityEventTest::onConstComplex, 0);
|
||||||
ConstComplex.notify(this, pCArgs);
|
ConstComplex.notify(this, pCArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
Const2Complex += priorityDelegate(this, &PriorityEventTest::onConst2Complex, 0);
|
||||||
Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
Const2Complex -= priorityDelegate(this, &PriorityEventTest::onConst2Complex, 0);
|
||||||
Const2Complex.notify(this, pArgs);
|
Const2Complex.notify(this, pArgs);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 0);
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 0);
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 1);
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple2, 2);
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple3, 3);
|
||||||
|
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 3);
|
||||||
|
Simple -= priorityDelegate(PriorityEventTest::onStaticSimple, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testSingleDelegate()
|
void PriorityEventTest::testSingleDelegate()
|
||||||
@@ -105,36 +120,36 @@ void PriorityEventTest::testSingleDelegate()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
// unregistering with a different priority --> different observer, is ignored
|
// unregistering with a different priority --> different observer, is ignored
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 3);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 3);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
|
ConstSimple += priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
|
||||||
ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 3);
|
ConstSimple -= priorityDelegate(this, &PriorityEventTest::onConstSimple, 3);
|
||||||
ConstSimple.notify(this, tmp);
|
ConstSimple.notify(this, tmp);
|
||||||
assert (_count == 2);
|
assert (_count == 2);
|
||||||
|
|
||||||
EventArgs* pArgs = &args;
|
EventArgs* pArgs = &args;
|
||||||
Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
|
Complex += priorityDelegate(this, &PriorityEventTest::onComplex, 0);
|
||||||
Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 3);
|
Complex -= priorityDelegate(this, &PriorityEventTest::onComplex, 3);
|
||||||
Complex.notify(this, pArgs);
|
Complex.notify(this, pArgs);
|
||||||
assert (_count == 3);
|
assert (_count == 3);
|
||||||
|
|
||||||
Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
|
Complex2 += priorityDelegate(this, &PriorityEventTest::onComplex2, 0);
|
||||||
Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 3);
|
Complex2 -= priorityDelegate(this, &PriorityEventTest::onComplex2, 3);
|
||||||
Complex2.notify(this, args);
|
Complex2.notify(this, args);
|
||||||
assert (_count == 4);
|
assert (_count == 4);
|
||||||
|
|
||||||
const EventArgs* pCArgs = &args;
|
const EventArgs* pCArgs = &args;
|
||||||
ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
|
ConstComplex += priorityDelegate(this, &PriorityEventTest::onConstComplex, 0);
|
||||||
ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 3);
|
ConstComplex -= priorityDelegate(this, &PriorityEventTest::onConstComplex, 3);
|
||||||
ConstComplex.notify(this, pCArgs);
|
ConstComplex.notify(this, pCArgs);
|
||||||
assert (_count == 5);
|
assert (_count == 5);
|
||||||
|
|
||||||
Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
|
Const2Complex += priorityDelegate(this, &PriorityEventTest::onConst2Complex, 0);
|
||||||
Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 3);
|
Const2Complex -= priorityDelegate(this, &PriorityEventTest::onConst2Complex, 3);
|
||||||
Const2Complex.notify(this, pArgs);
|
Const2Complex.notify(this, pArgs);
|
||||||
assert (_count == 6);
|
assert (_count == 6);
|
||||||
// check if 2nd notify also works
|
// check if 2nd notify also works
|
||||||
@@ -149,19 +164,19 @@ void PriorityEventTest::testDuplicateRegister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimpleOther, 1);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 2 + LARGEINC);
|
assert (_count == 2 + LARGEINC);
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimpleOther, 1);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 3 + LARGEINC);
|
assert (_count == 3 + LARGEINC);
|
||||||
}
|
}
|
||||||
@@ -173,19 +188,19 @@ void PriorityEventTest::testDuplicateUnregister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0); // should work
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0); // should work
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
|
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
}
|
}
|
||||||
@@ -197,7 +212,7 @@ void PriorityEventTest::testDisabling()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.disable();
|
Simple.disable();
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
@@ -207,7 +222,7 @@ void PriorityEventTest::testDisabling()
|
|||||||
|
|
||||||
// unregister should also work with disabled event
|
// unregister should also work with disabled event
|
||||||
Simple.disable();
|
Simple.disable();
|
||||||
Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
|
||||||
Simple.enable();
|
Simple.enable();
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
@@ -256,35 +271,35 @@ void PriorityEventTest::testPriorityOrderExpire()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
|
Simple += priorityDelegate(&o2, &DummyDelegate::onSimple2, 1, 500000);
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 500000);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0, 500000);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
// both ways of unregistering should work
|
// both ways of unregistering should work
|
||||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple, 0, 600000);
|
||||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 1);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now start mixing of expire and non expire
|
// now start mixing of expire and non expire
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
|
Simple += priorityDelegate(&o2, &DummyDelegate::onSimple2, 1, 500000);
|
||||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0);
|
||||||
|
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
|
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 1);
|
||||||
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
|
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
|
||||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
|
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple, 0, 600000);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
|
|
||||||
// now try with the wrong order
|
// now try with the wrong order
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
Simple += priorityDelegate(&o2, &DummyDelegate::onSimple2, 0, 500000);
|
||||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -296,8 +311,8 @@ void PriorityEventTest::testPriorityOrderExpire()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
|
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 0, 500000);
|
||||||
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
|
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,13 +322,22 @@ void PriorityEventTest::testExpire()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep(700);
|
Poco::Thread::sleep(700);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Simple -= PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
|
||||||
|
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 1, 500);
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple2, 1, 500);
|
||||||
|
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple3, 1, 500);
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 3);
|
||||||
|
Poco::Thread::sleep(700);
|
||||||
|
Simple.notify(this, tmp);
|
||||||
|
assert (_count == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -323,14 +347,14 @@ void PriorityEventTest::testExpireReRegister()
|
|||||||
|
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
|
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 1);
|
assert (_count == 1);
|
||||||
Poco::Thread::sleep(200);
|
Poco::Thread::sleep(200);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 2);
|
assert (_count == 2);
|
||||||
// renew registration
|
// renew registration
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 600);
|
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 600);
|
||||||
Poco::Thread::sleep(400);
|
Poco::Thread::sleep(400);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (_count == 3);
|
assert (_count == 3);
|
||||||
@@ -343,7 +367,7 @@ void PriorityEventTest::testExpireReRegister()
|
|||||||
void PriorityEventTest::testReturnParams()
|
void PriorityEventTest::testReturnParams()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0);
|
||||||
|
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
@@ -353,24 +377,24 @@ void PriorityEventTest::testReturnParams()
|
|||||||
void PriorityEventTest::testOverwriteDelegate()
|
void PriorityEventTest::testOverwriteDelegate()
|
||||||
{
|
{
|
||||||
DummyDelegate o1;
|
DummyDelegate o1;
|
||||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple2, 0);
|
||||||
// o1 can only have one entry per priority, thus the next line will replace the entry
|
// o1 can only have one entry per priority, thus the next line will replace the entry
|
||||||
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0);
|
||||||
|
|
||||||
int tmp = 0; // onsimple requires 0 as input
|
int tmp = 0; // onsimple requires 0 as input
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 1);
|
assert (tmp == 1);
|
||||||
// now overwrite with onsimple2 with requires as input tmp = 1
|
// now overwrite with onsimple2 with requires as input tmp = 1
|
||||||
Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
|
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple2, 0, 23000);
|
||||||
Simple.notify(this, tmp);
|
Simple.notify(this, tmp);
|
||||||
assert (tmp == 2);
|
assert (tmp == 2);
|
||||||
Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
|
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple2, 0, 23000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PriorityEventTest::testAsyncNotify()
|
void PriorityEventTest::testAsyncNotify()
|
||||||
{
|
{
|
||||||
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
|
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
|
||||||
(*pSimple) += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onAsync, 0);
|
(*pSimple) += priorityDelegate(this, &PriorityEventTest::onAsync, 0);
|
||||||
assert (_count == 0);
|
assert (_count == 0);
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
|
||||||
@@ -383,6 +407,32 @@ void PriorityEventTest::testAsyncNotify()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PriorityEventTest::onStaticSimple(const void* pSender, int& i)
|
||||||
|
{
|
||||||
|
PriorityEventTest* p = const_cast<PriorityEventTest*>(reinterpret_cast<const PriorityEventTest*>(pSender));
|
||||||
|
p->_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PriorityEventTest::onStaticSimple2(void* pSender, int& i)
|
||||||
|
{
|
||||||
|
PriorityEventTest* p = reinterpret_cast<PriorityEventTest*>(pSender);
|
||||||
|
p->_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PriorityEventTest::onStaticSimple3(int& i)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PriorityEventTest::onSimpleNoSender(int& i)
|
||||||
|
{
|
||||||
|
_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PriorityEventTest::onSimple(const void* pSender, int& i)
|
void PriorityEventTest::onSimple(const void* pSender, int& i)
|
||||||
{
|
{
|
||||||
_count++;
|
_count++;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// PriorityEventTest.h
|
// PriorityEventTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/PriorityEventTest.h#8 $
|
// $Id: //poco/Main/Foundation/testsuite/src/PriorityEventTest.h#9 $
|
||||||
//
|
//
|
||||||
// Definition of the PriorityEventTest class.
|
// Definition of the PriorityEventTest class.
|
||||||
//
|
//
|
||||||
@@ -72,7 +72,11 @@ public:
|
|||||||
static CppUnit::Test* suite();
|
static CppUnit::Test* suite();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static void onStaticSimple(const void* pSender, int& i);
|
||||||
|
static void onStaticSimple2(void* pSender, int& i);
|
||||||
|
static void onStaticSimple3(int& i);
|
||||||
|
|
||||||
|
void onSimpleNoSender(int& i);
|
||||||
void onSimple(const void* pSender, int& i);
|
void onSimple(const void* pSender, int& i);
|
||||||
void onSimpleOther(const void* pSender, int& i);
|
void onSimpleOther(const void* pSender, int& i);
|
||||||
void onConstSimple(const void* pSender, const int& i);
|
void onConstSimple(const void* pSender, const int& i);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// TimerTest.cpp
|
// TimerTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/TimerTest.cpp#10 $
|
// $Id: //poco/Main/Foundation/testsuite/src/TimerTest.cpp#11 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
@@ -78,6 +78,19 @@ void TimerTest::testTimer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TimerTest::testDuplicateStop()
|
||||||
|
{
|
||||||
|
Timer t(100, 200);
|
||||||
|
t.stop();
|
||||||
|
t.stop();
|
||||||
|
|
||||||
|
TimerCallback<TimerTest> tc(*this, &TimerTest::onTimer);
|
||||||
|
t.start(tc);
|
||||||
|
_event.wait();
|
||||||
|
t.stop();
|
||||||
|
t.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void TimerTest::setUp()
|
void TimerTest::setUp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -99,6 +112,7 @@ CppUnit::Test* TimerTest::suite()
|
|||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TimerTest");
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TimerTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, TimerTest, testTimer);
|
CppUnit_addTest(pSuite, TimerTest, testTimer);
|
||||||
|
CppUnit_addTest(pSuite, TimerTest, testDuplicateStop);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// TimerTest.h
|
// TimerTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Foundation/testsuite/src/TimerTest.h#9 $
|
// $Id: //poco/Main/Foundation/testsuite/src/TimerTest.h#10 $
|
||||||
//
|
//
|
||||||
// Definition of the TimerTest class.
|
// Definition of the TimerTest class.
|
||||||
//
|
//
|
||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
~TimerTest();
|
~TimerTest();
|
||||||
|
|
||||||
void testTimer();
|
void testTimer();
|
||||||
|
void testDuplicateStop();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
Reference in New Issue
Block a user