billich 204a71c51a rename class eigerReceiver to EigerReceiver - start class names with a capital letter.
make class EigerReceiver an abstract base class with pure virtual public member functions.
So class EigerReceiver defines the interface, but does not expose the implementation.

Add a preliminary dummy implementation for  EigerReceiver.

Add a test program eigerReceiverTest to test the newly created EigerReceiver class. 
Modify the Makefile accordingly.

Example:

$ make eigerReceiverTest
g++  -DSLS_RECEIVER_FUNCTION_LIST -O3 -DEIGER_RECEIVER     -c -o eigerReceiverTest.o eigerReceiverTest.cpp
g++  -DSLS_RECEIVER_FUNCTION_LIST -O3 -DEIGER_RECEIVER     -c -o eigerReceiver.o eigerReceiver.cpp
g++    eigerReceiverTest.o eigerReceiver.o   -o eigerReceiverTest

$ ./eigerReceiverTest
main: start EigerReceiver tests
create(): Return new EigerReceiverImplementation instance.
initialize() with: detectorHostName= detectors_host_name.
getFileName(): Return some_file_name.
main: got file name some_file_name
getFilePath(): Return some_path.
main: got path name some_path
getDynamicRange(): Return 16.
main: got dynamic range 16.
getScanTag(): return 4711.
main: got scan tag 4711.
setFileName() called with some_other_name.
getFileName(): Return some_file_name.
main: got file name  some_file_name after setting to <some_other_name>
setFilePath() called withsome_other_path.
getFilePath(): Return some_path.
main: got file path  some_path after setting to <some_other_path>
setDynamicRange() called with 8.
getDynamicRange(): Return 16.
main: got dynamic range 16 after setting it to 8.
setNumberOfFrames() called with 11.
getNumberOfFrames(): return 42.
enableFileWrite() called with 1.
startReceiver(): return 0.
stopReceiver(): return 0.
abort(): return 0.
getEnableFileWrite() returns 1.
getDetectorHostname(): Return some_host_name.

HeinerBillich/2014-03-11


git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@766 951219d9-93cf-4727-9268-0efd64621fa3
2014-03-11 16:51:55 +00:00

120 lines
2.7 KiB
C++

/*
* eigerReceiver.cpp
*
* Created on: Mar 11, 2014
* Author: billich
*/
#include <iostream>
#include <string>
#include "eigerReceiver.h"
class EigerReceiverImplementation: public EigerReceiver {
public:
void initialize(const char *detectorHostName) {
std::cout << "initialize() with: detectorHostName= " << detectorHostName << ".\n";
}
char *getDetectorHostname() {
const std::string name = "some_host_name";
char *c = new char[name.length()];
name.copy(c, name.length());
c[name.length()] = '\0';
std::cout << "getDetectorHostname(): Return " << c << ".\n";
return(c);
}
char *getFileName() {
const std::string name = "some_file_name";
char *c = new char[name.length()];
name.copy(c, name.length());
c[name.length()] = '\0';
std::cout << "getFileName(): Return " << c << ".\n";
return(c);
}
char *getFilePath() {
std::string name = "some_path";
char *c = new char[name.length()];
name.copy(c, name.length());
c[name.length()] = '\0';
std::cout << "getFilePath(): Return " << c << ".\n";
return(c);
}
int getDynamicRange() {
std::cout << "getDynamicRange(): Return 16.\n";
return(16);
}
int getScanTag() {
std::cout << "getScanTag(): return 4711.\n";
return(4711);
}
int getNumberOfFrames() {
std::cout << "getNumberOfFrames(): return 42.\n";
return(42);
}
char * setFileName(const char c[]) {
std::cout << "setFileName() called with " << c <<".\n";
return(this->getFileName());
}
char * setFilePath(const char c[]) {
std::cout << "setFilePath() called with" << c << ".\n";
return(this->getFilePath());
}
int getEnableFileWrite() {
std::cout << "getEnableFileWrite() returns 1.\n";
return(1);
}
int setDynamicRange (const int dr) {
std::cout << "setDynamicRange() called with " << dr << '.' << '\n';
return(this->getDynamicRange());
}
int setScanTag (const int tag) {
std::cout << "setScanTag() called with " << tag << ".\n";
return(this->getScanTag());
}
int setNumberOfFrames (const int fnum) {
std::cout << "setNumberOfFrames() called with " << fnum << ".\n";
return(this->getNumberOfFrames());
}
int setEnableFileWrite(const int i) {
std::cout << "enableFileWrite() called with " << i << ".\n";
return(0);
}
int startReceiver(char message[]) {
std::cout << "startReceiver(): return 0.\n";
message = NULL;
return(0);
}
int stopReceiver() {
std::cout << "stopReceiver(): return 0.\n";
return(0);
}
void abort() {
std::cout << "abort(): return 0.\n";
}
};
EigerReceiver *EigerReceiver::create(void) {
std::cout << "create(): Return new EigerReceiverImplementation instance.\n";
return new EigerReceiverImplementation();
}