CFEL - ASG Software Suite  2.5.0
CASS
tcp_streamer.h
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file tcp_streamer.h contains base class for all tcp streamers
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _TCPSTREAMER_H_
10 #define _TCPSTREAMER_H_
11 
12 #include <tr1/memory>
13 #include <string>
14 
15 #include <QtCore/QDataStream>
16 
17 namespace cass
18 {
19 class CASSEvent;
20 
21 /** base class for all tcp streamers
22  *
23  * @author Lutz Foucar
24  */
26 {
27 public:
28  /** typedef the shared pointer of this */
29  typedef std::tr1::shared_ptr<TCPStreamer> shared_pointer;
30 
31  /** virtual destructor */
32  virtual ~TCPStreamer() {}
33 
34  /** create an instance of the requested type and return a reference
35  *
36  * @return a refrerence to the object contained in the shared pointer
37  * @param type the reqested type
38  */
39  static TCPStreamer& instance(const std::string &type);
40 
41  /** return a reference to the derefenced instance
42  *
43  * @return a refrerence to the object contained in the shared pointer
44  */
45  static TCPStreamer& instance();
46 
47  /** deserialize stream
48  *
49  * @return the nbr of bytes read of from stream
50  * @param stream The stream that contains the serialized data
51  * @param evt The CASS Event that the data should be deserialized to.
52  */
53  virtual size_t operator()(QDataStream &stream, CASSEvent& evt)=0;
54 
55  /** deserialize the file header
56  *
57  * @return the nbr of bytes read of from stream
58  * @param stream the datastream containing the header information
59  */
60  virtual size_t operator()(QDataStream&/*stream*/) {return 0;}
61 
62 protected:
63  /** only inheritants can create this */
65 
66  /** a sigleton instance */
67  static shared_pointer _instance;
68 };
69 } //end namespace cass
70 #endif
virtual size_t operator()(QDataStream &)
deserialize the file header
Definition: tcp_streamer.h:60
Event to store all LCLS Data.
Definition: cass_event.h:32
static TCPStreamer & instance()
return a reference to the derefenced instance
static shared_pointer _instance
a sigleton instance
Definition: tcp_streamer.h:67
std::tr1::shared_ptr< TCPStreamer > shared_pointer
typedef the shared pointer of this
Definition: tcp_streamer.h:29
virtual ~TCPStreamer()
virtual destructor
Definition: tcp_streamer.h:32
virtual size_t operator()(QDataStream &stream, CASSEvent &evt)=0
deserialize stream
base class for all tcp streamers
Definition: tcp_streamer.h:25
TCPStreamer()
only inheritants can create this
Definition: tcp_streamer.h:64