OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
ippl
src
DataSource
FilePtclAttribDataSource.hpp
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
#include "
DataSource/FilePtclAttribDataSource.h
"
28
#include "
DataSource/FileDataConnect.h
"
29
#include "
Utility/DiscParticle.h
"
30
#include "
Utility/IpplInfo.h
"
31
32
34
// constructor: the name, the connection, the transfer method,
35
// the particlebase to connect
36
template
<
class
T>
37
FileParticleAttribDataSource<T>::FileParticleAttribDataSource
(
const
char
*nm,
38
DataConnect
*dc,
39
int
tm,
40
ParticleAttrib<T>
& P)
41
:
DataSourceObject
(nm,&P,dc,tm), DP(0), MyParticles(P), counter(0) {
42
43
std::string filestring =
"file"
;
44
if
(std::string(dc->
DSID
()) != filestring) {
45
ERRORMSG
(
"Illegal DataConnect object for FILE Data Object."
<<
endl
);
46
Connection
= 0;
47
}
else
if
(tm !=
DataSource::OUTPUT
&& tm !=
DataSource::INPUT
) {
48
ERRORMSG
(
"FILE connections may only be of type INPUT or OUTPUT."
<<
endl
);
49
Connection
= 0;
50
}
else
{
51
FileDataConnect
*fdc = (
FileDataConnect
*)dc;
52
int
dptm = (
TransferMethod
==
DataSource::OUTPUT
?
53
DiscParticle::OUTPUT
:
DiscParticle::INPUT
);
54
DP
=
new
DiscParticle
(nm, dc->
name
(), dptm, fdc->
getTypeString
());
55
}
56
}
57
58
60
// destructor
61
template
<
class
T>
62
FileParticleAttribDataSource<T>::~FileParticleAttribDataSource
() {
63
64
if
(DP != 0)
65
delete
DP;
66
}
67
68
70
// Update the object, that is, make sure the receiver of the data has a
71
// current and consistent snapshot of the current state. Return success.
72
template
<
class
T>
73
bool
FileParticleAttribDataSource<T>::update
() {
74
75
if
(TransferMethod ==
DataSource::OUTPUT
)
76
return
DP->write(MyParticles);
77
else
if
(TransferMethod ==
DataSource::INPUT
)
78
return
DP->read(MyParticles, counter++);
79
else
80
return
false
;
81
}
82
83
85
// Indicate to the receiver that we're allowing the connection time to
86
// manipulate the data (e.g., for a viz program, to rotate it, change
87
// representation, etc.).
88
// This should only return when the manipulation is done.
89
template
<
class
T>
90
void
FileParticleAttribDataSource<T>::interact
(
const
char
*) {}
91
92
93
/***************************************************************************
94
* $RCSfile: FilePtclAttribDataSource.cpp,v $ $Author: adelmann $
95
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
96
* IPPL_VERSION_ID: $Id: FilePtclAttribDataSource.cpp,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
97
***************************************************************************/
FilePtclAttribDataSource.h
FileDataConnect.h
endl
Inform & endl(Inform &inf)
Definition
Inform.cpp:42
IpplInfo.h
ERRORMSG
#define ERRORMSG(msg)
Definition
IpplInfo.h:350
DiscParticle.h
DataConnect
Definition
DataConnect.h:32
DataConnect::DSID
const char * DSID() const
Definition
DataConnect.h:55
DataSource::OUTPUT
@ OUTPUT
Definition
DataSource.h:64
DataSource::INPUT
@ INPUT
Definition
DataSource.h:64
DataSourceObject
Definition
DataSourceObject.h:53
DataSourceObject::Connection
DataConnect * Connection
Definition
DataSourceObject.h:98
DataSourceObject::TransferMethod
int TransferMethod
Definition
DataSourceObject.h:107
FileDataConnect
Definition
FileDataConnect.h:25
FileDataConnect::getTypeString
const char * getTypeString() const
Definition
FileDataConnect.h:49
FileParticleAttribDataSource::DP
DiscParticle * DP
Definition
FilePtclAttribDataSource.h:57
FileParticleAttribDataSource::FileParticleAttribDataSource
FileParticleAttribDataSource(const char *, DataConnect *, int, ParticleAttrib< T > &)
Definition
FilePtclAttribDataSource.hpp:37
FileParticleAttribDataSource::interact
virtual void interact(const char *=0)
Definition
FilePtclAttribDataSource.hpp:90
FileParticleAttribDataSource::~FileParticleAttribDataSource
virtual ~FileParticleAttribDataSource()
Definition
FilePtclAttribDataSource.hpp:62
FileParticleAttribDataSource::update
virtual bool update()
Definition
FilePtclAttribDataSource.hpp:73
ParticleAttrib
Definition
ParticleAttrib.h:100
DiscParticle
Definition
DiscParticle.h:30
DiscParticle::INPUT
@ INPUT
Definition
DiscParticle.h:35
DiscParticle::OUTPUT
@ OUTPUT
Definition
DiscParticle.h:35
NamedObj::name
const char * name() const
Definition
NamedObj.h:35
Generated on Tue Apr 14 2026 07:18:43 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.8