src/IplPaws/PawsScalarDataSource.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 // IPPL include fiels
00027 #include "IpplPaws/PawsScalarDataSource.h"
00028 #include "IpplPaws/PawsDataConnect.h"
00029 #include "DataSource/ScalarDataSource.h"
00030 #include "Utility/IpplInfo.h"
00031 #include "Utility/Pstring.h"
00032 
00033 // PAWS include files
00034 #include "Paws/Paws.h"
00035 
00036 
00038 // constructor: the name, the connection, the transfer method,
00039 // the scalar to connect, and the parent node.
00040 template<class T>
00041 PawsScalarDataSource<T>::PawsScalarDataSource(const char *nm,
00042                                                     DataConnect *dc,
00043                                                     int tm,
00044                                                     ScalarDataSource<T>& S)
00045   : DataSourceObject(nm, &S, dc, tm),
00046     scalarDataSource(S), myScalar(S.scalarRef()), pawsdata(0), pdc(0)
00047 {
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 PawsScalarData which contains the representation
00058     // (this stores the domain information, about how many blocks there
00059     // are and what their domains are) and
00060     // the descriptor (this manages the actual data storage)
00061 
00062     // figure out the transfer method
00063     if (TransferMethod == DataSource::DEFAULT)
00064       TransferMethod = dc->getDefaultTransferMethod();
00065 
00066     int mode = PAWS_OUT;
00067 
00068     if (TransferMethod == DataSource::INPUT)
00069       mode = PAWS_IN;
00070     else if (TransferMethod == DataSource::OUTPUT)
00071       mode = PAWS_OUT;
00072     else if (TransferMethod == DataSource::BOTH)
00073       mode = PAWS_INOUT;
00074 
00075     // create a PawsScalarData object, the main interface from the scalar
00076     // to the PAWS data transfer capabilities.  It contains a representation,
00077     // descriptor, and PawsData object.  The representation and descriptor
00078     // objects are used to get the domain and storage information, to calculate
00079     // send/receive schedules, and to pack and unpack data during transfers.
00080     pawsdata = new PawsScalarData<T>(
00081                  nm,                   // name
00082                  &myScalar,            // pointer to data 
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 PawsScalarDataSource<T>::~PawsScalarDataSource() {
00095   if (pawsdata != 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 PawsScalarDataSource<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 PawsScalarDataSource<T>::interact(const char *) {
00124   pdc->poll();
00125 }
00126 
00127 
00128 /***************************************************************************
00129  * $RCSfile: PawsScalarDataSource.cpp,v $   $Author: adelmann $
00130  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:32 $
00131  * IPPL_VERSION_ID: $Id: PawsScalarDataSource.cpp,v 1.1.1.1 2003/01/23 07:40:32 adelmann Exp $ 
00132  ***************************************************************************/

Generated on Mon Jan 16 13:23:49 2006 for IPPL by  doxygen 1.4.6