mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-03 16:40:41 +02:00
adding namespace sls to public receiver api
This commit is contained in:
parent
121a3ad733
commit
2020407438
@ -11,6 +11,8 @@
|
||||
#include <semaphore.h>
|
||||
#include <vector>
|
||||
|
||||
namespace sls{
|
||||
|
||||
/** Circular Fifo (a.k.a. Circular Buffer)
|
||||
* Thread safe for one reader, and one writer */
|
||||
template <typename Element> class CircularFifo {
|
||||
@ -127,3 +129,5 @@ size_t CircularFifo<Element>::increment(size_t i) const {
|
||||
i = (i + 1) % capacity;
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,9 @@
|
||||
|
||||
class ClientInterface;
|
||||
|
||||
namespace sls
|
||||
{
|
||||
|
||||
class Receiver : private virtual slsDetectorDefs {
|
||||
|
||||
public:
|
||||
@ -86,3 +89,5 @@ class Receiver : private virtual slsDetectorDefs {
|
||||
private:
|
||||
std::unique_ptr<ClientInterface> tcpipInterface;
|
||||
};
|
||||
|
||||
} // namespace sls
|
@ -33,9 +33,9 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
DestroyFifos();
|
||||
|
||||
// create fifos
|
||||
fifoBound = new CircularFifo<char>(fifoDepth);
|
||||
fifoFree = new CircularFifo<char>(fifoDepth);
|
||||
fifoStream = new CircularFifo<char>(fifoDepth);
|
||||
fifoBound = new sls::CircularFifo<char>(fifoDepth);
|
||||
fifoFree = new sls::CircularFifo<char>(fifoDepth);
|
||||
fifoStream = new sls::CircularFifo<char>(fifoDepth);
|
||||
// allocate memory
|
||||
size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
||||
memory = (char *)malloc(mem_len);
|
||||
|
@ -92,13 +92,13 @@ class Fifo : private virtual slsDetectorDefs {
|
||||
char *memory;
|
||||
|
||||
/** Circular Fifo pointing to addresses of bound data in memory */
|
||||
CircularFifo<char> *fifoBound;
|
||||
sls::CircularFifo<char> *fifoBound;
|
||||
|
||||
/** Circular Fifo pointing to addresses of freed data in memory */
|
||||
CircularFifo<char> *fifoFree;
|
||||
sls::CircularFifo<char> *fifoFree;
|
||||
|
||||
/** Circular Fifo pointing to addresses of to be streamed data in memory */
|
||||
CircularFifo<char> *fifoStream;
|
||||
sls::CircularFifo<char> *fifoStream;
|
||||
|
||||
/** Fifo depth set */
|
||||
int fifoDepth;
|
||||
|
@ -216,9 +216,9 @@ int main(int argc, char *argv[]) {
|
||||
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i,
|
||||
(long)syscall(SYS_gettid));
|
||||
|
||||
std::unique_ptr<Receiver> receiver = nullptr;
|
||||
std::unique_ptr<sls::Receiver> receiver = nullptr;
|
||||
try {
|
||||
receiver = sls::make_unique<Receiver>(startTCPPort + i);
|
||||
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
|
||||
} catch (...) {
|
||||
LOG(logINFOBLUE)
|
||||
<< "Exiting Child Process [ Tid: " << syscall(SYS_gettid)
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace sls{
|
||||
|
||||
Receiver::~Receiver() = default;
|
||||
|
||||
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
||||
@ -142,3 +144,5 @@ void Receiver::registerCallBackRawDataModifyReady(
|
||||
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
|
||||
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
||||
}
|
||||
|
||||
}
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
try {
|
||||
Receiver r(argc, argv);
|
||||
sls::Receiver r(argc, argv);
|
||||
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||
sem_wait(&semaphore);
|
||||
sem_destroy(&semaphore);
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "catch.hpp"
|
||||
#include <vector>
|
||||
|
||||
using sls::CircularFifo;
|
||||
|
||||
TEST_CASE("Empty buffer") {
|
||||
CircularFifo<char> fifo(0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user