My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
MasterMsg.h
1 #ifndef GCP_GRABBER_MASTERMSG_H
2 #define GCP_GRABBER_MASTERMSG_H
3 
11 #include "gcp/util/common/Exception.h"
12 #include "gcp/util/common/GenericMasterTaskMsg.h"
13 
14 #include "gcp/grabber/common/ControlMsg.h"
15 #include "gcp/grabber/common/ScannerMsg.h"
16 
17 namespace gcp {
18  namespace grabber {
19 
20  class MasterMsg :
22 
23  public:
27  enum MsgType {
28  CONTROL_CONNECTED, // A message that we are dis/connected from
29  // the control port
30  SCANNER_CONNECTED, // A message that we are dis/connected from
31  // the scanner port
32  CONTROL_MSG, // A message for the control task
33  SCANNER_MSG // A message for the scanner task
34  };
35 
40 
44  union {
45 
46  struct {
47  bool connected;
48  } controlConnected;
49 
50  struct {
51  bool connected;
52  } scannerConnected;
53 
58 
63 
64  } body;
65 
66  //------------------------------------------------------------
67  // Methods for returning pointers to messages for threads
68  // managed by this task.
69  //------------------------------------------------------------
70 
71  inline ScannerMsg* getScannerMsg()
72  {
74  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
75 
76  type = SCANNER_MSG;
77  return &body.scannerMsg;
78  }
79 
80  inline ControlMsg* getControlMsg()
81  {
83  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
84 
85  type = CONTROL_MSG;
86  return &body.controlMsg;
87  }
88 
92  inline void packControlConnectedMsg(bool connected)
93  {
95  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
96 
97  type = CONTROL_CONNECTED;
98 
99  body.controlConnected.connected = connected;
100  }
101 
105  inline void packScannerConnectedMsg(bool connected)
106  {
107  genericMsgType_ =
108  gcp::util::GenericTaskMsg::TASK_SPECIFIC;
109 
110  type = SCANNER_CONNECTED;
111 
112  body.scannerConnected.connected = connected;
113  }
114 
115  }; // End class MasterMsg
116 
117  }; // End namespace grabber
118 }; // End namespace gcp
119 
120 
121 #endif // End #ifndef GCP_GRABBER_MASTER_H
Definition: ControlMsg.h:17
void packControlConnectedMsg(bool connected)
Definition: MasterMsg.h:92
MsgType
Definition: MasterMsg.h:27
Definition: GenericMasterTaskMsg.h:36
ControlMsg controlMsg
Definition: MasterMsg.h:57
ScannerMsg scannerMsg
Definition: MasterMsg.h:62
Definition: MasterMsg.h:20
GenericMsgType genericMsgType_
Definition: GenericTaskMsg.h:50
union gcp::grabber::MasterMsg::@171 body
Definition: ScannerMsg.h:18
MsgType type
Definition: MasterMsg.h:39
void packScannerConnectedMsg(bool connected)
Definition: MasterMsg.h:105