integrated changes for 1.2.3

This commit is contained in:
Guenter Obiltschnig
2006-09-14 16:48:30 +00:00
parent a01116ca11
commit 245e2f7e83
6 changed files with 53 additions and 17 deletions

View File

@@ -1463,7 +1463,7 @@
RelativePath=".\src\NotificationQueue.cpp"> RelativePath=".\src\NotificationQueue.cpp">
</File> </File>
<File <File
RelativePath=".\src\Observer.cpp"> RelativePath=".\src\AbstractObserver.cpp">
</File> </File>
</Filter> </Filter>
<Filter <Filter
@@ -1478,9 +1478,15 @@
<File <File
RelativePath=".\include\Poco\NotificationQueue.h"> RelativePath=".\include\Poco\NotificationQueue.h">
</File> </File>
<File
RelativePath=".\include\Poco\AbstractObserver.h">
</File>
<File <File
RelativePath=".\include\Poco\Observer.h"> RelativePath=".\include\Poco\Observer.h">
</File> </File>
<File
RelativePath=".\include\Poco\NObserver.h">
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter

View File

@@ -1932,7 +1932,7 @@
> >
</File> </File>
<File <File
RelativePath=".\src\Observer.cpp" RelativePath=".\src\AbstractObserver.cpp"
> >
</File> </File>
</Filter> </Filter>
@@ -1951,10 +1951,18 @@
RelativePath=".\include\Poco\NotificationQueue.h" RelativePath=".\include\Poco\NotificationQueue.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\AbstractObserver.h"
>
</File>
<File <File
RelativePath=".\include\Poco\Observer.h" RelativePath=".\include\Poco\Observer.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\NObserver.h"
>
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter

View File

@@ -1,7 +1,7 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Foundation/Makefile#1 $ # $Id: //poco/1.2/Foundation/Makefile#2 $
# #
# Makefile for Poco Foundation # Makefile for Poco Foundation
# #
@@ -18,7 +18,7 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \ LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \
MemoryPool MD2Engine MD4Engine MD5Engine Manifest Message Mutex \ MemoryPool MD2Engine MD4Engine MD5Engine Manifest Message Mutex \
NestedDiagnosticContext Notification NotificationCenter \ NestedDiagnosticContext Notification NotificationCenter \
NotificationQueue NullStream NumberFormatter NumberParser Observer \ NotificationQueue NullStream NumberFormatter NumberParser AbstractObserver \
Path PatternFormatter Process PurgeStrategy RWLock Random RandomStream \ Path PatternFormatter Process PurgeStrategy RWLock Random RandomStream \
RegularExpression RefCountedObject Runnable RotateStrategy \ RegularExpression RefCountedObject Runnable RotateStrategy \
SHA1Engine Semaphore SharedLibrary SimpleFileChannel \ SHA1Engine Semaphore SharedLibrary SimpleFileChannel \

View File

