mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 05:47:14 +02:00
Add slsReceiverUsers(int tcpip_port_no) overload
Use std::unique_ptr<> instead of raw pointers
This commit is contained in:
@ -4,10 +4,9 @@
|
|||||||
* @short creates the UDP and TCP class objects
|
* @short creates the UDP and TCP class objects
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "slsReceiverTCPIPInterface.h"
|
||||||
class slsReceiverTCPIPInterface;
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
|
|
||||||
@ -29,9 +28,13 @@ class slsReceiver : private virtual slsDetectorDefs {
|
|||||||
slsReceiver(int argc, char *argv[]);
|
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
|
* starts listening on the TCP port for client comminication
|
||||||
@ -95,6 +98,5 @@ class slsReceiver : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
slsReceiverTCPIPInterface* tcpipInterface;
|
std::unique_ptr<slsReceiverTCPIPInterface> tcpipInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.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
|
@short Class for implementing the SLS data receiver in the users application. Callbacks can be defined for processing and/or saving data
|
||||||
@ -24,9 +25,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
slsReceiverUsers(int argc, char *argv[], int &success);
|
slsReceiverUsers(int argc, char *argv[], int &success);
|
||||||
|
|
||||||
|
/**
|
||||||
/** Destructor */
|
* Constructor
|
||||||
~slsReceiverUsers();
|
* 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
|
* starts listening on the TCP port for client comminication
|
||||||
@ -83,6 +88,5 @@ public:
|
|||||||
char* datapointer, uint32_t &revDatasize, void*),void *arg);
|
char* datapointer, uint32_t &revDatasize, void*),void *arg);
|
||||||
|
|
||||||
//receiver object
|
//receiver object
|
||||||
slsReceiver* receiver;
|
std::unique_ptr<slsReceiver> receiver;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,14 +78,17 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
|
|||||||
}
|
}
|
||||||
|
|
||||||
// might throw an exception
|
// might throw an exception
|
||||||
tcpipInterface = new slsReceiverTCPIPInterface(tcpip_port_no);
|
//tcpipInterface = std::make_unique<slsReceiverTCPIPInterface>(tcpip_port_no);
|
||||||
|
tcpipInterface = std::unique_ptr<slsReceiverTCPIPInterface>(new slsReceiverTCPIPInterface(tcpip_port_no));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
slsReceiver::~slsReceiver() {
|
slsReceiver::slsReceiver(int tcpip_port_no)
|
||||||
if(tcpipInterface)
|
{
|
||||||
delete tcpipInterface;
|
// might throw an exception
|
||||||
|
//tcpipInterface = std::make_unique<slsReceiverTCPIPInterface>(tcpip_port_no);
|
||||||
|
tcpipInterface = std::unique_ptr<slsReceiverTCPIPInterface>(new slsReceiverTCPIPInterface(tcpip_port_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#include "slsReceiverUsers.h"
|
#include "slsReceiverUsers.h"
|
||||||
#include "slsReceiver.h"
|
|
||||||
|
|
||||||
slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) {
|
slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) {
|
||||||
// catch the exception here to limit it to within the library (for current version)
|
// catch the exception here to limit it to within the library (for current version)
|
||||||
try {
|
try {
|
||||||
slsReceiver* r = new slsReceiver(argc, argv);
|
//receiver = std::make_unique<slsReceiver>(argc, argv);
|
||||||
receiver = r;
|
receiver = std::unique_ptr<slsReceiver>(new slsReceiver(argc, argv));
|
||||||
success = slsDetectorDefs::OK;
|
success = slsDetectorDefs::OK;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
success = slsDetectorDefs::FAIL;
|
success = slsDetectorDefs::FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slsReceiverUsers::~slsReceiverUsers() {
|
slsReceiverUsers::slsReceiverUsers(int tcpip_port_no) {
|
||||||
delete receiver;
|
//receiver = std::make_unique<slsReceiver>(tcpip_port_no);
|
||||||
|
receiver = std::unique_ptr<slsReceiver>(new slsReceiver(tcpip_port_no));
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsReceiverUsers::start() {
|
int slsReceiverUsers::start() {
|
||||||
|
Reference in New Issue
Block a user