rllib  1
rlfifo.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           rlfifo.h  -  description
00003                              -------------------
00004     begin                : Tue Jan 02 2001
00005     copyright            : (C) 2001 by Rainer Lehrig
00006     email                : lehrig@t-online.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as        *
00013  *   published by the Free Software Foundation                             *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef _RL_FIFO_H_
00017 #define _RL_FIFO_H_
00018 
00019 #include "rldefine.h"
00020 #include "rlthread.h"
00021 
00025 class rlFifo
00026 {
00027 private:
00028   typedef struct _MessageList_
00029   {
00030     char *mes;
00031     int  len;
00032     struct _MessageList_ *next;
00033   }MessageList;
00034 
00035 public:
00036   rlFifo(int maxmessages=0);
00037   virtual ~rlFifo();
00038 
00039   enum FifoEnum {
00040        DATA_AVAILABLE=-1, NO_DATA_AVAILABLE=-2, MESSAGE_TO_BIG=-3, FIFO_FULL=-4
00041   };
00042 
00043   int read(void *buf, int maxlen);
00044   int poll();
00045   int write(const void *buf, int len);
00046   int printf(const char *format, ...);
00047 
00048 private:
00049   int maxmes;
00050   int nmes;
00051   MessageList *list;
00052   WSEMAPHORE semaphore;
00053   pthread_mutex_t mutex;
00054 };
00055 
00056 #endif