CPacketQueue Class Reference

Implementation of platform (and stack) independent FIFO packet queue for objects of type CMessage. More...

#include <PacketQueue.h>

Inherits CLockMechanism.

Collaboration diagram for CPacketQueue:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CPacketQueue ()
virtual ~CPacketQueue ()
bool setQueueMaxsize (INT32 maxsize, UINT32 &lasterr)
 Adjust the Queue depth.
UINT32 getLastError ()
 Returns last error code happened.
bool pop_front (CMessage **obj, UINT32 &lasterr)
 Gets the first message (FIFO) out of the queue.
bool push_back (const CMessage *obj, UINT32 &lasterr)
 Appends a CMessage object to the end of the (FIFO) queue.
bool remove_elem (UINT16 requestid, UINT32 &lasterr)
bool find_elem (UINT16 requestid, CMessage **obj, UINT32 &lasterr)
bool find_and_remove_elem (UINT16 requestid, CMessage **obj, UINT32 &lasterr)
int size (UINT32 &lasterr)
bool find_elem_ack_and_signal (const CMessage &aAckPacket, UINT32 &lasterr)
bool find_and_remove_passed_elem (CMessage *obj, UINT32 &lasterr)
bool setQueueMaxsize (INT32 maxsize)
bool pop_front (CMessage **obj)
bool push_back (const CMessage *obj)
bool remove_elem (UINT16 requestid)
bool find_elem (UINT16 requestid, CMessage **obj)
bool find_and_remove_elem (UINT16 requestid, CMessage **obj)
int size ()
 Returns the current amount of elements stored in the queue.
bool find_elem_ack_and_signal (const CMessage &aAckPacket)
bool find_and_remove_passed_elem (CMessage *obj)

Private Attributes

INT32 m_iQueueFirstElement
INT32 m_iQueueLastElement
INT32 m_iQueueNumElements
VOIDP * m_pQueueValue
INT32 * m_iQueueNextElement
INT32 m_iQueueMaxSize
UINT32 m_iLastError

Friends

class CMessage


Detailed Description

Implementation of platform (and stack) independent FIFO packet queue for objects of type CMessage.

Using C++ STL this could be done much more easily, but implementation on Nios2 platform did not work (reason not fully known, stack issues suspected). This CPacketQueue was created as a slightly inferior, but working solution.

Implementation details:

Definition at line 25 of file PacketQueue.h.


Constructor & Destructor Documentation

CPacketQueue::CPacketQueue (  ) 

Definition at line 12 of file PacketQueue.cpp.

CPacketQueue::~CPacketQueue (  )  [virtual]

Definition at line 37 of file PacketQueue.cpp.


Member Function Documentation

bool CPacketQueue::setQueueMaxsize ( INT32  maxsize,
UINT32 &  lasterr 
)

Adjust the Queue depth.

This method adjusts the queue depth by reinitializing the queue pool. Any data accumulated in the queue might be lost after readjustment.

Parameters:
maxsize new 'queue depth'
lasterr unique error code
Return values:
true successfully readjusted to 'maxsize' depth
false failure, something happened (see lasterr) if lasterr ERR_PQ_LOCK, mutex locking failed
See also:
Network Queue Error Codes

Definition at line 122 of file PacketQueue.cpp.

Referenced by CNetworkQueue::CNetworkQueue(), and setQueueMaxsize().

Here is the call graph for this function:

Here is the caller graph for this function:

UINT32 CPacketQueue::getLastError (  ) 

Returns last error code happened.

for detailed list of possible error codes, see Declarations.h

See also:
Network Queue Error Codes

Definition at line 766 of file PacketQueue.cpp.

bool CPacketQueue::pop_front ( CMessage **  obj,
UINT32 &  lasterr 
)

Gets the first message (FIFO) out of the queue.

Parameters:
obj place to store extracted element (empty variable of type CMessage)
lasterr unique error code
Return values:
true successful, first element extracted and put to **obj
false failure, something happened (see lasterr)
Errorcodes:

Note:
This function contains assert() which gives more failure reasons during development/debugging.
See also:
Network Queue Error Codes

Definition at line 175 of file PacketQueue.cpp.

Referenced by CNetworkQueue::close(), pop_front(), CNetworkQueue::recvMsg(), and CNetworkQueue::SendProcessTask().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPacketQueue::push_back ( const CMessage obj,
UINT32 &  lasterr 
)

Appends a CMessage object to the end of the (FIFO) queue.

Parameters:
obj object reference to store
lasterr unique error code
Return values:
true successful, element reference to obj appended
false failure, something happened (see lasterr)
Errorcodes:

Note:
This function contains assert() which gives more failure reasons during development/debugging.
See also:
Network Queue Error Codes

Definition at line 237 of file PacketQueue.cpp.

Referenced by push_back(), CNetworkQueue::ReceiveProcessTask(), CNetworkQueue::sendMsgTo(), and CNetworkQueue::sendMsgToInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPacketQueue::remove_elem ( UINT16  requestid,
UINT32 &  lasterr 
)

This method traverses the queue, looks for a CMessage element that contains the 'requestid' and removes it.

Parameters:
requestid CMessage object's request id (this object will be removed from the queue if found)
lasterr unique error code
Return values:
true successful, element reference was removed
false failure, something happened (see lasterr)
Errorcodes:

