otsdaq_components  v2_03_00
FrontEndHardwareBase.h
1 /*
2  * FrontEndHardwareBase.h
3  *
4  * Created on: Aug 26, 2015
5  * Author: uplegger
6  */
7 
8 #ifndef _ots_FrontEndHardwareBase_h_
9 #define _ots_FrontEndHardwareBase_h_
10 
11 #include "otsdaq-core/Macros/CoutMacros.h"
12 
13 #include <stdexcept> /*for std::runtime_error*/
14 #include <string>
15 #include <vector>
16 
17 namespace ots
18 {
20 {
21  public:
22  FrontEndHardwareBase(unsigned int version = -1) : version_(version) { ; }
23  virtual ~FrontEndHardwareBase() { ; }
24 
25  // These should never be called directly if used correctly, but
26  // not all classes will implement every function (so no pure virtuals). Should be
27  // obvious that the wrong thing is happening if these are called because exceptions
28  // are thrown!
29 
30  virtual void write(const std::string& sendBuffer) throw(std::runtime_error)
31  {
32  __SS__;
33  __THROW__(ss.str() + "Illegal call to undefined base class member function");
34  }
35  virtual void write(const std::vector<std::string>& sendBuffers) throw(
36  std::runtime_error)
37  {
38  __SS__;
39  __THROW__(ss.str() + "Illegal call to undefined base class member function");
40  }
41  virtual void writeAndAcknowledge(const std::string& sendBuffer,
42  int timeoutSeconds = -1) throw(std::runtime_error)
43  {
44  __SS__;
45  __THROW__(ss.str() + "Illegal call to undefined base class member function");
46  }
47  virtual void writeAndAcknowledge(const std::vector<std::string>& sendBuffers,
48  int timeoutSeconds = -1) throw(std::runtime_error)
49  {
50  __SS__;
51  __THROW__(ss.str() + "Illegal call to undefined base class member function");
52  }
53  virtual void read(const std::string& sendBuffer,
54  std::string& receiveBuffer,
55  int timeoutSeconds = -1) throw(std::runtime_error)
56  {
57  __SS__;
58  __THROW__(ss.str() + "Illegal call to undefined base class member function");
59  }
60  virtual void read(const std::vector<std::string>& sendBuffers,
61  std::vector<std::string>& receiveBuffers,
62  int timeoutSeconds = -1) throw(std::runtime_error)
63  {
64  __SS__;
65  __THROW__(ss.str() + "Illegal call to undefined base class member function");
66  }
67 
68  // return count of 'things' flushed
69  virtual int flushRead() throw(std::runtime_error)
70  {
71  __SS__;
72  __THROW__(ss.str() + "Illegal call to undefined base class member function");
73  return 0;
74  }
75 
76  static const std::string PURDUE_HARDWARE_NAME;
77  static const std::string OTS_HARDWARE_NAME;
78 
79  protected:
80  unsigned int version_;
81 };
82 
83 const std::string FrontEndHardwareBase::PURDUE_HARDWARE_NAME = "PurdueHardware";
84 const std::string FrontEndHardwareBase::OTS_HARDWARE_NAME = "OtsUDPHardware";
85 
86 } // namespace ots
87 
88 #endif // _ots_FrontEndHardwareBase_h_