ICP  1
ISISDS.h
Go to the documentation of this file.
1 #ifndef ISISDS_H
2 #define ISISDS_H
3 
4 #include "isisds_command.h"
5 #include "../newicp/CRPTProxy.h"
6 
7 #import "..\\isisicp\\isisicp.tlb" named_guids
8 
10 {
11 private:
13  unsigned m_thread_id;
14 
15 public:
17  void start()
18  {
19  m_thread_handle = (HANDLE)_beginthreadex(NULL, 0, startHelper, this, 0, &m_thread_id);
20  }
21 
22  void cleanup()
23  {
24  if (m_thread_handle != 0)
25  {
26  CloseHandle(m_thread_handle);
27  m_thread_handle = 0;
28  }
29  m_thread_id = 0;
30  }
31  virtual void run() { }
32  bool isRunning() { return WaitForSingleObject(m_thread_handle, 0) == WAIT_TIMEOUT; }
33  virtual ~ThreadedClass() { cleanup(); }
34 
35 protected:
36  static unsigned __stdcall startHelper(void* arg)
37  {
38  ((ThreadedClass*)arg)->run();
39  _endthreadex(0);
40  return 0;
41  }
42 };
43 
44 struct ISISCRPT_STRUCT;
45 
47 {
48 private:
49  std::string m_address;
51  CComPtr<isisicpLib::Idae> m_dae;
52  SOCKET m_socket; //< client socket requests received on
53 
54  bool processCommand(ISISDSAccessMode access_type, const char* command_in, const char* comm_data_in, int comm_data_len_in,
55  char*& comm_data_out, ISISDSDataType& type_out, int* dims_array_out, int& ndims_out, bool& free_out);
56 
57 public:
58  ISISDSRequest(SOCKET s, const char* address, CRPTProxy& crpt) : ThreadedClass(), ISIS::Base(), m_socket(s), m_crpt(crpt), m_address(address) { setLoggerName("ISISDSRequest"); }
59  virtual void run();
61  const char* address() const { return m_address.c_str(); }
62 };
63 
65 {
66 private:
67  std::list<ISISDSRequest*> m_requests;
69  CComPtr<isisicpLib::Idae> m_dae;
70 
71 public:
72  ISISDS();
73  virtual void run();
74  virtual ~ISISDS();
75  int doit();
76 
77 };
78 
79 extern ISISDS* m_ds;
80 
81 #endif /* ISISDS_H */
virtual void run()
Definition: ISISDS.cpp:145
void cleanup()
Definition: ISISDS.h:22
virtual ~ISISDS()
Definition: ISISDS.cpp:19
ISISDSDataType
CComPtr< isisicpLib::Idae > m_dae
Definition: ISISDS.h:69
virtual void run()
Definition: ISISDS.h:31
const char * address() const
Definition: ISISDS.h:61
CComPtr< isisicpLib::Idae > m_dae
Definition: ISISDS.h:51
HANDLE m_thread_handle
Definition: ISISDS.h:12
Definition: ISISDS.h:64
ThreadedClass()
Definition: ISISDS.h:16
std::list< ISISDSRequest * > m_requests
Definition: ISISDS.h:67
virtual ~ISISDSRequest()
Definition: ISISDS.h:60
bool isRunning()
Definition: ISISDS.h:32
virtual void run()
Definition: ISISDS.cpp:25
CRPTProxy m_crpt
Definition: ISISDS.h:68
ISISDSRequest(SOCKET s, const char *address, CRPTProxy &crpt)
Definition: ISISDS.h:58
static unsigned __stdcall startHelper(void *arg)
Definition: ISISDS.h:36
int doit()
#define SOCKET
CRPTProxy & m_crpt
Definition: ISISDS.h:50
std::string m_address
Definition: ISISDS.h:49
Base(const std::string &logger_name="UNKNOWN")
Definition: IsisBase.h:13
ISISDSAccessMode
ISISDS * m_ds
Definition: ISISDS.cpp:12
void start()
Definition: ISISDS.h:17
#define closesocket
void setLoggerName(const std::string &logger_name)
Definition: IsisBase.h:17
unsigned m_thread_id
Definition: ISISDS.h:13
bool processCommand(ISISDSAccessMode access_type, const char *command_in, const char *comm_data_in, int comm_data_len_in, char *&comm_data_out, ISISDSDataType &type_out, int *dims_array_out, int &ndims_out, bool &free_out)
Definition: ISISDS.cpp:212
virtual ~ThreadedClass()
Definition: ISISDS.h:33
SOCKET m_socket
Definition: ISISDS.h:52
ISISDS()
Definition: ISISDS.cpp:14