CFEL - ASG Software Suite  2.5.0
CASS
tcp_streamer.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file tcp_streamer.cpp contains the base class for all tcp streamers
5  *
6  * @author Lutz Foucar
7  */
8 
9 #include <stdexcept>
10 
11 #include "tcp_streamer.h"
12 
13 #include "shm_deserializer.h"
14 #include "agat_deserializer.h"
15 
16 using namespace cass;
17 using namespace std;
18 using namespace std::tr1;
19 
21 
23 {
24  if(!_instance)
25  throw runtime_error("TCPStreamer::instance(): The instance has not been initialized yet.");
26  return *_instance.get();
27 }
28 
29 TCPStreamer &TCPStreamer::instance(const string &type)
30 {
31  if (type == "shm")
32  _instance = shared_pointer(new pixeldetector::SHMStreamer());
33  else if (type == "agat")
34  _instance = shared_pointer(new ACQIRIS::AGATStreamer());
35  else
36  {
37  throw invalid_argument("TCPStreamer::instance(type): streamer of type '"+ type +
38  "' is unknown.");
39  }
40  return *_instance;
41 }
42 
deserialize the data stream of the regular agat program
static TCPStreamer & instance()
return a reference to the derefenced instance
STL namespace.
contains functors to deserialize the data stream sent by shm2tcp.
static shared_pointer _instance
a sigleton instance
Definition: tcp_streamer.h:67
contains base class for all tcp streamers
std::tr1::shared_ptr< TCPStreamer > shared_pointer
typedef the shared pointer of this
Definition: tcp_streamer.h:29
deserialize the data stream of shm2tcp program
contains functions to deserialize the data stream sent by agat.
base class for all tcp streamers
Definition: tcp_streamer.h:25