Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

cyclic_buffer.h

Go to the documentation of this file.
00001 /*! \file cyclic_buffer.h
00002     Header file for cyclic_buffer.c
00003  */
00004 
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008 
00009 
00010 #ifndef CYCLIC_BUFFER_HD
00011 
00012 
00013 #include <stdlib.h>
00014 #include <string.h>
00015 
00016 
00017   /* ========================================================== */
00018   /* Data structure                                             */
00019   /* ========================================================== */
00020 
00021   /*! \brief Basic structure that defines the cyclic buffer. 
00022    */
00023   struct s_cyclic_buffer {
00024                            /*! \brief Array of pointers to (void*), each element points to an item of the buffer. */
00025                            void           **buffer;
00026 
00027                            /*! \brief Maximum number of elements in the buffer. */
00028                            unsigned long  size;
00029 
00030                            /*! \brief Index to the first item in the cyclic buffer. */
00031                            unsigned long  start;
00032 
00033                            /*! \brief Index to the last item in the cyclic buffer. */
00034                            unsigned long  stop;
00035 
00036                            /*! \brief Pointer to the current index. */
00037                            unsigned long  current;
00038 
00039                            /*! \brief Current number of element in the buffer (from 0 to 'size'). */ 
00040                            unsigned long  current_size;
00041 
00042                            /*! \brief Current number of element extracted (this is used by get_element()). */
00043                            unsigned long  n;
00044 
00045                          };
00046 
00047   typedef struct s_cyclic_buffer* cyclic_buffer;
00048 
00049 
00050   /* ========================================================== */
00051   /* Buffer functions                                           */
00052   /* ========================================================== */
00053 
00054   cyclic_buffer create_cyclic_buffer (unsigned long size);
00055   void destroy_cyclic_buffer (cyclic_buffer buffer);
00056   void* cyclic_buffer_add_element (cyclic_buffer buffer, void* element, unsigned element_size);
00057   void rewind_cyclic_buffer (cyclic_buffer buffer);
00058   void* cyclic_buffer_get_element(cyclic_buffer buffer);
00059   unsigned long cyclic_buffer_get_start(cyclic_buffer buffer);
00060   unsigned long cyclic_buffer_get_stop(cyclic_buffer buffer);
00061   unsigned long cyclic_buffer_get_current_size(cyclic_buffer buffer);
00062 
00063   #define CYCLIC_BUFFER_HD
00064 #endif
00065 
00066 
00067 #ifdef __cplusplus
00068 }
00069 #endif
00070 

Generated on Thu Apr 3 16:23:42 2003 for Common_C_libraries by doxygen1.3-rc1