Jpp  debug
the software that should make you happy
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JNET::JSocketBuffer< JElement_t > Class Template Reference

Auxiliary class for non-blocking socket I/O. More...

#include <JSocketNonblocking.hh>

Inheritance diagram for JNET::JSocketBuffer< JElement_t >:
JNET::JSocketStatus JNET::JSocketNonblockingReader JNET::JSocketNonblockingWriter JNET::JSocketInputChannel< JPrefix_t > JNET::JSocketOutputChannel< JPrefix_t >

Public Types

enum  JStatus_t { IO_RESET = -1 , IO_READY = 0 , IO_BUSY = +1 }
 

Public Member Functions

 JSocketBuffer (JElement_t *buffer, const int length)
 Constructor. More...
 
int getSize () const
 Get size of pending data. More...
 
void set (const JSocketBuffer< JElement_t > &buffer)
 Initialise buffer. More...
 
void set (JElement_t *buffer, const int length)
 Initialise buffer. More...
 
void reset ()
 Reset. More...
 
JStatus_t getStatus () const
 Get status of I/O. More...
 
bool isReset () const
 Check reset status. More...
 
bool isBusy () const
 Check busy status. More...
 
bool isReady () const
 Check ready status. More...
 
int getCounter () const
 Get number of I/O attempts. More...
 

Protected Member Functions

 JSocketBuffer ()
 Default constructor. More...
 
void setStatus (const JStatus_t status)
 Set status of I/O. More...
 

Protected Attributes

JElement_t * __data
 
int __size
 
JStatus_t status
 
int counter
 

Detailed Description

template<class JElement_t>
class JNET::JSocketBuffer< JElement_t >

Auxiliary class for non-blocking socket I/O.

Definition at line 22 of file JSocketNonblocking.hh.

Member Enumeration Documentation

◆ JStatus_t

Enumerator
IO_RESET 
IO_READY 
IO_BUSY 

Definition at line 26 of file JSocketStatus.hh.

Constructor & Destructor Documentation

◆ JSocketBuffer() [1/2]

template<class JElement_t >
JNET::JSocketBuffer< JElement_t >::JSocketBuffer ( )
inlineprotected

Default constructor.

Definition at line 29 of file JSocketNonblocking.hh.

29  :
30  JSocketStatus(),
31  __data(NULL),
32  __size(0)
33  {}
JSocketStatus()
Default constructor.

◆ JSocketBuffer() [2/2]

template<class JElement_t >
JNET::JSocketBuffer< JElement_t >::JSocketBuffer ( JElement_t *  buffer,
const int  length 
)
inline

Constructor.

Parameters
bufferI/O data
lengthnumber of bytes

Definition at line 43 of file JSocketNonblocking.hh.

43  :
44  JSocketStatus(),
45  __data(buffer),
46  __size(length)
47  {}

Member Function Documentation

◆ getSize()

template<class JElement_t >
int JNET::JSocketBuffer< JElement_t >::getSize ( ) const
inline

Get size of pending data.

Returns
number of bytes

Definition at line 55 of file JSocketNonblocking.hh.

56  {
57  return __size;
58  }

◆ set() [1/2]

template<class JElement_t >
void JNET::JSocketBuffer< JElement_t >::set ( const JSocketBuffer< JElement_t > &  buffer)
inline

Initialise buffer.

Parameters
bufferbuffer

Definition at line 66 of file JSocketNonblocking.hh.

67  {
68  set(buffer.__data, buffer.__size);
69  }
void set(const JSocketBuffer< JElement_t > &buffer)
Initialise buffer.

◆ set() [2/2]

template<class JElement_t >
void JNET::JSocketBuffer< JElement_t >::set ( JElement_t *  buffer,
const int  length 
)
inline

Initialise buffer.

Parameters
bufferI/O data
lengthnumber of bytes

Definition at line 78 of file JSocketNonblocking.hh.

79  {
80  if (status == IO_BUSY) {
81  THROW(JSocketException, "Set socket buffer I/O while busy.");
82  }
83 
84  status = (length != 0 ? IO_BUSY : IO_READY);
85  counter = 0;
86  __data = buffer;
87  __size = length;
88  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for socket.
Definition: JException.hh:468

◆ reset()

template<class JElement_t >
void JNET::JSocketBuffer< JElement_t >::reset ( )
inline

Reset.

Definition at line 94 of file JSocketNonblocking.hh.

95  {
97 
98  __data = NULL;
99  __size = 0;
100  }
void reset()
Reset.

◆ getStatus()

JStatus_t JNET::JSocketStatus::getStatus ( ) const
inlineinherited

Get status of I/O.

Returns
status

Definition at line 43 of file JSocketStatus.hh.

44  {
45  return status;
46  }

◆ isReset()

bool JNET::JSocketStatus::isReset ( ) const
inlineinherited

Check reset status.

Returns
true if reset; else false

Definition at line 54 of file JSocketStatus.hh.

55  {
56  return status == IO_RESET;
57  }

◆ isBusy()

bool JNET::JSocketStatus::isBusy ( ) const
inlineinherited

Check busy status.

Returns
true if busy; else false

Definition at line 65 of file JSocketStatus.hh.

66  {
67  return status == IO_BUSY;
68  }

◆ isReady()

bool JNET::JSocketStatus::isReady ( ) const
inlineinherited

Check ready status.

Returns
true if ready; else false

Definition at line 76 of file JSocketStatus.hh.

77  {
78  return status == IO_READY;
79  }

◆ getCounter()

int JNET::JSocketStatus::getCounter ( ) const
inlineinherited

Get number of I/O attempts.

Returns
number of I/O attempts

Definition at line 87 of file JSocketStatus.hh.

88  {
89  return counter;
90  }

◆ setStatus()

void JNET::JSocketStatus::setStatus ( const JStatus_t  status)
inlineprotectedinherited

Set status of I/O.

Parameters
statusstatus

Definition at line 109 of file JSocketStatus.hh.

110  {
111  this->status = status;
112  }

Member Data Documentation

◆ __data

template<class JElement_t >
JElement_t* JNET::JSocketBuffer< JElement_t >::__data
protected

Definition at line 104 of file JSocketNonblocking.hh.

◆ __size

template<class JElement_t >
int JNET::JSocketBuffer< JElement_t >::__size
protected

Definition at line 105 of file JSocketNonblocking.hh.

◆ status

JStatus_t JNET::JSocketStatus::status
protectedinherited

Definition at line 115 of file JSocketStatus.hh.

◆ counter

int JNET::JSocketStatus::counter
protectedinherited

Definition at line 116 of file JSocketStatus.hh.


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