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
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
unix-fd-reader.h
Go to the documentation of this file.
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)
Start a new read thread.
Definition:
unix-fd-reader.cc:54
ns3::FdReader::DestroyEvent
void DestroyEvent(void)
Definition:
unix-fd-reader.cc:106
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::~FdReader
virtual ~FdReader()
Definition:
unix-fd-reader.cc:48
system-thread.h
ns3::FdReader::m_readCallback
Callback< void, uint8_t *, ssize_t > m_readCallback
Definition:
unix-fd-reader.h:103
ns3::FdReader::m_stop
bool m_stop
Definition:
unix-fd-reader.h:106
ns3::FdReader::Run
void Run(void)
Definition:
unix-fd-reader.cc:155
ns3::FdReader
A class that asynchronously reads from a file descriptor.
Definition:
unix-fd-reader.h:40
callback.h
ns3::FdReader::Stop
void Stop(void)
Stop the read thread and reset internal state.
Definition:
unix-fd-reader.cc:113
ns3::FdReader::m_readThread
Ptr< SystemThread > m_readThread
Definition:
unix-fd-reader.h:104
ns3::FdReader::m_fd
int m_fd
The file descriptor to read from.
Definition:
unix-fd-reader.h:96
ns3::FdReader::FdReader
FdReader()
Definition:
unix-fd-reader.cc:39
ns3::FdReader::Data::m_buf
uint8_t * m_buf
Definition:
unix-fd-reader.h:72
ns3::FdReader::m_destroyEvent
EventId m_destroyEvent
Definition:
unix-fd-reader.h:107
ns3::FdReader::Data::Data
Data(uint8_t *buf, ssize_t len)
Definition:
unix-fd-reader.h:71
ns3::FdReader::Data::Data
Data()
Definition:
unix-fd-reader.h:70
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::FdReader::m_evpipe
int m_evpipe[2]
Definition:
unix-fd-reader.h:105
event-id.h
ns3::SimpleRefCount
A template-based reference counting class.
Definition:
simple-ref-count.h:64
ns3::FdReader::Data::m_len
ssize_t m_len
Definition:
unix-fd-reader.h:73
src
core
model
unix-fd-reader.h
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6