Merge pull request #3 from esrf-bliss/add-slsReceiver-ctor-overload

merge for Add slsReceiver ctor overload and sls::make_unique
This commit is contained in:
Dhanya Thattil 2019-02-13 09:10:33 +01:00 committed by GitHub
commit 75a75b6cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 25 deletions

View File

@ -4,10 +4,9 @@
* @short creates the UDP and TCP class objects
***********************************************/
#include <memory>
class slsReceiverTCPIPInterface;
#include "slsReceiverTCPIPInterface.h"
#include "sls_detector_defs.h"
@ -27,11 +26,15 @@ class slsReceiver : private virtual slsDetectorDefs {
* @param argv from command line
*/
slsReceiver(int argc, char *argv[]);
/**
* Destructor
* Constructor
* Starts up a Receiver server. Reads configuration file, options, and
* assembles a Receiver using TCP and UDP detector interfaces
* throws an exception in case of failure
* @param tcpip_port_no TCP/IP port number
*/
~slsReceiver();
slsReceiver(int tcpip_port_no = 1954);
/**
* starts listening on the TCP port for client comminication
@ -95,6 +98,5 @@ class slsReceiver : private virtual slsDetectorDefs {
private:
slsReceiverTCPIPInterface* tcpipInterface;
std::unique_ptr<slsReceiverTCPIPInterface> tcpipInterface;
};

View File

@ -3,8 +3,9 @@
#include <stdio.h>
#include <stdint.h>
#include <memory>
class slsReceiver;
#include "slsReceiver.h"
/**
@short Class for implementing the SLS data receiver in the users application. Callbacks can be defined for processing and/or saving data
@ -23,10 +24,14 @@ public:
* @param success socket creation was successfull
*/
slsReceiverUsers(int argc, char *argv[], int &success);
/** Destructor */
~slsReceiverUsers();
/**
* Constructor
* reads config file, creates socket, assigns function table
* @param tcpip_port_no TCP/IP port
* @throws
*/
slsReceiverUsers(int tcpip_port_no = 1954);
/**
* starts listening on the TCP port for client comminication
@ -83,6 +88,5 @@ public:
char* datapointer, uint32_t &revDatasize, void*),void *arg);
//receiver object
slsReceiver* receiver;
std::unique_ptr<slsReceiver> receiver;
};

View File

@ -11,6 +11,7 @@
#include <map>
#include <getopt.h>
#include "container_utils.h" // For sls::make_unique<>
#include "slsReceiver.h"
#include "slsReceiverTCPIPInterface.h"
@ -78,14 +79,14 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
}
// might throw an exception
tcpipInterface = new slsReceiverTCPIPInterface(tcpip_port_no);
tcpipInterface = sls::make_unique<slsReceiverTCPIPInterface>(tcpip_port_no);
}
slsReceiver::~slsReceiver() {
if(tcpipInterface)
delete tcpipInterface;
slsReceiver::slsReceiver(int tcpip_port_no)
{
// might throw an exception
tcpipInterface = sls::make_unique<slsReceiverTCPIPInterface>(tcpip_port_no);
}

View File

@ -1,19 +1,19 @@
#include "container_utils.h" // For sls::make_unique<>
#include "slsReceiverUsers.h"
#include "slsReceiver.h"
slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) {
// catch the exception here to limit it to within the library (for current version)
try {
slsReceiver* r = new slsReceiver(argc, argv);
receiver = r;
receiver = sls::make_unique<slsReceiver>(argc, argv);
success = slsDetectorDefs::OK;
} catch (...) {
success = slsDetectorDefs::FAIL;
}
}
slsReceiverUsers::~slsReceiverUsers() {
delete receiver;
slsReceiverUsers::slsReceiverUsers(int tcpip_port_no) {
receiver = sls::make_unique<slsReceiver>(tcpip_port_no);
}
int slsReceiverUsers::start() {