This is Unofficial EPICS BASE Doxygen Site
comQueRecv Class Reference

#include "comQueRecv.h"

Public Member Functions

 comQueRecv (comBufMemoryManager &)
 
 ~comQueRecv ()
 
unsigned occupiedBytes () const
 
unsigned copyOutBytes (epicsInt8 *pBuf, unsigned nBytes)
 
unsigned removeBytes (unsigned nBytes)
 
void pushLastComBufReceived (comBuf &)
 
void clear ()
 
bool popOldMsgHeader (struct caHdrLargeArray &)
 
epicsInt8 popInt8 ()
 
epicsUInt8 popUInt8 ()
 
epicsInt16 popInt16 ()
 
epicsUInt16 popUInt16 ()
 
epicsInt32 popInt32 ()
 
epicsUInt32 popUInt32 ()
 
epicsFloat32 popFloat32 ()
 
epicsFloat64 popFloat64 ()
 
void popString (epicsOldString *)
 

Detailed Description

Definition at line 30 of file comQueRecv.h.

Constructor & Destructor Documentation

comQueRecv::comQueRecv ( comBufMemoryManager comBufMemoryManagerIn)

Definition at line 28 of file comQueRecv.cpp.

28  :
29  comBufMemMgr ( comBufMemoryManagerIn ), nBytesPending ( 0u )
30 {
31 }
comQueRecv::~comQueRecv ( )

Definition at line 33 of file comQueRecv.cpp.

34 {
35  this->clear ();
36 }
void clear()
Definition: comQueRecv.cpp:38

Member Function Documentation

void comQueRecv::clear ( )

Definition at line 38 of file comQueRecv.cpp.

39 {
40  comBuf *pBuf;
41  while ( ( pBuf = this->bufs.get () ) ) {
42  pBuf->~comBuf ();
43  this->comBufMemMgr.release ( pBuf );
44  }
45  this->nBytesPending = 0u;
46 }
T * get()
Definition: tsDLList.h:261
Definition: comBuf.h:75
virtual void release(void *)=0
unsigned comQueRecv::copyOutBytes ( epicsInt8 pBuf,
unsigned  nBytes 
)

Definition at line 48 of file comQueRecv.cpp.

49 {
50  unsigned totalBytes = 0u;
51  do {
52  comBuf * pComBuf = this->bufs.first ();
53  if ( ! pComBuf ) {
54  this->nBytesPending -= totalBytes;
55  return totalBytes;
56  }
57  totalBytes += pComBuf->copyOutBytes ( &pBuf[totalBytes], nBytes - totalBytes );
58  if ( pComBuf->occupiedBytes () == 0u ) {
59  this->bufs.remove ( *pComBuf );
60  pComBuf->~comBuf ();
61  this->comBufMemMgr.release ( pComBuf );
62  }
63  }
64  while ( totalBytes < nBytes );
65  this->nBytesPending -= totalBytes;
66  return totalBytes;
67 }
unsigned occupiedBytes() const
Definition: comBuf.h:152
unsigned copyOutBytes(void *pBuf, unsigned nBytes)
Definition: comBuf.h:288
Definition: comBuf.h:75
void remove(T &item)
Definition: tsDLList.h:219
T * first(void) const
Definition: tsDLList.h:190
virtual void release(void *)=0
unsigned comQueRecv::occupiedBytes ( ) const
inline

Definition at line 60 of file comQueRecv.h.

61 {
62  return this->nBytesPending;
63 }
epicsFloat32 comQueRecv::popFloat32 ( )
inline

Definition at line 82 of file comQueRecv.h.

83 {
84  union {
85  epicsUInt8 _wire[ sizeof ( epicsFloat32 ) ];
86  epicsFloat32 _fp;
87  } tmp;
88  // optimizer will unroll this loop
89  for ( unsigned i = 0u; i < sizeof ( tmp._wire ); i++ ) {
90  tmp._wire[i] = this->popUInt8 ();
91  }
92  return AlignedWireRef < epicsFloat32 > ( tmp._fp );
93 }
epicsUInt8 popUInt8()
Definition: comQueRecv.cpp:174
int i
Definition: scan.c:967
unsigned char epicsUInt8
Definition: epicsTypes.h:39
float epicsFloat32
Definition: epicsTypes.h:48
epicsFloat64 comQueRecv::popFloat64 ( )
inline

Definition at line 97 of file comQueRecv.h.

98 {
99  union {
100  epicsUInt8 _wire[ sizeof ( epicsFloat64 ) ];
101  epicsFloat64 _fp;
102  } tmp;
103  // optimizer will unroll this loop
104  for ( unsigned i = 0u; i < sizeof ( tmp._wire ); i++ ) {
105  tmp._wire[i] = this->popUInt8 ();
106  }
107  return AlignedWireRef < epicsFloat64 > ( tmp._fp );
108 }
epicsUInt8 popUInt8()
Definition: comQueRecv.cpp:174
double epicsFloat64
Definition: epicsTypes.h:49
int i
Definition: scan.c:967
unsigned char epicsUInt8
Definition: epicsTypes.h:39
epicsInt16 comQueRecv::popInt16 ( )
inline

