36 static const unsigned comBufSize = 0x4000;
42 virtual void *
allocate (
size_t ) = 0;
43 virtual void release (
void * ) = 0;
48 virtual unsigned sendBytes (
const void * pBuf,
69 virtual void recvBytes (
void * pBuf,
79 unsigned unoccupiedBytes ()
const;
80 unsigned occupiedBytes ()
const;
81 unsigned uncommittedBytes ()
const;
82 static unsigned capacityBytes ();
84 unsigned copyInBytes (
const void *pBuf,
unsigned nBytes );
85 unsigned push (
comBuf & );
87 bool push (
const T &
value );
89 unsigned push (
const T * pValue,
unsigned nElem );
90 unsigned push (
const epicsInt8 * pValue,
unsigned nElem );
91 unsigned push (
const epicsUInt8 * pValue,
unsigned nElem );
93 void commitIncomming ();
94 void clearUncommittedIncomming ();
95 bool copyInAllBytes (
const void *pBuf,
unsigned nBytes );
96 unsigned copyOutBytes (
void *pBuf,
unsigned nBytes );
97 bool copyOutAllBytes (
void *pBuf,
unsigned nBytes );
98 unsigned removeBytes (
unsigned nBytes );
107 static void throwInsufficentBytesException ();
108 void *
operator new (
size_t size,
112 unsigned commitIndex;
113 unsigned nextWriteIndex;
114 unsigned nextReadIndex;
116 void operator delete (
void * );
118 bool push ( const T * );
121 inline
void *
comBuf::operator new (
size_t size,
124 return mgr.allocate ( size );
127 #ifdef CXX_PLACEMENT_DELETE 128 inline void comBuf::operator
delete (
void * pCadaver,
131 mgr.release ( pCadaver );
136 nextWriteIndex ( 0u ), nextReadIndex ( 0u )
142 this->commitIndex = 0u;
181 sizeof ( this->
buf ) - this->nextWriteIndex, stat );
191 unsigned available =
sizeof ( this->
buf ) - index;
192 if (
sizeof ( value ) > available ) {
213 unsigned available =
sizeof ( this->
buf ) - index;
214 unsigned nBytes =
sizeof ( *pValue ) * nElem;
215 if ( nBytes > available ) {
216 nElem = available /
sizeof ( *pValue );
217 nBytes = nElem *
sizeof ( *pValue );
219 memcpy ( &this->
buf[ index ], pValue, nBytes );
228 unsigned available =
sizeof ( this->
buf ) - index;
229 unsigned nBytes =
sizeof ( *pValue ) * nElem;
230 if ( nBytes > available ) {
231 nElem = available /
sizeof ( *pValue );
233 for (
unsigned i = 0u;
i < nElem;
i++ ) {
236 index +=
sizeof ( *pValue );
255 unsigned available =
sizeof ( this->
buf ) - index;
256 if ( nBytes <= available ) {
257 memcpy ( & this->
buf[index], pBuf, nBytes );
267 unsigned available =
sizeof ( this->
buf ) - index;
268 if ( nBytes > available ) {
271 memcpy ( & this->
buf[index], pBuf, nBytes );
279 unsigned occupied = this->commitIndex - index;
280 if ( nBytes <= occupied ) {
281 memcpy ( pBuf, &this->
buf[index], nBytes);
291 unsigned occupied = this->commitIndex - index;
292 if ( nBytes > occupied ) {
295 memcpy ( pBuf, &this->
buf[index], nBytes);
303 unsigned occupied = this->commitIndex - index;
304 if ( nBytes > occupied ) {
315 unsigned popIndex = nrIndex +
sizeof ( returnVal );
316 unsigned cIndex = this->commitIndex;
320 if ( popIndex >= cIndex ) {
321 if ( popIndex == cIndex ) {
329 WireGet ( & this->
buf[ nrIndex ], returnVal );
334 #endif // ifndef INC_comBuf_H bool copyOutAllBytes(void *pBuf, unsigned nBytes)
char epicsOldString[MAX_STRING_SIZE]
virtual ~wireSendAdapter()
An EPICS-specific replacement for ANSI C's assert.
unsigned copyInBytes(const void *pBuf, unsigned nBytes)
bool copyInAllBytes(const void *pBuf, unsigned nBytes)
void fillFromWire(wireRecvAdapter &, statusWireIO &)
unsigned uncommittedBytes() const
swioCircuitState circuitState
void clearUncommittedIncomming()
epicsUInt8 buf[comBufSize]
unsigned occupiedBytes() const
unsigned copyOutBytes(void *pBuf, unsigned nBytes)
virtual ~wireRecvAdapter()
unsigned removeBytes(unsigned nBytes)
virtual void recvBytes(void *pBuf, unsigned nBytesInBuf, statusWireIO &)=0
virtual void * allocate(size_t)=0
virtual ~comBufMemoryManager()
unsigned unoccupiedBytes() const
static unsigned capacityBytes()
Compiler specific declarations.
epicsPlacementDeleteOperator((void *, comBufMemoryManager &)) private unsigne nextWriteIndex)
virtual void release(void *)=0