s-net-Tools
HdlcdSessionDescriptor.h
Go to the documentation of this file.
1 
37 #ifndef HDLCD_SESSION_DESCRIPTOR_H
38 #define HDLCD_SESSION_DESCRIPTOR_H
39 
40 #include <stdint.h>
41 
42 // Session types. Select only one!
43 typedef enum {
49 
50  // Bookkeeping
55 
56 // Multiple combination of flags are possible
57 typedef enum {
63 
64  // Bookkeeping
67 
69 public:
70  // CTORs
71  HdlcdSessionDescriptor(E_SESSION_TYPE a_eSessionType, uint8_t a_SessionFlags): m_ServiceAccessPointSpecifier(a_eSessionType | a_SessionFlags) {
72  // Checks
73  if (((a_eSessionType & SESSION_TYPE_MASK) >= SESSION_TYPE_ARITHMETIC_ENDMARKER) ||
74  (a_eSessionType & ~SESSION_TYPE_MASK)) {
75  // Invalid session type
76  m_ServiceAccessPointSpecifier = SESSION_TYPE_UNSET;
77  } // if
78 
79  if (a_SessionFlags & ~SESSION_FLAGS_MASK) {
80  // Invalid flags
81  m_ServiceAccessPointSpecifier = SESSION_TYPE_UNSET;
82  } // if
83  }
84 
85  explicit HdlcdSessionDescriptor(uint8_t a_ServiceAccessPointSpecifier): m_ServiceAccessPointSpecifier(a_ServiceAccessPointSpecifier) {
86  // Checks
87  if ((m_ServiceAccessPointSpecifier & SESSION_TYPE_MASK) >= SESSION_TYPE_ARITHMETIC_ENDMARKER) {
88  // Invalid session type
89  m_ServiceAccessPointSpecifier = SESSION_TYPE_UNSET;
90  } // if
91  }
92 
93  // Getter
94  operator uint8_t() const {
95  return m_ServiceAccessPointSpecifier;
96  }
97 
99  return E_SESSION_TYPE(m_ServiceAccessPointSpecifier & SESSION_TYPE_MASK);
100  }
101 
102  bool DeliversRcvdData() const {
103  return (m_ServiceAccessPointSpecifier & SESSION_FLAGS_DELIVER_RCVD);
104  }
105 
106  bool DeliversSentData() const {
107  return (m_ServiceAccessPointSpecifier & SESSION_FLAGS_DELIVER_SENT);
108  }
109 
110  bool DeliversInvalidData() const {
111  return (m_ServiceAccessPointSpecifier & SESSION_FLAGS_DELIVER_INVALIDS);
112  }
113 
114 private:
115  uint8_t m_ServiceAccessPointSpecifier;
116 };
117 
118 #endif // HDLCD_SESSION_DESCRIPTOR_H
HdlcdSessionDescriptor(E_SESSION_TYPE a_eSessionType, uint8_t a_SessionFlags)
E_SESSION_TYPE GetSessionType() const
HdlcdSessionDescriptor(uint8_t a_ServiceAccessPointSpecifier)