ICP  1
Qxtrm_driver.h
Go to the documentation of this file.
1 // The following ifdef block is the standard way of creating macros which make exporting
2 // from a DLL simpler. All files within this DLL are compiled with the QXTRM_DRIVER_EXPORTS
3 // symbol defined on the command line. This symbol should not be defined on any project
4 // that uses this DLL. This way any other project whose source files include this file see
5 // QXTRM_DRIVER_API functions as being imported from a DLL, whereas this DLL sees symbols
6 // defined with this macro as being exported.
7 #ifndef QXTRM_DRIVER_H
8 #define QXTRM_DRIVER_H
9 
10 #ifdef QXTRM_DRIVER_EXPORTS
11 #define QXTRM_DRIVER_API __declspec(dllexport)
12 #else
13 #define QXTRM_DRIVER_API __declspec(dllimport)
14 #endif
15 
16 #include "Poco/SharedPtr.h"
17 #include "../newicp/isisbase.h"
18 #include "qxtrm.h"
19 
20 static const int INVALID_QXTRM_CHANNEL = -1;
21 
22 class Quixtream;
23 
25 {
26  Poco::SharedPtr<Quixtream> m_qx;
27  int m_chan_id;
28  std::string m_chan_name;
29  void channelStatsHelper(int chan, qxtrmTransStatsCmd cmd, const char* mess, std::ostream& oss) const;
30  public:
31  Qxtrm_channel(Poco::SharedPtr<Quixtream> qx, const std::string& chan_name);
32  virtual ~Qxtrm_channel();
33  void RDMAWrite(uint32_t value, unsigned int remote_address) { RDMAWrite(&value, sizeof(value), remote_address); }
34  void RDMARead(uint32_t& value, unsigned int remote_address) { RDMARead(&value, sizeof(value), remote_address); }
35  void RDMARead(void* buffer, unsigned int len, unsigned int remote_address);
36  void RDMAWrite(const void* buffer, unsigned int len, unsigned int remote_address);
37  void blockSend(const void* buffer, unsigned int len);
38  void blockReceive(void* buffer, unsigned int len);
39  void streamSend(const void* buffer, unsigned int len);
40  void streamReceive(qxtrmStreamCallbackFunc pCallback, unsigned int interval);
41  void streamReceive();
42  void RDMARegisterMemory(void* local_address, unsigned int len, unsigned int rdmaAddr);
43  void RDMAUnregisterMemory(unsigned int rdmaAddr);
44  std::string channelStatus() const;
45  std::ostream& channelTransferStats(std::ostream& os) const;
46  std::ostream& channelStatus(std::ostream& os) const;
47  static void outputStreamDataCallback(char* pDataBuffer, unsigned int callbackSize, bool segmentEnd);
48  static FILE* m_outstream;
50  static int m_outstream_columns;
51 };
52 
53 // This class is exported from the Qxtrm_driver.dll
55 {
56  private:
57  Poco::SharedPtr<Quixtream> m_qx;
58  typedef std::map< std::string, Poco::SharedPtr<Qxtrm_channel> > chan_map_t;
60 
61  public: // functions
62  static void getNetworkDetails(const std::string& ip_prefix, std::string& ip_addr, std::string& mac_addr);
63  void loadConfigData(const std::string& config_file, int ethernet_id, bool do_remote_config, std::string& config_data);
64  static std::string qxtrmStatusMessage(int qxtrm_status, Quixtream* qx = NULL, int chan = INVALID_QXTRM_CHANNEL);
65  static std::string qxtrmChannelStatusMessage(int qxtrm_channel_status);
66  static std::string qxtrmChannelStatusMessage(Quixtream* qx, int chan);
67  std::ostream& channelStatus(std::ostream& os) const;
68  std::ostream& channelTransferStats(std::ostream& os) const;
69  Poco::SharedPtr<Qxtrm_channel> createChannel(const std::string& chan_name);
70  Qxtrm_driver(const std::string& config_file, const std::string& node_name, int ethernet_id, int process_number, bool do_remote_config);
71  virtual ~Qxtrm_driver();
72 };
73 
75 class QXTRM_DRIVER_API qxtrmException : public std::runtime_error
76 {
77 public:
78  explicit qxtrmException(const char* message) : std::runtime_error(message) { }
79  explicit qxtrmException(const std::string& message) : std::runtime_error(message) { }
84  explicit qxtrmException(int qxtrm_status, const std::string& message = "", Quixtream* qx = NULL, int chan = INVALID_QXTRM_CHANNEL) :
85  std::runtime_error(message + "(Quixtream: " + Qxtrm_driver::qxtrmStatusMessage(qxtrm_status, qx, chan) + ")") { }
86 };
87 
88 #endif /* QXTRM_DRIVER_H */
chan_map_t m_chans
Definition: Qxtrm_driver.h:59
static FILE * m_outstream
Definition: Qxtrm_driver.h:48
std::string m_chan_name
Definition: Qxtrm_driver.h:28
Poco::SharedPtr< Quixtream > m_qx
Definition: Qxtrm_driver.h:57
qxtrmException(const char *message)
Definition: Qxtrm_driver.h:78
static const int INVALID_QXTRM_CHANNEL
Definition: Qxtrm_driver.h:20
qxtrmException(const std::string &message)
Definition: Qxtrm_driver.h:79
void RDMAWrite(uint32_t value, unsigned int remote_address)
Definition: Qxtrm_driver.h:33
std::map< std::string, Poco::SharedPtr< Qxtrm_channel > > chan_map_t
Definition: Qxtrm_driver.h:58
#define QXTRM_DRIVER_API
Definition: Qxtrm_driver.h:13
Poco::SharedPtr< Quixtream > m_qx
Definition: Qxtrm_driver.h:26
qxtrmException(int qxtrm_status, const std::string &message="", Quixtream *qx=NULL, int chan=INVALID_QXTRM_CHANNEL)
Definition: Qxtrm_driver.h:84
void RDMARead(uint32_t &value, unsigned int remote_address)
Definition: Qxtrm_driver.h:34
static int m_outstream_word_size
Definition: Qxtrm_driver.h:49
Exception class recording an error raised by a Quixtream API function.
Definition: Qxtrm_driver.h:75
static int m_outstream_columns
Definition: Qxtrm_driver.h:50