otsdaq_components  v2_05_02_indev
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/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*/)
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*/)
36  {
37  __SS__;
38  __THROW__(ss.str() + "Illegal call to undefined base class member function");
39  }
40  virtual void writeAndAcknowledge(const std::string& /*sendBuffer*/,
41  int /*timeoutSeconds*/ = -1)
42  {
43  __SS__;
44  __THROW__(ss.str() + "Illegal call to undefined base class member function");
45  }
46  virtual void writeAndAcknowledge(const std::vector<std::string>& /*sendBuffers*/,
47  int /*timeoutSeconds*/ = -1)
48  {
49  __SS__;
50  __THROW__(ss.str() + "Illegal call to undefined base class member function");
51  }
52  virtual void read(const std::string& /*sendBuffer*/,
53  std::string& /*receiveBuffer*/,
54  int /*timeoutSeconds*/ = -1)
55  {
56  __SS__;
57  __THROW__(ss.str() + "Illegal call to undefined base class member function");
58  }
59  virtual void read(const std::vector<std::string>& /*sendBuffers*/,
60  std::vector<std::string>& /*receiveBuffers*/,
61  int /*timeoutSeconds*/ = -1)
62  {
63  __SS__;
64  __THROW__(ss.str() + "Illegal call to undefined base class member function");
65  }
66 
67  // return count of 'things' flushed
68  virtual int flushRead()
69  {
70  __SS__;
71  __THROW__(ss.str() + "Illegal call to undefined base class member function");
72  return 0;
73  }
74 
75  protected:
76  unsigned int version_;
77 };
78 
79 } // namespace ots
80 
81 #endif // _ots_FrontEndHardwareBase_h_