Note:
This function contains assert() which gives more failure reasons during development/debugging.
See also:
Network Queue Error Codes

Definition at line 325 of file PacketQueue.cpp.

Referenced by remove_elem().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPacketQueue::find_elem ( UINT16  requestid,
CMessage **  obj,
UINT32 &  lasterr 
)

This method traverses the queue, looks for a CMessage element that contains the 'requestid' and returns it without removeing it.

Parameters:
requestid CMessage object's request id (this object will be returned if found)
obj place to store element, if found (empty variable of type CMessage *)
lasterr unique error code
Return values:
true successful, element is returned
false failure, something happened, element is NOT returned (see lasterr)
Errorcodes:

See also:
Network Queue Error Codes

Definition at line 426 of file PacketQueue.cpp.

Referenced by find_elem().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPacketQueue::find_and_remove_elem ( UINT16  requestid,
CMessage **  obj,
UINT32 &  lasterr 
)

This method traverses the queue, looks for a CMessage element that contains the 'requestid' and returns it. The object reference is removed from the queue.

Parameters:
requestid CMessage object's request id (this object will be returned if found)
obj place to store element, if found (empty variable of type CMessage *)
lasterr unique error code
Return values:
true successful, element is returned and removed from queue
false failure, something happened, element is NOT returned (see lasterr)
Errorcodes:

note\ This function contains assert() which gives more failure reasons during development/debugging.

See also:
Network Queue Error Codes

Definition at line 664 of file PacketQueue.cpp.

Referenced by find_and_remove_elem(), and CNetworkQueue::sendRecvMsg().

Here is the call graph for this function:

Here is the caller graph for this function:

int CPacketQueue::size ( UINT32 &  lasterr  ) 

Referenced by CNetworkQueue::close().

Here is the caller graph for this function:

bool CPacketQueue::find_elem_ack_and_signal ( const CMessage ack_packet,
UINT32 &  lasterr 
)

This method traverses the queue, looks for a CMessage element that matches the passed 'ack packet' and signals the attached semaphore in case a match is found.

This method is used in order to signal 'waiting to be ACKed' packets inside ReceiveProcessTask on successful reception of an ACK packet.

Parameters:
ack_packet CMessage object's ack_packet
lasterr unique error code
Return values:
true successful, element is returned
false failure, something happened, element is NOT returned (see lasterr)
Errorcodes:

Note:
In case of debug version a special assert is thrown in case the semaphore could not be signalled.
See also:
Network Queue Error Codes

Definition at line 493 of file PacketQueue.cpp.

Referenced by find_elem_ack_and_signal(), and CNetworkQueue::ReceiveProcessTask().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPacketQueue::find_and_remove_passed_elem ( CMessage obj,
UINT32 &  lasterr 
)

This method traverses the queue, looks for a CMessage element that matches the passed CMessage and, if found, removes the object reference from the queue.

Parameters:
obj a valid CMessage to look for inside the queue
lasterr unique error code
Return values:
true successful, element is returned and removed from queue
false failure, something happened, element is NOT returned (see lasterr)
Errorcodes:

Note:
This function contains assert() which gives more failure reasons during development/debugging.
See also:
Network Queue Error Codes

Definition at line 562 of file PacketQueue.cpp.

Referenced by find_and_remove_passed_elem(), and CNetworkQueue::sendMsgTo().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPacketQueue::setQueueMaxsize ( INT32  maxsize  ) 

Definition at line 47 of file PacketQueue.cpp.

Here is the call graph for this function:

bool CPacketQueue::pop_front ( CMessage **  obj  ) 

Definition at line 54 of file PacketQueue.cpp.

Here is the call graph for this function:

bool CPacketQueue::push_back ( const CMessage obj  ) 

Definition at line 61 of file PacketQueue.cpp.

Here is the call graph for this function:

bool CPacketQueue::remove_elem ( UINT16  requestid  ) 

Definition at line 68 of file PacketQueue.cpp.

Here is the call graph for this function:

bool CPacketQueue::find_elem ( UINT16  requestid,
CMessage **  obj 
)

Definition at line 75 of file PacketQueue.cpp.

Here is the call graph for this function:

bool CPacketQueue::find_and_remove_elem ( UINT16  requestid,
CMessage **  obj 
)

Definition at line 82 of file PacketQueue.cpp.

Here is the call graph for this function:

int CPacketQueue::size (  ) 

Returns the current amount of elements stored in the queue.

Return values:
>0 number of elements in queue
0 failure or queue is empty (see lasterr)

Definition at line 754 of file PacketQueue.cpp.

bool CPacketQueue::find_elem_ack_and_signal ( const CMessage aAckPacket  ) 

Definition at line 89 of file PacketQueue.cpp.

Here is the call graph for this function:

bool CPacketQueue::find_and_remove_passed_elem ( CMessage obj  ) 

Definition at line 96 of file PacketQueue.cpp.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class CMessage [friend]

Definition at line 27 of file PacketQueue.h.


Member Data Documentation

VOIDP* CPacketQueue::m_pQueueValue [private]

Definition at line 65 of file PacketQueue.h.

Referenced by CPacketQueue(), push_back(), and setQueueMaxsize().

UINT32 CPacketQueue::m_iLastError [private]


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

Generated on Wed Apr 16 18:22:16 2008 for NetworkQueue by  doxygen 1.5.5