ns-3 Direct Code Execution
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fifo-buffer.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Frederic Urbani <frederic.urbani@inria.fr>
19  *
20  */
21 #ifndef FIFO_BUFFER_H
22 #define FIFO_BUFFER_H
23 
24 #include <stdint.h>
25 #include <unistd.h>
26 
27 namespace ns3 {
29 {
30 public:
31  FifoBuffer (size_t mxSz);
32  ~FifoBuffer (void);
33 
34  ssize_t Write (uint8_t *buf, size_t len);
35  ssize_t Read (uint8_t *buf, size_t len);
36  ssize_t GetSize ();
37  ssize_t GetSpace ();
38 
39 private:
40  const size_t m_maxSize;
41  uint8_t *m_buffer;
42  size_t m_read;
43  size_t m_fill;
44  size_t m_size;
45 };
46 }
47 
48 #endif // FIFO_BUFFER_H