otsdaq_components  v2_02_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 
12 #include "otsdaq-core/Macros/CoutMacros.h"
13 
14 #include <string>
15 #include <vector>
16 #include <stdexcept> /*for std::runtime_error*/
17 
18 namespace ots
19 {
20 
22 {
23 public:
24  FrontEndHardwareBase(unsigned int version = -1):version_(version) {;}
25  virtual ~FrontEndHardwareBase() {;}
26 
27  //These should never be called directly if used correctly, but
28  //not all classes will implement every function (so no pure virtuals). Should be obvious
29  //that the wrong thing is happening if these are called because exceptions are thrown!
30 
31  virtual void write (const std::string& sendBuffer) throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");}
32  virtual void write (const std::vector<std::string>& sendBuffers) throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");}
33  virtual void writeAndAcknowledge(const std::string& sendBuffer, int timeoutSeconds = -1) throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");}
34  virtual void writeAndAcknowledge(const std::vector<std::string>& sendBuffers, int timeoutSeconds = -1) throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");}
35  virtual void read (const std::string& sendBuffer , std::string& receiveBuffer, int timeoutSeconds = -1) throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");}
36  virtual void read (const std::vector<std::string>& sendBuffers, std::vector<std::string>& receiveBuffers, int timeoutSeconds = -1) throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function");}
37 
38  //return count of 'things' flushed
39  virtual int flushRead () throw(std::runtime_error){__SS__; __THROW__(ss.str() + "Illegal call to undefined base class member function"); return 0;}
40 
41  static const std::string PURDUE_HARDWARE_NAME;
42  static const std::string OTS_HARDWARE_NAME;
43 protected:
44  unsigned int version_;
45 };
46 
47 const std::string FrontEndHardwareBase::PURDUE_HARDWARE_NAME = "PurdueHardware";
48 const std::string FrontEndHardwareBase::OTS_HARDWARE_NAME = "OtsUDPHardware";
49 
50 } // namespace ots
51 
52 #endif // _ots_FrontEndHardwareBase_h_