Definition at line 70 of file comQueRecv.h.

71 {
72  return static_cast < epicsInt16 > ( this->popUInt16() );
73 }
epicsUInt16 popUInt16()
Definition: comQueRecv.cpp:192
short epicsInt16
Definition: epicsTypes.h:40
epicsInt32 comQueRecv::popInt32 ( )
inline

Definition at line 75 of file comQueRecv.h.

76 {
77  return static_cast < epicsInt32 > ( this->popUInt32() );
78 }
int epicsInt32
Definition: epicsTypes.h:42
epicsUInt32 popUInt32()
Definition: comQueRecv.cpp:211
epicsInt8 comQueRecv::popInt8 ( )
inline

Definition at line 65 of file comQueRecv.h.

66 {
67  return static_cast < epicsInt8 > ( this->popUInt8() );
68 }
epicsUInt8 popUInt8()
Definition: comQueRecv.cpp:174
char epicsInt8
Definition: epicsTypes.h:38
bool comQueRecv::popOldMsgHeader ( struct caHdrLargeArray msg)

Definition at line 230 of file comQueRecv.cpp.

231 {
232  // try first for all in one buffer efficent version
233  comBuf * pComBuf = this->bufs.first ();
234  if ( ! pComBuf ) {
235  return false;
236  }
237  unsigned avail = pComBuf->occupiedBytes ();
238  if ( avail >= sizeof ( caHdr ) ) {
239  pComBuf->pop ( msg.m_cmmd );
240  ca_uint16_t smallPostsize = 0;
241  pComBuf->pop ( smallPostsize );
242  msg.m_postsize = smallPostsize;
243  pComBuf->pop ( msg.m_dataType );
244  ca_uint16_t smallCount = 0;
245  pComBuf->pop ( smallCount );
246  msg.m_count = smallCount;
247  pComBuf->pop ( msg.m_cid );
248  pComBuf->pop ( msg.m_available );
249  this->nBytesPending -= sizeof ( caHdr );
250  if ( avail == sizeof ( caHdr ) ) {
251  this->removeAndDestroyBuf ( *pComBuf );
252  }
253  return true;
254  }
255  else if ( this->occupiedBytes () >= sizeof ( caHdr ) ) {
256  msg.m_cmmd = this->popUInt16 ();
257  msg.m_postsize = this->popUInt16 ();
258  msg.m_dataType = this->popUInt16 ();
259  msg.m_count = this->popUInt16 ();
260  msg.m_cid = this->popUInt32 ();
261  msg.m_available = this->popUInt32 ();
262  return true;
263  }
264  else {
265  return false;
266  }
267 }
ca_uint32_t m_postsize
ca_uint16_t m_dataType
unsigned short ca_uint16_t
Definition: caProto.h:75
epicsUInt16 popUInt16()
Definition: comQueRecv.cpp:192
ca_uint32_t m_count
unsigned occupiedBytes() const
Definition: comBuf.h:152
unsigned occupiedBytes() const
Definition: comQueRecv.h:60
struct ca_hdr caHdr
ca_uint32_t m_cid
popStatus pop(T &)
Definition: comBuf.h:312
Definition: comBuf.h:75
ca_uint16_t m_cmmd
ca_uint32_t m_available
epicsUInt32 popUInt32()
Definition: comQueRecv.cpp:211
T * first(void) const
Definition: tsDLList.h:190
void comQueRecv::popString ( epicsOldString pStr)

Definition at line 95 of file comQueRecv.cpp.

96 {
97  for ( unsigned i = 0u; i < sizeof ( *pStr ); i++ ) {
98  pStr[0][i] = this->popInt8 ();
99  }
100 }
int i
Definition: scan.c:967
epicsInt8 popInt8()
Definition: comQueRecv.h:65
epicsUInt16 comQueRecv::popUInt16 ( )

Definition at line 192 of file comQueRecv.cpp.

193 {
194  comBuf * pComBuf = this->bufs.first ();
195  if ( ! pComBuf ) {
197  }
198  // try first for all in one buffer efficent version
199  epicsUInt16 tmp = 0;
200  comBuf::popStatus status = pComBuf->pop ( tmp );
201  if ( status.success ) {
202  this->nBytesPending -= sizeof ( epicsUInt16 );
203  if ( status.nowEmpty ) {
204  this->removeAndDestroyBuf ( *pComBuf );
205  }
206  return tmp;
207  }
208  return this->multiBufferPopUInt16 ();
209 }
pvd::Status status
unsigned short epicsUInt16
Definition: epicsTypes.h:41
static void throwInsufficentBytesException()
Definition: comBuf.cpp:49
popStatus pop(T &)
Definition: comBuf.h:312
Definition: comBuf.h:75
T * first(void) const
Definition: tsDLList.h:190
epicsUInt32 comQueRecv::popUInt32 ( )

