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