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 // IPPL include fiels 00027 #include "IpplPaws/PawsDataConnect.h" 00028 #include "DataSource/StringDataSource.h" 00029 #include "Utility/IpplInfo.h" 00030 #include "Utility/Pstring.h" 00031 00032 // PAWS include files 00033 #include "Paws/Paws.h" 00034 00035 00037 // constructor: the name, the connection, the transfer method, 00038 // the scalar to connect, and the parent node. 00039 template <class T> 00040 PawsStringDataSource<T>::PawsStringDataSource(const char *nm, 00041 DataConnect *dc, 00042 int tm, 00043 StringDataSource<T>& S) 00044 : DataSourceObject(nm, &S, dc, tm), stringDataSource(S) { 00045 00046 myString = S.stringPtr(); 00047 stringLen = S.stringLen(); 00048 00049 string filestring = "paws"; 00050 if (string(dc->ID()) != filestring) { 00051 ERRORMSG("Illegal DataConnect object for Paws Data Object." << endl); 00052 Connection = 0; 00053 } else { 00054 // get the data connection pointer for a PAWS connection 00055 pdc = (PawsDataConnect *)dc; 00056 00057 // create a PawsStringData which contains the representation (this stores 00058 // the domain information, about how many blocks there are and what their 00059 // domains are) and the descriptor (this manages the actual data storage) 00060 00061 // figure out the transfer method 00062 if (TransferMethod == DataSource::DEFAULT) 00063 TransferMethod = dc->getDefaultTransferMethod(); 00064 00065 int mode = PAWS_OUT; 00066 00067 if (TransferMethod == DataSource::INPUT) 00068 mode = PAWS_IN; 00069 else if (TransferMethod == DataSource::OUTPUT) 00070 mode = PAWS_OUT; 00071 else if (TransferMethod == DataSource::BOTH) 00072 mode = PAWS_INOUT; 00073 00074 // create a PawsStringData object, the main interface from the string 00075 // to the PAWS data transfer capabilities. It contains a representation, 00076 // descriptor, and PawsData object. The representation and descriptor 00077 // objects are used to get the domain and storage information, to calculate 00078 // send/receive schedules, and to pack and unpack data during transfers. 00079 pawsdata = new PawsStringData<T>( 00080 nm, // name 00081 myString, // pointer to data 00082 stringLen, // length 00083 mode, // transfer mode 00084 PAWS_SYNC, // sync mode 00085 *(pdc->getPawsApp())); // pointer to PAWS 00086 00087 } 00088 } 00089 00090 00092 // destructor 00093 template <class T> 00094 PawsStringDataSource<T>::~PawsStringDataSource() { 00095 myString = 0; 00096 delete pawsdata; 00097 } 00098 00099 00101 // Update the object, that is, make sure the receiver of the data has a 00102 // current and consistent snapshot of the current state. Return success. 00103 template <class T> 00104 bool PawsStringDataSource<T>::update() { 00105 00106 if (TransferMethod == DataSource::OUTPUT || 00107 TransferMethod == DataSource::BOTH) { 00108 pawsdata->send(); 00109 } else if (TransferMethod == DataSource::INPUT || 00110 TransferMethod == DataSource::BOTH) { 00111 pawsdata->receive(); 00112 } 00113 00114 return true; 00115 } 00116 00117 00119 // Indicate to the receiver that we're allowing them time to manipulate the 00120 // data (e.g., for a viz program, to rotate it, change representation, etc.) 00121 // This should only return when the manipulation is done. 00122 template <class T> 00123 void PawsStringDataSource<T>::interact(const char *) { 00124 pdc->poll(); 00125 } 00126 00127 00128 /*************************************************************************** 00129 * $RCSfile: PawsStringDataSource.cpp,v $ $Author: adelmann $ 00130 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:32 $ 00131 * IPPL_VERSION_ID: $Id: PawsStringDataSource.cpp,v 1.1.1.1 2003/01/23 07:40:32 adelmann Exp $ 00132 ***************************************************************************/