Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/DataSource/FilePtclAttribDataSource.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 // include files
00027 #include "DataSource/FilePtclAttribDataSource.h"
00028 #include "DataSource/FileDataConnect.h"
00029 #include "Utility/DiscParticle.h"
00030 #include "Utility/IpplInfo.h"
00031 #include "Utility/Pstring.h"
00032 #include "Profile/Profiler.h"
00033 
00034 
00036 // constructor: the name, the connection, the transfer method,
00037 // the particlebase to connect
00038 template<class T>
00039 FileParticleAttribDataSource<T>::FileParticleAttribDataSource(const char *nm,
00040                                                               DataConnect *dc,
00041                                                               int tm,
00042                                                           ParticleAttrib<T>& P)
00043   : DataSourceObject(nm,&P,dc,tm), MyParticles(P), DP(0), counter(0) {
00044 
00045   TAU_TYPE_STRING(taustr, "void (char *, DataConnect *, int, " + CT(P) + " )");
00046   TAU_PROFILE("FileParticleAttribDataSource::FileParticleAttribDataSource()",
00047               taustr, TAU_PARTICLE);
00048 
00049   string filestring = "file";
00050   if (string(dc->ID()) != filestring) {
00051     ERRORMSG("Illegal DataConnect object for FILE Data Object." << endl);
00052     Connection = 0;
00053   } else if (tm != DataSource::OUTPUT && tm != DataSource::INPUT) {
00054     ERRORMSG("FILE connections may only be of type INPUT or OUTPUT." << endl);
00055     Connection = 0;
00056   } else {
00057     FileDataConnect *fdc = (FileDataConnect *)dc;
00058     int dptm = (TransferMethod == DataSource::OUTPUT ?
00059                 DiscParticle::OUTPUT : DiscParticle::INPUT);
00060     DP = new DiscParticle(nm, dc->name(), dptm, fdc->getTypeString());
00061   }
00062 }
00063 
00064 
00066 // destructor
00067 template<class T>
00068 FileParticleAttribDataSource<T>::~FileParticleAttribDataSource() {
00069   TAU_TYPE_STRING(taustr, CT(*this) + " void ()" );
00070   TAU_PROFILE("FileParticleAttribDataSource::~FileParticleAttribDataSource()",
00071               taustr, TAU_PARTICLE);
00072 
00073   if (DP != 0)
00074     delete DP;
00075 }
00076 
00077 
00079 // Update the object, that is, make sure the receiver of the data has a
00080 // current and consistent snapshot of the current state.  Return success.
00081 template<class T>
00082 bool FileParticleAttribDataSource<T>::update() {
00083   TAU_TYPE_STRING(taustr, CT(*this) + " void ()" );
00084   TAU_PROFILE("FileParticleAttribDataSource::update()",
00085               taustr, TAU_PARTICLE);
00086 
00087   if (TransferMethod == DataSource::OUTPUT)
00088     return DP->write(MyParticles);
00089   else if (TransferMethod == DataSource::INPUT)
00090     return DP->read(MyParticles, counter++);
00091   else
00092     return false;
00093 }
00094 
00095 
00097 // Indicate to the receiver that we're allowing the connection time to
00098 // manipulate the data (e.g., for a viz program, to rotate it, change
00099 // representation, etc.).
00100 // This should only return when the manipulation is done.
00101 template<class T>
00102 void FileParticleAttribDataSource<T>::interact(const char *) {}
00103 
00104 
00105 /***************************************************************************
00106  * $RCSfile: FilePtclAttribDataSource.cpp,v $   $Author: adelmann $
00107  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:25 $
00108  * IPPL_VERSION_ID: $Id: FilePtclAttribDataSource.cpp,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $ 
00109  ***************************************************************************/

Generated on Fri Nov 2 01:25:55 2007 for IPPL by doxygen 1.3.5