@@ -1,7 +1,7 @@
// //
// NotificationCenterTest.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -35,11 +35,13 @@
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/NotificationCenter.h" #include "Poco/NotificationCenter.h"
#include "Poco/Observer.h" #include "Poco/Observer.h"
#include "Poco/NObserver.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
using Poco::NotificationCenter; using Poco::NotificationCenter;
using Poco::Observer; using Poco::Observer;
using Poco::NObserver;
using Poco::Notification; using Poco::Notification;
using Poco::AutoPtr; 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() void NotificationCenterTest::testDefaultCenter()
{ {
NotificationCenter& nc = NotificationCenter::defaultCenter(); 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() void NotificationCenterTest::setUp()
{ {
_set.clear(); _set.clear();
@@ -194,6 +213,7 @@ CppUnit::Test* NotificationCenterTest::suite()
CppUnit_addTest(pSuite, NotificationCenterTest, test3); CppUnit_addTest(pSuite, NotificationCenterTest, test3);
CppUnit_addTest(pSuite, NotificationCenterTest, test4); CppUnit_addTest(pSuite, NotificationCenterTest, test4);
CppUnit_addTest(pSuite, NotificationCenterTest, test5); CppUnit_addTest(pSuite, NotificationCenterTest, test5);
CppUnit_addTest(pSuite, NotificationCenterTest, testAuto);
CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultCenter); CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultCenter);
return pSuite; return pSuite;

View File

@@ -1,7 +1,7 @@
// //
// NotificationCenterTest.h // 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. // Definition of the NotificationCenterTest class.
// //
@@ -39,6 +39,7 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
#include "Poco/Notification.h" #include "Poco/Notification.h"
#include "Poco/AutoPtr.h"
#include <set> #include <set>
@@ -56,6 +57,7 @@ public:
void test3(); void test3();
void test4(); void test4();
void test5(); void test5();
void testAuto();
void testDefaultCenter(); void testDefaultCenter();
void setUp(); void setUp();
@@ -68,6 +70,7 @@ protected:
void handle2(Poco::Notification* pNf); void handle2(Poco::Notification* pNf);
void handle3(Poco::Notification* pNf); void handle3(Poco::Notification* pNf);
void handleTest(TestNotification* pNf); void handleTest(TestNotification* pNf);
void handleAuto(const Poco::AutoPtr<Poco::Notification>& pNf);
private: private:
std::set<std::string> _set; std::set<std::string> _set;

View File

@@ -1,7 +1,7 @@
// //
// EchoServer.cpp // 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. // This sample demonstrates the SocketReactor and SocketAcceptor classes.
// //
@@ -37,7 +37,7 @@
#include "Poco/Net/SocketNotification.h" #include "Poco/Net/SocketNotification.h"
#include "Poco/Net/StreamSocket.h" #include "Poco/Net/StreamSocket.h"
#include "Poco/Net/ServerSocket.h" #include "Poco/Net/ServerSocket.h"
#include "Poco/Observer.h" #include "Poco/NObserver.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include "Poco/Util/ServerApplication.h" #include "Poco/Util/ServerApplication.h"
@@ -53,7 +53,8 @@ using Poco::Net::ReadableNotification;
using Poco::Net::ShutdownNotification; using Poco::Net::ShutdownNotification;
using Poco::Net::ServerSocket; using Poco::Net::ServerSocket;
using Poco::Net::StreamSocket; using Poco::Net::StreamSocket;
using Poco::Observer; using Poco::NObserver;
using Poco::AutoPtr;
using Poco::Thread; using Poco::Thread;
using Poco::Util::ServerApplication; using Poco::Util::ServerApplication;
using Poco::Util::Application; using Poco::Util::Application;
@@ -73,8 +74,8 @@ public:
Application& app = Application::instance(); Application& app = Application::instance();
app.logger().information("Connection from " + socket.peerAddress().toString()); app.logger().information("Connection from " + socket.peerAddress().toString());
_reactor.addEventHandler(_socket, Observer<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable)); _reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
_reactor.addEventHandler(_socket, Observer<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown)); _reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
} }
~EchoServiceHandler() ~EchoServiceHandler()
@@ -87,14 +88,13 @@ public:
catch (...) catch (...)
{ {
} }
_reactor.removeEventHandler(_socket, Observer<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable)); _reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
_reactor.removeEventHandler(_socket, Observer<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown)); _reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
delete [] _pBuffer; 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); int n = _socket.receiveBytes(_pBuffer, BUFFER_SIZE);
if (n > 0) if (n > 0)
_socket.sendBytes(_pBuffer, n); _socket.sendBytes(_pBuffer, n);
@@ -102,9 +102,8 @@ public:
delete this; delete this;
} }
void onShutdown(ShutdownNotification* pNf) void onShutdown(const AutoPtr<ShutdownNotification>& pNf)
{ {
pNf->release();
delete this; delete this;
} }