Electric Tiger DAQ  1.0.0
Data Acquisition Software for the Electric Tiger Experiment
generics.h
1 #ifndef GENERICS_H
2 #define GENERICS_H
3 
4 //C System-Headers
5 //
6 //C++ System headers
7 #include <string>
8 #include <vector>
9 #include <iostream>
10 //Qt Headers
11 //
12 //OpenCV Headers
13 //
14 //Boost Headers
15 //
16 //Project specific headers
17 //
18 
19 struct TCPSocketParam {
20 
21  TCPSocketParam( const std::string& name, const std::string& addr, uint port ) : inst_name( name ), \
22  ip_addr( addr ),\
23  port_addr( port ) {}
24 
25  TCPSocketParam & operator=(const TCPSocketParam & sock_param ) {
26  inst_name = sock_param.inst_name;
27  ip_addr = sock_param.ip_addr;
28  port_addr = sock_param.port_addr;
29 
30  return *this;
31  }
32 
33  friend std::ostream& operator << (std::ostream& stream, TCPSocketParam& param) {
34 
35  stream << param.inst_name << "," \
36  << param.ip_addr << "," \
37  << param.port_addr;
38 
39  return stream;
40  }
41 
42  std::string inst_name;
43  std::string ip_addr;
44  uint port_addr;
45 };
46 
47 template< typename T >
48 struct data_triple {
49 
50  data_triple( T cav_len, T freq, T power ) : cavity_length( cav_len ),\
51  frequency_MHz( freq ), \
52  power_dBm( power ) {
53  static_assert( std::is_floating_point<T>::value, "data_triple must be initialized with floating point type.");
54  }
55 
56  data_triple & operator=(const data_triple & triple ) {
57  cavity_length = triple.cavity_length;
58  frequency_MHz = triple.frequency_MHz;
59  power_dBm = triple.power_dBm;
60 
61  return *this;
62  }
63 
64  friend std::ostream& operator << (std::ostream& stream, const data_triple& triple) {
65 
66  stream << triple.cavity_length << "," \
67  << triple.frequency_MHz << ","\
68  << triple.power_dBm;
69 
70  return stream;
71  }
72 
73 
74  friend std::ofstream& operator << (std::ofstream& stream, const data_triple& triple) {
75 
76  stream << triple.cavity_length << "," \
77  << triple.frequency_MHz << ","\
78  << triple.power_dBm;
79 
80  return stream;
81  }
82 
83  T cavity_length;
84  T frequency_MHz;
85  T power_dBm;
86 
87 };
88 
89 #endif /* GENERICS_H */
Definition: configprocessor.h:38
Definition: generics.h:48