00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00037
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
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
00080
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
00098
00099
00100
00101 template<class T>
00102 void FileParticleAttribDataSource<T>::interact(const char *) {}
00103
00104
00105
00106
00107
00108
00109