Definition at line 211 of file comQueRecv.cpp.

212 {
213  comBuf *pComBuf = this->bufs.first ();
214  if ( ! pComBuf ) {
216  }
217  // try first for all in one buffer efficent version
218  epicsUInt32 tmp = 0;
219  comBuf::popStatus status = pComBuf->pop ( tmp );
220  if ( status.success ) {
221  this->nBytesPending -= sizeof ( epicsUInt32 );
222  if ( status.nowEmpty ) {
223  this->removeAndDestroyBuf ( *pComBuf );
224  }
225  return tmp;
226  }
227  return this->multiBufferPopUInt32 ();
228 }
pvd::Status status
unsigned int epicsUInt32
Definition: epicsTypes.h:43
static void throwInsufficentBytesException()
Definition: comBuf.cpp:49
popStatus pop(T &)
Definition: comBuf.h:312
Definition: comBuf.h:75
T * first(void) const
Definition: tsDLList.h:190
epicsUInt8 comQueRecv::popUInt8 ( )

Definition at line 174 of file comQueRecv.cpp.

175 {
176  comBuf * pComBuf = this->bufs.first ();
177  if ( ! pComBuf ) {
179  }
180  epicsUInt8 tmp = '\0';
181  comBuf::popStatus status = pComBuf->pop ( tmp );
182  if ( ! status.success ) {
184  }
185  if ( status.nowEmpty ) {
186  this->removeAndDestroyBuf ( *pComBuf );
187  }
188  this->nBytesPending--;
189  return tmp;
190 }
pvd::Status status
unsigned char epicsUInt8
Definition: epicsTypes.h:39
static void throwInsufficentBytesException()
Definition: comBuf.cpp:49
popStatus pop(T &)
Definition: comBuf.h:312
Definition: comBuf.h:75
T * first(void) const
Definition: tsDLList.h:190
void comQueRecv::pushLastComBufReceived ( comBuf bufIn)

Definition at line 102 of file comQueRecv.cpp.

104 {
105  bufIn.commitIncomming ();
106  comBuf * pComBuf = this->bufs.last ();
107  if ( pComBuf ) {
108  if ( pComBuf->unoccupiedBytes() ) {
109  this->nBytesPending += pComBuf->push ( bufIn );
110  pComBuf->commitIncomming ();
111  }
112  }
113  unsigned bufBytes = bufIn.occupiedBytes();
114  if ( bufBytes ) {
115  this->nBytesPending += bufBytes;
116  this->bufs.add ( bufIn );
117  }
118  else {
119  bufIn.~comBuf ();
120  this->comBufMemMgr.release ( & bufIn );
121  }
122 }
unsigned push(comBuf &)
Definition: comBuf.h:162
void commitIncomming()
Definition: comBuf.h:242
void add(T &item)
Definition: tsDLList.h:313
T * last(void) const
Definition: tsDLList.h:199
unsigned occupiedBytes() const
Definition: comBuf.h:152
Definition: comBuf.h:75
unsigned unoccupiedBytes() const
Definition: comBuf.h:147
virtual void release(void *)=0
unsigned comQueRecv::removeBytes ( unsigned  nBytes)

Definition at line 69 of file comQueRecv.cpp.

70 {
71  unsigned totalBytes = 0u;
72  unsigned bytesLeft = nBytes;
73  while ( bytesLeft ) {
74  comBuf * pComBuf = this->bufs.first ();
75  if ( ! pComBuf ) {
76  this->nBytesPending -= totalBytes;
77  return totalBytes;
78  }
79  unsigned nBytesThisTime = pComBuf->removeBytes ( bytesLeft );
80  if ( pComBuf->occupiedBytes () == 0u ) {
81  this->bufs.remove ( *pComBuf );
82  pComBuf->~comBuf ();
83  this->comBufMemMgr.release ( pComBuf );
84  }
85  if ( nBytesThisTime == 0u) {
86  break;
87  }
88  totalBytes += nBytesThisTime;
89  bytesLeft = nBytes - totalBytes;
90  }
91  this->nBytesPending -= totalBytes;
92  return totalBytes;
93 }
unsigned occupiedBytes() const
Definition: comBuf.h:152
unsigned removeBytes(unsigned nBytes)
Definition: comBuf.h:300
Definition: comBuf.h:75
void remove(T &item)
Definition: tsDLList.h:219
T * first(void) const
Definition: tsDLList.h:190
virtual void release(void *)=0

The documentation for this class was generated from the following files: