A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
unix-fd-reader.h
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 The Boeing Company
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: Tom Goff <thomas.goff@boeing.com>
19
*/
20
21
#ifndef UNIX_FD_READER_H
22
#define UNIX_FD_READER_H
23
24
#include <stdint.h>
25
26
#include "callback.h"
27
#include "system-thread.h"
28
#include "event-id.h"
29
30
namespace
ns3 {
31
40
class
FdReader
:
public
SimpleRefCount
<FdReader>
41
{
42
public
:
43
FdReader
();
44
virtual
~
FdReader
();
45
54
void
Start
(
int
fd,
Callback<void, uint8_t *, ssize_t>
readCallback);
55
60
void
Stop
(
void
);
61
62
protected
:
63
68
struct
Data
69
{
70
Data
() : m_buf (0), m_len (0) {}
71
Data
(uint8_t *buf, ssize_t len) : m_buf (buf), m_len (len) {}
72
uint8_t *m_buf;
73
ssize_t m_len;
74
};
75
90
virtual
FdReader::Data
DoRead
(
void
) = 0;
91
96
int
m_fd
;
97
98
private
:
99
100
void
Run (
void
);
101
void
DestroyEvent (
void
);
102
103
Callback<void, uint8_t *, ssize_t>
m_readCallback;
104
Ptr<SystemThread>
m_readThread;
105
int
m_evpipe[2];
// pipe used to signal events between threads
106
bool
m_stop;
// true means the read thread should stop
107
EventId
m_destroyEvent;
108
};
109
110
}
// namespace ns3
111
112
#endif
/* UNIX_FD_READER_H */
ns3::FdReader::Start
void Start(int fd, Callback< void, uint8_t *, ssize_t > readCallback)
Definition:
unix-fd-reader.cc:54
ns3::FdReader::Data
A structure representing data read.
Definition:
unix-fd-reader.h:68
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::Callback< void, uint8_t *, ssize_t >
ns3::FdReader
A class that asynchronously reads from a file descriptor.
Definition:
unix-fd-reader.h:40
ns3::FdReader::Stop
void Stop(void)
Definition:
unix-fd-reader.cc:113
ns3::FdReader::m_fd
int m_fd
The file descriptor to read from.
Definition:
unix-fd-reader.h:96
ns3::EventId
an identifier for simulation events.
Definition:
event-id.h:46
ns3::FdReader::DoRead
virtual FdReader::Data DoRead(void)=0
The read implementation.
ns3::SimpleRefCount
A template-based reference counting class.
Definition:
simple-ref-count.h:63
src
core
model
unix-fd-reader.h
Generated on Sun Mar 16 2014 11:25:02 for ns-3 by
1.8.6