00001 #ifndef __RVL_MPI_SERDC 00002 #define __RVL_MPI_SERDC 00003 00004 #define FRUITCAKE 00005 00006 #include "mpiserialfo.hh" 00007 #include "data.hh" 00008 00009 namespace RVL { 00010 00011 class MPISerialDCF; 00012 00013 class MPISerialDC: public DataContainer { 00014 00015 friend class MPISerialDCF; 00016 00017 private: 00018 00019 MPISerialDC(); 00020 MPISerialDC(MPISerialDC const &); 00021 00022 protected: 00023 00025 int rk; 00026 00028 DataContainer * mydc; 00029 00030 public: 00031 00035 MPISerialDC(DataContainerFactory const & F): rk(0), mydc(NULL) { 00036 /* set rank - all processes*/ 00037 #ifdef IWAVE_USE_MPI 00038 MPI_Comm_rank(MPI_COMM_WORLD,&rk); 00039 #endif 00040 /* construct internal PC */ 00041 if (rk==0) mydc=F.build(); 00042 } 00043 00044 ~MPISerialDC() { if (mydc) delete mydc; } 00045 00048 void eval(FunctionObject & f, 00049 std::vector<DataContainer const * > &x); 00050 00053 void eval(FunctionObjectConstEval & f, 00054 vector<DataContainer const *> & x) const; 00055 00056 ostream & write(ostream & str) const; 00057 }; 00058 00061 class MPISerialDCF: public DataContainerFactory { 00062 00063 private: 00064 00065 int rk; 00066 00068 DataContainerFactory const & f; 00069 00070 MPISerialDC * buildMPISerialDC() const; 00071 00072 public: 00073 00074 MPISerialDCF(DataContainerFactory const & _f) 00075 : rk(0), f(_f) { 00076 #ifdef IWAVE_USE_MPI 00077 MPI_Comm_rank(MPI_COMM_WORLD,&rk); 00078 #endif 00079 } 00080 00081 MPISerialDCF(MPISerialDCF const & fact) 00082 : rk(0), f(fact.f) { 00083 #ifdef IWAVE_USE_MPI 00084 MPI_Comm_rank(MPI_COMM_WORLD,&rk); 00085 #endif 00086 } 00087 ~MPISerialDCF() {} 00088 DataContainer * build() const { return buildMPISerialDC(); } 00089 bool compare(DataContainerFactory const & dcf) const; 00092 bool isCompatible(DataContainer const & dc) const; 00093 ostream & write(ostream & str) const; 00094 }; 00095 00096 } 00097 00098 #endif