OPAL (Object Oriented Parallel Accelerator Library)
2022.1
OPAL
src
ippl
src
Utility
DiscBuffer.cpp
Go to the documentation of this file.
1
// -*- C++ -*-
2
/***************************************************************************
3
*
4
* The IPPL Framework
5
*
6
* This program was prepared by PSI.
7
* All rights in the program are reserved by PSI.
8
* Neither PSI nor the author(s)
9
* makes any warranty, express or implied, or assumes any liability or
10
* responsibility for the use of this software
11
*
12
* Visit www.amas.web.psi for more details
13
*
14
***************************************************************************/
15
16
// -*- C++ -*-
17
/***************************************************************************
18
*
19
* The IPPL Framework
20
*
21
*
22
* Visit http://people.web.psi.ch/adelmann/ for more details
23
*
24
***************************************************************************/
25
26
// include files
27
28
#include "
Utility/DiscBuffer.h
"
29
#include "
Utility/PAssert.h
"
30
#include <cstdlib>
31
32
34
// Method definitions for DiscBuffer
36
37
// Static storage
38
39
long
DiscBuffer::size_s
= 0;
40
char
*
DiscBuffer::buffer_s
= 0;
41
42
// Some static variables used for statistics, these are really
43
// hacks so don't count on them.
44
45
double
DiscBuffer::readtime
= 0.0;
46
double
DiscBuffer::writetime
= 0.0;
47
long
DiscBuffer::readbytes
= 0;
48
long
DiscBuffer::writebytes
= 0;
49
50
52
// The default constructor does nothing, this class is mainly an
53
// interface to the static data.
54
55
DiscBuffer::DiscBuffer
()
56
{
57
}
58
59
61
// The destructor will delete the buffer storage if it has been
62
// previously created.
63
64
DiscBuffer::~DiscBuffer
()
65
{
66
if
(
buffer_s
!= 0)
67
delete
[]
buffer_s
;
68
69
size_s
= 0;
70
buffer_s
= 0;
71
}
72
73
75
// Make sure the current buffer is at least as large as the given
76
// size. If it is not, reallocate (but do not copy). In either case,
77
// return the buffer pointer.
78
79
void
*
DiscBuffer::resize
(
long
sz)
80
{
81
PAssert_GE
(sz, 0);
82
83
if
(sz >
size_s
)
84
{
85
// Reset our existing size
86
size_s
= sz;
87
88
// Free the old buffer, if necessary, and create a new one
89
if
(
buffer_s
!= 0)
90
{
91
delete
[]
buffer_s
;
92
buffer_s
= 0;
93
}
94
buffer_s
=
new
char
[
size_s
];
95
PAssert
(
buffer_s
);
96
}
97
98
return
buffer
();
99
}
100
101
103
// Create a single global instance of a DiscBuffer so that something
104
// will delete the storage when it is done.
105
106
DiscBuffer
ipplGlobalDiscBuffer_g
;
107
108
109
/***************************************************************************
110
* $RCSfile: DiscBuffer.cpp,v $ $Author: adelmann $
111
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
112
* IPPL_VERSION_ID: $Id: DiscBuffer.cpp,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
113
***************************************************************************/
ipplGlobalDiscBuffer_g
DiscBuffer ipplGlobalDiscBuffer_g
Definition:
DiscBuffer.cpp:106
DiscBuffer.h
PAssert.h
PAssert
#define PAssert(c)
Definition:
PAssert.h:102
PAssert_GE
#define PAssert_GE(a, b)
Definition:
PAssert.h:109
DiscBuffer
Definition:
DiscBuffer.h:30
DiscBuffer::writebytes
static long writebytes
Definition:
DiscBuffer.h:85
DiscBuffer::writetime
static double writetime
Definition:
DiscBuffer.h:83
DiscBuffer::~DiscBuffer
~DiscBuffer()
Definition:
DiscBuffer.cpp:64
DiscBuffer::buffer
static void * buffer()
Definition:
DiscBuffer.h:55
DiscBuffer::readbytes
static long readbytes
Definition:
DiscBuffer.h:84
DiscBuffer::size_s
static long size_s
Definition:
DiscBuffer.h:90
DiscBuffer::DiscBuffer
DiscBuffer()
Definition:
DiscBuffer.cpp:55
DiscBuffer::buffer_s
static char * buffer_s
Definition:
DiscBuffer.h:94
DiscBuffer::readtime
static double readtime
Definition:
DiscBuffer.h:82
DiscBuffer::resize
static void * resize(long sz)
Definition:
DiscBuffer.cpp:79
Generated on Thu Oct 20 2022 17:40:08 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.3