OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
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
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>
38  DataConnect *dc,
39  int tm,
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 ?
54  DP = new DiscParticle(nm, dc->name(), dptm, fdc->getTypeString());
55  }
56 }
57 
58 
60 // destructor
61 template<class T>
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>
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>
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  ***************************************************************************/
#define ERRORMSG(msg)
Definition: IpplInfo.h:399
const char * name() const
Definition: NamedObj.h:35
DataConnect * Connection
const char * DSID() const
Definition: DataConnect.h:55
FileParticleAttribDataSource(const char *, DataConnect *, int, ParticleAttrib< T > &)
const char * getTypeString() const
virtual void interact(const char *=0)
Inform & endl(Inform &inf)
Definition: Inform.cpp:42