mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 03:03:23 +02:00
integrated changes for 1.2.3
This commit is contained in:
@@ -1463,7 +1463,7 @@
|
||||
RelativePath=".\src\NotificationQueue.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Observer.cpp">
|
||||
RelativePath=".\src\AbstractObserver.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
@@ -1478,9 +1478,15 @@
|
||||
<File
|
||||
RelativePath=".\include\Poco\NotificationQueue.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\AbstractObserver.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Observer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\NObserver.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@@ -1932,7 +1932,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Observer.cpp"
|
||||
RelativePath=".\src\AbstractObserver.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@@ -1951,10 +1951,18 @@
|
||||
RelativePath=".\include\Poco\NotificationQueue.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\AbstractObserver.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Observer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\NObserver.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/1.2/Foundation/Makefile#1 $
|
||||
# $Id: //poco/1.2/Foundation/Makefile#2 $
|
||||
#
|
||||
# Makefile for Poco Foundation
|
||||
#
|
||||
@@ -18,7 +18,7 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
|
||||
LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \
|
||||
MemoryPool MD2Engine MD4Engine MD5Engine Manifest Message Mutex \
|
||||
NestedDiagnosticContext Notification NotificationCenter \
|
||||
NotificationQueue NullStream NumberFormatter NumberParser Observer \
|
||||
NotificationQueue NullStream NumberFormatter NumberParser AbstractObserver \
|
||||
Path PatternFormatter Process PurgeStrategy RWLock Random RandomStream \
|
||||
RegularExpression RefCountedObject Runnable RotateStrategy \
|
||||
SHA1Engine Semaphore SharedLibrary SimpleFileChannel \
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// NotificationCenterTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/NotificationCenterTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/NotificationCenterTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -35,11 +35,13 @@
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/NotificationCenter.h"
|
||||
#include "Poco/Observer.h"
|
||||
#include "Poco/NObserver.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::NotificationCenter;
|
||||
using Poco::Observer;
|
||||
using Poco::NObserver;
|
||||
using Poco::Notification;
|
||||
using Poco::AutoPtr;
|
||||
|
||||
@@ -131,6 +133,17 @@ void NotificationCenterTest::test5()
|
||||
}
|
||||
|
||||
|
||||
void NotificationCenterTest::testAuto()
|
||||
{
|
||||
NotificationCenter nc;
|
||||
nc.addObserver(NObserver<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handleAuto));
|
||||
nc.postNotification(new Notification);
|
||||
assert (_set.size() == 1);
|
||||
assert (_set.find("handleAuto") != _set.end());
|
||||
nc.removeObserver(NObserver<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handleAuto));
|
||||
}
|
||||
|
||||
|
||||
void NotificationCenterTest::testDefaultCenter()
|
||||
{
|
||||
NotificationCenter& nc = NotificationCenter::defaultCenter();
|
||||
@@ -174,6 +187,12 @@ void NotificationCenterTest::handleTest(TestNotification* pNf)
|
||||
}
|
||||
|
||||
|
||||
void NotificationCenterTest::handleAuto(const AutoPtr<Notification>& pNf)
|
||||
{
|
||||
_set.insert("handleAuto");
|
||||
}
|
||||
|
||||
|
||||
void NotificationCenterTest::setUp()
|
||||
{
|
||||
_set.clear();
|
||||
@@ -194,6 +213,7 @@ CppUnit::Test* NotificationCenterTest::suite()
|
||||
CppUnit_addTest(pSuite, NotificationCenterTest, test3);
|
||||
CppUnit_addTest(pSuite, NotificationCenterTest, test4);
|
||||
CppUnit_addTest(pSuite, NotificationCenterTest, test5);
|
||||
CppUnit_addTest(pSuite, NotificationCenterTest, testAuto);
|
||||
CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultCenter);
|
||||
|
||||
return pSuite;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// NotificationCenterTest.h
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/NotificationCenterTest.h#1 $
|
||||
// $Id: //poco/1.2/Foundation/testsuite/src/NotificationCenterTest.h#2 $
|
||||
//
|
||||
// Definition of the NotificationCenterTest class.
|
||||
//
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "Poco/Notification.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <set>
|
||||
|
||||
|
||||
@@ -56,6 +57,7 @@ public:
|
||||
void test3();
|
||||
void test4();
|
||||
void test5();
|
||||
void testAuto();
|
||||
void testDefaultCenter();
|
||||
|
||||
void setUp();
|
||||
@@ -68,6 +70,7 @@ protected:
|
||||
void handle2(Poco::Notification* pNf);
|
||||
void handle3(Poco::Notification* pNf);
|
||||
void handleTest(TestNotification* pNf);
|
||||
void handleAuto(const Poco::AutoPtr<Poco::Notification>& pNf);
|
||||
|
||||
private:
|
||||
std::set<std::string> _set;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// EchoServer.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Net/samples/EchoServer/src/EchoServer.cpp#2 $
|
||||
// $Id: //poco/1.2/Net/samples/EchoServer/src/EchoServer.cpp#3 $
|
||||
//
|
||||
// This sample demonstrates the SocketReactor and SocketAcceptor classes.
|
||||
//
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "Poco/Net/SocketNotification.h"
|
||||
#include "Poco/Net/StreamSocket.h"
|
||||
#include "Poco/Net/ServerSocket.h"
|
||||
#include "Poco/Observer.h"
|
||||
#include "Poco/NObserver.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/Util/ServerApplication.h"
|
||||
@@ -53,7 +53,8 @@ using Poco::Net::ReadableNotification;
|
||||
using Poco::Net::ShutdownNotification;
|
||||
using Poco::Net::ServerSocket;
|
||||
using Poco::Net::StreamSocket;
|
||||
using Poco::Observer;
|
||||
using Poco::NObserver;
|
||||
using Poco::AutoPtr;
|
||||
using Poco::Thread;
|
||||
using Poco::Util::ServerApplication;
|
||||
using Poco::Util::Application;
|
||||
@@ -73,8 +74,8 @@ public:
|
||||
Application& app = Application::instance();
|
||||
app.logger().information("Connection from " + socket.peerAddress().toString());
|
||||
|
||||
_reactor.addEventHandler(_socket, Observer<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
|
||||
_reactor.addEventHandler(_socket, Observer<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
|
||||
_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
|
||||
_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
|
||||
}
|
||||
|
||||
~EchoServiceHandler()
|
||||
@@ -87,14 +88,13 @@ public:
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
_reactor.removeEventHandler(_socket, Observer<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
|
||||
_reactor.removeEventHandler(_socket, Observer<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
|
||||
_reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
|
||||
_reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
|
||||
delete [] _pBuffer;
|
||||
}
|
||||
|
||||
void onReadable(ReadableNotification* pNf)
|
||||
void onReadable(const AutoPtr<ReadableNotification>& pNf)
|
||||
{
|
||||
pNf->release(); // we get ownership of the notification, but we do not need it, so we kiss it goodbye.
|
||||
int n = _socket.receiveBytes(_pBuffer, BUFFER_SIZE);
|
||||
if (n > 0)
|
||||
_socket.sendBytes(_pBuffer, n);
|
||||
@@ -102,9 +102,8 @@ public:
|
||||
delete this;
|
||||
}
|
||||
|
||||
void onShutdown(ShutdownNotification* pNf)
|
||||
void onShutdown(const AutoPtr<ShutdownNotification>& pNf)
|
||||
{
|
||||
pNf->release();
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user