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 DATA_CONNECT_CREATOR_H 00012 #define DATA_CONNECT_CREATOR_H 00013 00014 /*********************************************************************** 00015 * 00016 * DataConnectCreator is a factory class which is used to create specific 00017 * subclasses of the base class DataConnect. To create a new, agency- 00018 * specific DataConnect, the user can either instantiate such a class 00019 * directly, or they can call the static method 00020 * DataConnectCreator::create(DataConnectCreator::CreateMethod, char *name, 00021 * DataConnectCreator::TransferMethod) 00022 * There is also a static method 'create' which does not take a CreateMethod 00023 * argument, instead it will use a 'default' value. In the IPPL Framework, 00024 * this default value is set by the IpplInfo object based on the command 00025 * line arguments. 00026 * 00027 ***********************************************************************/ 00028 00029 00030 // forward declarations 00031 class DataConnect; 00032 00033 00034 // class definition 00035 class DataConnectCreator { 00036 00037 public: 00038 // constructor and destructor 00039 DataConnectCreator(); 00040 ~DataConnectCreator(); 00041 00042 // 00043 // informative methods 00044 // 00045 00046 // return the number of connection methods available 00047 static int getNumMethods(); 00048 00049 // return the name of the Nth method 00050 static const char *getMethodName(int); 00051 00052 // return a list of all the methods, as a single string 00053 static const char *getAllMethodNames(); 00054 00055 // return the current 'default' connection method 00056 static int getDefaultMethod() { 00057 return DefaultMethod; 00058 } 00059 00060 // return the current 'default' connection method name 00061 static const char *getDefaultMethodName() { 00062 return getMethodName(DefaultMethod); 00063 } 00064 00065 // is the given method available here? 00066 static bool supported(int); 00067 static bool supported(const char *nm); 00068 00069 // is the given method name one we recognize? 00070 static bool known(int); 00071 static bool known(const char *nm); 00072 00073 // 00074 // DataConnect create methods 00075 // 00076 00077 // create a new connection. Arguments = type, name, nodes 00078 static DataConnect *create(int, const char *, int = 0); 00079 00080 // create a new connection, by giving the method name (nm1), the name 00081 // for the new connection (nm2), and the number of nodes 00082 static DataConnect *create(const char *nm1, const char *nm2, int n = 0) { 00083 return create(libindex(nm1), nm2, n); 00084 } 00085 00086 // also create a new connection, but use the 'default' connection method. 00087 static DataConnect *create(const char *nm, int n = 0) { 00088 return create(DefaultMethod, nm, n); 00089 } 00090 00091 // a final method for creating objects; this one provides a default name, 00092 // and if the default connection object has already been created, this just 00093 // returns that one. 00094 static DataConnect *create(); 00095 00096 // 00097 // DataConnectCreator manipulation methods 00098 // 00099 00100 // change the default connection method. Return success. 00101 static bool setDefaultMethod(int); 00102 00103 // change the default connection method by specifying a name. Return 00104 // success. 00105 static bool setDefaultMethod(const char *nm) { 00106 return setDefaultMethod(libindex(nm)); 00107 } 00108 00109 // change the default number of nodes to use for the connection 00110 static void setDefaultNodes(int); 00111 00112 // return the default number of nodes to use in a connection 00113 static int getDefaultNodes(); 00114 00115 private: 00116 // default connection method 00117 static int DefaultMethod; 00118 00119 // default connection, if it has been created yet 00120 static DataConnect *DefaultConnection; 00121 00122 // how many instances of this class exist? 00123 static int InstanceCount; 00124 00125 // default number of nodes to use in the connection ... some connections 00126 // may not care about this 00127 static int ConnectNodes; 00128 00129 // return the index of the given named method, or (-1) if not found 00130 static int libindex(const char *); 00131 }; 00132 00133 #endif // DATA_CONNECT_CREATOR_H 00134 00135 /*************************************************************************** 00136 * $RCSfile: DataConnectCreator.h,v $ $Author: adelmann $ 00137 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $ 00138 * IPPL_VERSION_ID: $Id: DataConnectCreator.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $ 00139 ***************************************************************************/