00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef COMM_CREATOR_H 00012 #define COMM_CREATOR_H 00013 00014 /*********************************************************************** 00015 * 00016 * CommCreator is a factory class which is used to create specific 00017 * subclasses of the base class Communicate. To create a new library- 00018 * specific Communicate, the user can either instantiate such a class 00019 * directly, or they can call the static method 00020 * CommCreator::create(CommCreator::CreateMethod, int argc, char *argv[], 00021 * int nodes) 00022 * 00023 ***********************************************************************/ 00024 00025 00026 // forward declarations 00027 class Communicate; 00028 00029 00030 // class definition 00031 class CommCreator { 00032 00033 public: 00034 // enumeration of communication libraries 00035 enum { ACLMPL, PM, MPI, SHMEMPI, PVM, SERIAL, COMMLIBRARIES }; 00036 00037 public: 00038 // constructor and destructor 00039 CommCreator() { } 00040 ~CommCreator() { } 00041 00042 // 00043 // informative methods 00044 // 00045 00046 // return the number of libraries available 00047 static int getNumLibraries() { return COMMLIBRARIES; } 00048 00049 // return the name of the Nth library 00050 static const char *getLibraryName(int); 00051 00052 // return a list of all the libraries, as a single string 00053 static const char *getAllLibraryNames(); 00054 00055 // is the given comm library available here? 00056 static bool supported(int); 00057 static bool supported(const char *nm) { return supported(libindex(nm)); } 00058 00059 // is the given comm library name one we recognize? 00060 static bool known(const char *nm) { return (libindex(nm) >= 0); } 00061 00062 // 00063 // Communicate create methods 00064 // 00065 00066 // create a new Communicate object. Arguments = type, argc, argv, num nodes, 00067 // do init 00068 static Communicate *create(int, int&, char** &, int = (-1), bool = true); 00069 00070 // same as above, but specifying the type as a string instead of an int 00071 static Communicate *create(const char *nm, int& argc, char **& argv, 00072 int nodes= (-1), bool doinit = true) { 00073 return create(libindex(nm), argc, argv, nodes, doinit); 00074 } 00075 00076 private: 00077 // return the index of the given named library, or (-1) if not found 00078 static int libindex(const char *); 00079 }; 00080 00081 #endif // COMM_CREATOR_H 00082 00083 /*************************************************************************** 00084 * $RCSfile: CommCreator.h,v $ $Author: adelmann $ 00085 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:28 $ 00086 * IPPL_VERSION_ID: $Id: CommCreator.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 00087 ***************************************************************************/