VTK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
home
demarle
Builds
VTK
release
Utilities
Doxygen
dox
IO
XMLParser
vtkXMLDataHeaderPrivate.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkXMLDataHeaderPrivate.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
15
16
#ifndef vtkXMLDataHeaderPrivate_DoNotInclude
17
# error "do not include unless you know what you are doing"
18
#endif
19
20
#ifndef vtkXMLDataHeaderPrivate_h
21
#define vtkXMLDataHeaderPrivate_h
22
23
#include "
vtkType.h
"
24
#include <vector>
25
26
// Abstract interface using type vtkTypeUInt64 to access an array
27
// of either vtkTypeUInt32 or vtkTypeUInt64. Shared by vtkXMLWriter
28
// and vtkXMLDataParser to write/read binary data headers.
29
class
vtkXMLDataHeader
30
{
31
public
:
32
virtual
void
Resize
(
size_t
count) = 0;
33
virtual
vtkTypeUInt64
Get
(
size_t
index
)
const
= 0;
34
virtual
bool
Set
(
size_t
index, vtkTypeUInt64
value
) = 0;
35
virtual
size_t
WordSize
()
const
= 0;
36
virtual
size_t
WordCount
()
const
= 0;
37
virtual
unsigned
char
*
Data
() = 0;
38
size_t
DataSize
()
const
{
return
this->
WordCount
()*this->
WordSize
(); }
39
virtual
~vtkXMLDataHeader
() {}
40
static
inline
vtkXMLDataHeader
*
New
(
int
width,
size_t
count);
41
};
42
43
template
<
typename
T>
44
class
vtkXMLDataHeaderImpl
:
public
vtkXMLDataHeader
45
{
46
std::vector<T> Header;
47
public
:
48
vtkXMLDataHeaderImpl
(
size_t
n): Header(n, 0) {}
49
virtual
void
Resize
(
size_t
count)
50
{ this->Header.resize(count, 0); }
51
virtual
vtkTypeUInt64
Get
(
size_t
index
)
const
52
{
return
this->Header[
index
]; }
53
virtual
bool
Set
(
size_t
index
, vtkTypeUInt64
value
)
54
{
55
this->Header[
index
] = T(value);
56
return
vtkTypeUInt64(this->Header[index]) ==
value
;
57
}
58
virtual
size_t
WordSize
()
const
{
return
sizeof
(T); }
59
virtual
size_t
WordCount
()
const
{
return
this->Header.size(); }
60
virtual
unsigned
char
*
Data
()
61
{
return
reinterpret_cast<
unsigned
char
*
>
(&this->Header[0]); }
62
};
63
64
vtkXMLDataHeader
*
vtkXMLDataHeader::New
(
int
width,
size_t
count)
65
{
66
switch
(width)
67
{
68
case
32:
return
new
vtkXMLDataHeaderImpl<vtkTypeUInt32>
(count);
69
case
64:
return
new
vtkXMLDataHeaderImpl<vtkTypeUInt64>
(count);
70
}
71
return
0;
72
}
73
74
#endif
75
// VTK-HeaderTest-Exclude: vtkXMLDataHeaderPrivate.h
vtkXMLDataHeaderImpl::WordCount
virtual size_t WordCount() const
Definition:
vtkXMLDataHeaderPrivate.h:59
vtkXMLDataHeader::New
static vtkXMLDataHeader * New(int width, size_t count)
Definition:
vtkXMLDataHeaderPrivate.h:64
vtkXMLDataHeader::~vtkXMLDataHeader
virtual ~vtkXMLDataHeader()
Definition:
vtkXMLDataHeaderPrivate.h:39
vtkXMLDataHeaderImpl::Resize
virtual void Resize(size_t count)
Definition:
vtkXMLDataHeaderPrivate.h:49
vtkXMLDataHeaderImpl::Set
virtual bool Set(size_t index, vtkTypeUInt64 value)
Definition:
vtkXMLDataHeaderPrivate.h:53
vtkXMLDataHeaderImpl
Definition:
vtkXMLDataHeaderPrivate.h:44
vtkXMLDataHeaderImpl::vtkXMLDataHeaderImpl
vtkXMLDataHeaderImpl(size_t n)
Definition:
vtkXMLDataHeaderPrivate.h:48
vtkXMLDataHeader::Set
virtual bool Set(size_t index, vtkTypeUInt64 value)=0
vtkXMLDataHeader
Definition:
vtkXMLDataHeaderPrivate.h:29
vtkXMLDataHeaderImpl::WordSize
virtual size_t WordSize() const
Definition:
vtkXMLDataHeaderPrivate.h:58
vtkXMLDataHeader::Resize
virtual void Resize(size_t count)=0
vtkXMLDataHeader::DataSize
size_t DataSize() const
Definition:
vtkXMLDataHeaderPrivate.h:38
vtkX3D::value
Definition:
vtkX3D.h:220
vtkXMLDataHeader::Data
virtual unsigned char * Data()=0
vtkType.h
vtkXMLDataHeaderImpl::Get
virtual vtkTypeUInt64 Get(size_t index) const
Definition:
vtkXMLDataHeaderPrivate.h:51
vtkXMLDataHeader::Get
virtual vtkTypeUInt64 Get(size_t index) const =0
vtkX3D::index
Definition:
vtkX3D.h:246
vtkXMLDataHeader::WordSize
virtual size_t WordSize() const =0
vtkXMLDataHeaderImpl::Data
virtual unsigned char * Data()
Definition:
vtkXMLDataHeaderPrivate.h:60
vtkXMLDataHeader::WordCount
virtual size_t WordCount() const =0
Generated by
1.8.9.1