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 #include <iostream.h>
00027 #include "IpplPaws/PawsFieldDataSource.h"
00028 #include "IpplPaws/PawsFieldData.h"
00029 #include "IpplPaws/PawsDataConnect.h"
00030 #include "Message/Communicate.h"
00031 #include "Utility/IpplInfo.h"
00032 #include "Utility/Pstring.h"
00033
00034
00035 #include "Paws/Paws.h"
00036
00038
00039
00040 template<class T, unsigned Dim, class M, class C>
00041 PawsFieldDataSource<T,Dim,M,C>::PawsFieldDataSource(const char *nm,
00042 DataConnect *dc,
00043 int tm,
00044 Field_t &F)
00045 : DataSourceObject(nm, &F, dc, tm), myField(F) {
00046
00047 string filestring = "paws";
00048 if (string(dc->ID()) != filestring) {
00049 ERRORMSG("Illegal DataConnect object for Paws Data Object." << endl);
00050 Connection = 0;
00051 } else {
00052
00053 pdc = (PawsDataConnect *)dc;
00054
00055
00056 if (TransferMethod == DataSource::DEFAULT)
00057 TransferMethod = dc->getDefaultTransferMethod();
00058
00059 int mode = PAWS_OUT;
00060
00061 if (TransferMethod == DataSource::INPUT)
00062 mode = PAWS_IN;
00063 else if (TransferMethod == DataSource::OUTPUT)
00064 mode = PAWS_OUT;
00065 else if (TransferMethod == DataSource::BOTH)
00066 mode = PAWS_INOUT;
00067
00068
00069
00070
00071
00072
00073 pawsdata = new PawsFieldData_t(nm, &F, mode,
00074 PAWS_SYNC, PAWS_COLUMN,
00075 *(pdc->getPawsApp()));
00076 }
00077 }
00078
00079
00081
00082 template<class T, unsigned Dim, class M, class C>
00083 PawsFieldDataSource<T,Dim,M,C>::~PawsFieldDataSource() {
00084
00085
00086
00087
00088 if (pawsdata != 0 && pdc != 0) {
00089
00090
00091 pdc->barrier();
00092 delete pawsdata;
00093 }
00094
00095 }
00096
00097
00099
00100
00101 template<class T, unsigned Dim, class M, class C>
00102 bool PawsFieldDataSource<T,Dim,M,C>::update() {
00103
00104 pdc->barrier();
00105
00106 if (TransferMethod == DataSource::OUTPUT ||
00107 TransferMethod == DataSource::BOTH) {
00108
00109 pawsdata->send();
00110
00111 } else if (TransferMethod == DataSource::INPUT ||
00112 TransferMethod == DataSource::BOTH) {
00113
00114 pawsdata->receive();
00115 }
00116
00117 return true;
00118 }
00119
00120
00122
00123
00124
00125 template<class T, unsigned Dim, class M, class C>
00126 void PawsFieldDataSource<T,Dim,M,C>::interact(const char *) {
00127 pdc->poll();
00128 }
00129
00130
00131
00132
00133
00134
00135