EventHelix.com: CASE Tools; Real-time and Embedded System Design; Object Oriented Design EventStudio 2.0: System Engineering CASE ToolEventStudio 2.5
Sequence diagram based system design and modeling
Home   What's New   EventStudio 2.5   Real-time Mantra   Thought Projects   Contact Us
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Packet_Queue.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #ifndef PACKET_QUEUE_H
00010 #define PACKET_QUEUE_H
00011 
00012 #include <queue>           // STL header file for queue
00013 #include <list>
00014 using namespace std;       // Specify that we are using the std namespace
00015 
00028 
00029 template <class Packet> class Packet_Queue
00030 {
00033    typedef queue<Packet *, list<Packet *> > Packet_Queue_Type;
00034 
00036    Packet_Queue_Type m_packet_Queue;
00037       
00038 public:
00045    void Add(Packet *p_Packet)
00046    {
00047       // Insert the element at the end of the queue
00048       m_packet_Queue.push(p_Packet);
00049    }
00050    
00060 
00061    Packet *Remove()
00062    {
00063       Packet *p_Packet = NULL;
00064       
00065       // Check if the message queue is not empty
00066       if (!m_packet_Queue.empty())
00067       {
00068          // Queue is not empty so get a pointer to the
00069          // first message in the queue
00070          p_Packet = m_packet_Queue.front();
00071          
00072          // Now remove the pointer from the message queue
00073          m_packet_Queue.pop();
00074       }
00075       return p_Packet;
00076    }
00077    
00081    size_t Get_Length() const
00082    {
00083       return m_packet_Queue.size();
00084    }   
00085 };
00086 #endif

Generated on Sun Feb 13 21:30:16 2005 for Object Oriented Design Examples by doxygen 1.3.4
 Home   What's New   EventStudio 2.5   Real-time Mantra   Thought Projects   Contact Us
Copyright © 2000-2005 EventHelix.com Inc. All Rights Reserved.