Added configuration to Context and fixed all the users.

This commit is contained in:
miha_vitorovic
2011-01-10 14:09:58 +01:00
parent 4b8bb07d61
commit df7a9fa073
12 changed files with 532 additions and 407 deletions

View File

@@ -18,6 +18,8 @@ using namespace epics::pvData;
class DummyResponseHandler : public ResponseHandler
{
public:
DummyResponseHandler(Context* ctx) : ResponseHandler(ctx) {}
virtual void handleResponse(osiSockAddr* responseFrom,
Transport* transport, int8 version, int8 command, int payloadSize,
ByteBuffer* payloadBuffer)
@@ -27,9 +29,33 @@ public:
};
class ContextImpl : public Context {
public:
ContextImpl() :
_tr(new TransportRegistry()), _timer(new Timer("server thread",
lowPriority)), _conf(new SystemConfigurationImpl()) {
}
virtual ~ContextImpl() {
delete _tr;
delete _timer;
}
virtual Timer* getTimer() { return _timer; }
virtual TransportRegistry* getTransportRegistry() { return _tr; }
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
virtual Transport* getSearchTransport() { return 0; }
virtual Configuration* getConfiguration() { return _conf; }
private:
TransportRegistry* _tr;
Timer* _timer;
Configuration* _conf;
};
void testBeaconEmitter()
{
DummyResponseHandler drh;
ContextImpl ctx;
DummyResponseHandler drh(&ctx);
/* SOCKET mysocket;
if ((mysocket = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
{

View File

@@ -37,7 +37,7 @@ void decodeFromIPv6Address(ByteBuffer* buffer, osiSockAddr* address)
class BeaconResponseHandler : public ResponseHandler
{
public:
BeaconResponseHandler()
BeaconResponseHandler(Context* ctx) : ResponseHandler(ctx)
{
_pvDataCreate = getPVDataCreate();
}
@@ -103,9 +103,33 @@ private:
};
class ContextImpl : public Context {
public:
ContextImpl() :
_tr(new TransportRegistry()), _timer(new Timer("server thread",
lowPriority)), _conf(new SystemConfigurationImpl()) {
}
virtual ~ContextImpl() {
delete _tr;
delete _timer;
}
virtual Timer* getTimer() { return _timer; }
virtual TransportRegistry* getTransportRegistry() { return _tr; }
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
virtual Transport* getSearchTransport() { return 0; }
virtual Configuration* getConfiguration() { return _conf; }
private:
TransportRegistry* _tr;
Timer* _timer;
Configuration* _conf;
};
void testBeaconHandler()
{
BeaconResponseHandler brh;
ContextImpl ctx;
BeaconResponseHandler brh(&ctx);
BlockingUDPConnector connector(false, NULL, true);
osiSockAddr bindAddr;

View File

@@ -29,28 +29,30 @@ using std::sscanf;
class ContextImpl : public Context {
public:
ContextImpl() :
_tr(new TransportRegistry()), _timer(new Timer("client thread",
lowPriority)) {
_tr(new TransportRegistry()), _timer(new Timer("server thread",
lowPriority)), _conf(new SystemConfigurationImpl()) {
}
virtual ~ContextImpl() {
delete _tr;
delete _timer;
}
virtual Timer* getTimer() {
return _timer;
}
virtual TransportRegistry* getTransportRegistry() {
return _tr;
}
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
virtual Transport* getSearchTransport() { return 0; }
virtual Timer* getTimer() { return _timer; }
virtual TransportRegistry* getTransportRegistry() { return _tr; }
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
virtual Transport* getSearchTransport() { return 0; }
virtual Configuration* getConfiguration() { return _conf; }
private:
TransportRegistry* _tr;
Timer* _timer;
Configuration* _conf;
};
class DummyResponseHandler : public ResponseHandler {
public:
DummyResponseHandler(Context* ctx) : ResponseHandler(ctx) {
}
virtual void handleResponse(osiSockAddr* responseFrom,
Transport* transport, int8 version, int8 command, int payloadSize,
ByteBuffer* payloadBuffer) {
@@ -110,7 +112,7 @@ void testBlockingTCPSender() {
DummyTransportClient dtc;
DummyTransportSender dts;
DummyResponseHandler drh;
DummyResponseHandler drh(&ctx);
osiSockAddr srvAddr;

View File

@@ -8,6 +8,7 @@
#include "blockingTCP.h"
#include "remote.h"
#include "logger.h"
#include "configuration.h"
#include <iostream>
@@ -21,7 +22,8 @@ class ContextImpl : public Context {
public:
ContextImpl() :
_tr(new TransportRegistry()),
_timer(new Timer("server thread", lowPriority)) {}
_timer(new Timer("server thread", lowPriority)),
_conf(new SystemConfigurationImpl()) {}
virtual ~ContextImpl() {
delete _tr;
delete _timer;
@@ -30,10 +32,12 @@ public:
virtual TransportRegistry* getTransportRegistry() { return _tr; }
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
virtual Transport* getSearchTransport() { return 0; }
virtual Configuration* getConfiguration() { return _conf; }
private:
TransportRegistry* _tr;
Timer* _timer;
Configuration* _conf;
};
void testServerConnections() {
@@ -43,7 +47,7 @@ void testServerConnections() {
1024);
cout<<"Press any key to stop the server...";
char c = cin.peek();
cin.peek();
delete srv;
}

View File

@@ -26,8 +26,44 @@ using std::sscanf;
static osiSockAddr sendTo;
class ContextImpl : public Context {
public:
ContextImpl() :
_tr(new TransportRegistry()), _timer(new Timer("server thread",
lowPriority)), _conf(new SystemConfigurationImpl()) {
}
virtual ~ContextImpl() {
delete _tr;
delete _timer;
}
virtual Timer* getTimer() {
return _timer;
}
virtual TransportRegistry* getTransportRegistry() {
return _tr;
}
virtual Channel* getChannel(epics::pvAccess::pvAccessID) {
return 0;
}
virtual Transport* getSearchTransport() {
return 0;
}
virtual Configuration* getConfiguration() {
return _conf;
}
private:
TransportRegistry* _tr;
Timer* _timer;
Configuration* _conf;
};
class DummyResponseHandler : public ResponseHandler {
public:
DummyResponseHandler(Context* ctx) :
ResponseHandler(ctx) {
}
virtual void handleResponse(osiSockAddr* responseFrom,
Transport* transport, int8 version, int8 command, int payloadSize,
ByteBuffer* payloadBuffer) {
@@ -69,9 +105,10 @@ private:
void testBlockingUDPSender() {
BlockingUDPConnector connector(false, NULL, true);
ContextImpl ctx;
DummyTransportSender dts;
DummyResponseHandler drh;
DummyResponseHandler drh(&ctx);
osiSockAddr bindAddr;

View File

@@ -21,10 +21,42 @@ using std::endl;
using std::hex;
using std::dec;
class ContextImpl : public Context {
public:
ContextImpl() :
_tr(new TransportRegistry()), _timer(new Timer("server thread",
lowPriority)), _conf(new SystemConfigurationImpl()) {
}
virtual ~ContextImpl() {
delete _tr;
delete _timer;
}
virtual Timer* getTimer() {
return _timer;
}
virtual TransportRegistry* getTransportRegistry() {
return _tr;
}
virtual Channel* getChannel(epics::pvAccess::pvAccessID) {
return 0;
}
virtual Transport* getSearchTransport() {
return 0;
}
virtual Configuration* getConfiguration() {
return _conf;
}
private:
TransportRegistry* _tr;
Timer* _timer;
Configuration* _conf;
};
class DummyResponseHandler : public ResponseHandler {
public:
DummyResponseHandler() :
packets(0) {
DummyResponseHandler(Context* context) :
ResponseHandler(context), packets(0) {
}
int getPackets() {
@@ -71,8 +103,9 @@ void DummyResponseHandler::handleResponse(osiSockAddr* responseFrom,
void testBlockingUDPConnector() {
BlockingUDPConnector connector(false, NULL, true);
ContextImpl ctx;
DummyResponseHandler drh;
DummyResponseHandler drh(&ctx);
osiSockAddr bindAddr;

File diff suppressed because it is too large Load Diff