Panda3D
subfileInfo.I
1 // Filename: subfileInfo.I
2 // Created by: drose (20Jun11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: SubfileInfo::Default Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE SubfileInfo::
22 SubfileInfo() :
23  _start(0),
24  _size(0)
25 {
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: SubfileInfo::Constructor
30 // Access: Published
31 // Description:
32 ////////////////////////////////////////////////////////////////////
33 INLINE SubfileInfo::
34 SubfileInfo(const FileReference *file, streampos start, streamsize size) :
35  _file(file),
36  _start(start),
37  _size(size)
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: SubfileInfo::Constructor
43 // Access: Published
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 INLINE SubfileInfo::
47 SubfileInfo(const Filename &filename, streampos start, streamsize size) :
48  _file(new FileReference(filename)),
49  _start(start),
50  _size(size)
51 {
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: SubfileInfo::Copy Constructor
56 // Access: Published
57 // Description:
58 ////////////////////////////////////////////////////////////////////
59 INLINE SubfileInfo::
60 SubfileInfo(const SubfileInfo &copy) :
61  _file(copy._file),
62  _start(copy._start),
63  _size(copy._size)
64 {
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: SubfileInfo::Copy Assignment Operator
69 // Access: Published
70 // Description:
71 ////////////////////////////////////////////////////////////////////
72 INLINE void SubfileInfo::
73 operator = (const SubfileInfo &copy) {
74  _file = copy._file;
75  _start = copy._start;
76  _size = copy._size;
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: SubfileInfo::is_empty
81 // Access: Published
82 // Description: Returns true if this SubfileInfo doesn't define any
83 // file, false if it has real data.
84 ////////////////////////////////////////////////////////////////////
85 INLINE bool SubfileInfo::
86 is_empty() const {
87  return _file == (FileReference *)NULL;
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: SubfileInfo::get_file
92 // Access: Published
93 // Description: Returns the FileReference that represents this file.
94 ////////////////////////////////////////////////////////////////////
95 INLINE const FileReference *SubfileInfo::
96 get_file() const {
97  return _file;
98 }
99 
100 ////////////////////////////////////////////////////////////////////
101 // Function: SubfileInfo::get_filename
102 // Access: Published
103 // Description: A shortcut to the filename.
104 ////////////////////////////////////////////////////////////////////
105 INLINE const Filename &SubfileInfo::
106 get_filename() const {
107  if (_file != (FileReference *)NULL) {
108  return _file->get_filename();
109  }
110  static const Filename empty_filename;
111  return empty_filename;
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: SubfileInfo::get_start
116 // Access: Published
117 // Description: Returns the offset within the file at which this file
118 // data begins.
119 ////////////////////////////////////////////////////////////////////
120 INLINE streampos SubfileInfo::
121 get_start() const {
122  return _start;
123 }
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: SubfileInfo::get_size
127 // Access: Published
128 // Description: Returns the number of consecutive bytes, beginning at
129 // get_start(), that correspond to this file data.
130 ////////////////////////////////////////////////////////////////////
131 INLINE streamsize SubfileInfo::
132 get_size() const {
133  return _size;
134 }
135 
136 INLINE ostream &
137 operator << (ostream &out, const SubfileInfo &info) {
138  info.output(out);
139  return out;
140 }
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:29
const FileReference * get_file() const
Returns the FileReference that represents this file.
Definition: subfileInfo.I:96
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
bool is_empty() const
Returns true if this SubfileInfo doesn&#39;t define any file, false if it has real data.
Definition: subfileInfo.I:86
const Filename & get_filename() const
A shortcut to the filename.
Definition: subfileInfo.I:106
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:29
streampos get_start() const
Returns the offset within the file at which this file data begins.
Definition: subfileInfo.I:121
streamsize get_size() const
Returns the number of consecutive bytes, beginning at get_start(), that correspond to this file data...
Definition: subfileInfo.I:132