ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
file-usage.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 FILE_USAGE_H
22
#define FILE_USAGE_H
23
24
namespace
ns3 {
25
26
class
UnixFd;
27
33
class
FileUsage
34
{
35
public
:
36
FileUsage
(
int
fd,
UnixFd
*file);
37
~FileUsage
();
38
39
// a new thread is using the corresponding UnixFd.
40
void
IncUsage
();
41
// Remove one and return true if count == 0 and closing = true
42
bool
DecUsage
();
43
44
// Return true if m_count == 0 else position closing to true.
45
bool
CanForget
();
46
47
// Inc count and return file reference
48
UnixFd
*
GetFileInc
();
49
50
// Return the file
51
UnixFd
*
GetFile
()
const
;
52
53
// Return true the close was already called for the corresponding fd.
54
bool
IsClosed
()
const
;
55
56
// When a process finish we can forget all usage count
57
void
NullifyUsage
();
58
59
private
:
60
int
m_count
;
61
int
const
m_fd
;
62
UnixFd
*
const
m_file
;
63
bool
m_closing
;
64
};
65
66
}
67
68
#endif // FILE_USAGE_H
model
file-usage.h
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2