IC_EndPointSet.h

Go to the documentation of this file.
00001 
00011 #ifndef IC_ENDPOINTSET_H
00012 #define IC_ENDPOINTSET_H
00013 
00014 #ifndef IC_ENDPOINT_H
00015 #include "IC_EndPoint.h"
00016 #endif
00017 
00018 #ifndef IC_CONNECTION_H
00019 #include "IC_Connection.h"
00020 #endif
00021 
00022 #include "../ezxml/ezxml.h"
00023 #include <map>
00024 #include <string>
00025 
00026 /* reserved define for ezxml */
00027 #define XJDVERSION "version"
00028 #define COMPLIST "components"
00029 #define COMP     "component"
00030 #define CONNLIST "connections"
00031 #define CONN     "connection"
00032 /* reserved define for IC_XJDRegion */
00033 #define CONNID   "id"
00034 #define EXPORTER "exporter"
00035 #define IMPORTER "importer"
00036 #define EXPPORT  "exportport"
00037 #define IMPPORT  "importport"
00038 #define DATATYPE "type"
00039 #define TAG      "msgtag"
00040 #define COMMTYPE "commtype"
00041 /* reserved define for IC_XJDComponent */
00042 #define COMPID   "id"
00043 #define COMPNAME "name"
00044 #define N_NODE   "nNode"
00045 #define ARRAYORDER "arrayorder"
00046 
00047 using namespace std;
00048 
00049 
00056 class IC_EndPointSet
00057 {
00058   public:
00059 
00064   /* the declarations below must be in sync with
00065      ../FortranInterface/intercomm_interface.h */
00066 
00067     enum
00068       {
00069       IC_OK                      = 0,
00070       IC_EPSET_INIT_FAILURE      = -13,
00071       IC_ARRAY_REGISTER_FAILURE  = -14,
00072       IC_COMMIT_ARRAY_FAILURE    = -15,
00073     };
00074     static const char * const IC_epset_errors[];
00075 
00083     IC_EndPointSet(const char* xjdfile, const char* compname, int& status);
00084 
00088     virtual ~IC_EndPointSet();
00089 
00094     void commitArrays(int& status);
00095 
00101     void exportArray(char* arrname, int& status);
00102 
00108     void importArray(char* arrname, int& status);
00109 
00110     static void printErrorMessage(const char* msg, const int ic_err);
00111 
00112 #ifdef PPLUSPLUS
00113   private:
00114     /* maps portname onto P++ array*/
00115     map<string, const intArray*> ppp_int_arrmap; /* map portname : intArray*/
00116     map<string, const floatArray*> ppp_float_arrmap; /* map portname : floatArray*/
00117     map<string, const doubleArray*> ppp_double_arrmap; /* map portname : doubleArray*/
00118 
00119   public:  
00120     virtual void registerArray(const char*, const intArray&, int& );
00121     virtual void bcastLocalArray(const char*, const intArray&, int, int&);
00122     virtual void recvLocalArray(const char*, const intArray&, int, int&);
00123 
00124     virtual void registerArray(const char*, const floatArray&, int& );
00125     virtual void bcastLocalArray(const char*, const floatArray&, int, int&);
00126     virtual void recvLocalArray(const char*, const floatArray&, int, int&);
00127 
00128     virtual void registerArray(const char*, const doubleArray&, int& );
00129     virtual void bcastLocalArray(const char*, const doubleArray&, int, int&);
00130     virtual void recvLocalArray(const char*, const doubleArray&, int, int&);
00131 #endif
00132 
00133 #ifdef FORTRAN90
00134   private:
00135     /* maps portname onto F90 arraydesc*/
00136     map<string, const F90_charArray*>   f90_char_arrmap;
00137     map<string, const F90_shortArray*>  f90_short_arrmap;
00138     map<string, const F90_intArray*>    f90_int_arrmap;
00139     map<string, const F90_floatArray*>  f90_float_arrmap;
00140     map<string, const F90_doubleArray*> f90_double_arrmap;
00141 
00142   public:  
00143     virtual void registerArray(const char* , const F90_charArray& , int& );
00144     virtual void bcastLocalArray(const char*, const F90_charArray&, int, int&);
00145     virtual void recvLocalArray(const char*, const F90_charArray&, int, int&);
00146 
00147     virtual void registerArray(const char* , const F90_shortArray& , int& );
00148     virtual void bcastLocalArray(const char*, const F90_shortArray&, int, int&);
00149     virtual void recvLocalArray(const char*, const F90_shortArray&, int, int&);
00150 
00151     virtual void registerArray(const char* , const F90_intArray& , int& );
00152     virtual void bcastLocalArray(const char*, const F90_intArray&, int, int&);
00153     virtual void recvLocalArray(const char*, const F90_intArray&, int, int&);
00154 
00155     virtual void registerArray(const char* , const F90_floatArray& , int& );
00156     virtual void bcastLocalArray(const char*, const F90_floatArray&, int, int&);
00157     virtual void recvLocalArray(const char*, const F90_floatArray&, int, int&);
00158 
00159     virtual void registerArray(const char* , const F90_doubleArray& , int& );
00160     virtual void bcastLocalArray(const char*, const F90_doubleArray&, int, int&);
00161     virtual void recvLocalArray(const char*, const F90_doubleArray&, int, int&);
00162    
00163 #endif
00164 
00165  private:
00166     const char* myprogname;
00167     char* cid;
00168     unsigned mynproc; 
00169     unsigned myao;
00170     
00171     char* xjdversion;
00172 
00173     map<string, IC_EndPoint*> epmap; /* map endpoint name : endpoint*/
00174     map<string, IC_Connection*> connmap; /* map connection name : connection */
00175     
00176     /* map<string, IC_EndPoint*> port2ep; /* map portname : endpoint*/
00177     /* map<string, IC_Desc*> port2desc; /* map portname : descriptor*/
00178     /* map<string, IC_Region**> port2regionset; /* map portname : regionset*/
00179     /* map<string, IC_Sched*> port2sched; /* map portname : schedule*/
00180     /* map<string, int> port2tag; /* map portname : tag*/
00181     
00182     void addep(const char* myname, unsigned mynproc, unsigned myao,
00183                char* othername, unsigned onproc, unsigned oao,
00184                char* portname, char* commtype, char* datatype, int tag,
00185                int ex_im, char* connname);
00186                
00187     IC_EndPoint* findep(string epname);
00188     void registerPort(IC_EndPoint* ep, char* ptname, char* ctype,
00189                       char* dtype, int tag, int& stat);
00190     void registerConn(IC_EndPoint* ep, char* connname, char* ptname, char* ctype,
00191                       char* dtype, int tag, int ex_im, int& stat);
00192 
00193 
00194     /* Methods for parsing*/
00195     ezxml_t read_xjd(const char* xjdname);
00196     char* get_version(ezxml_t xmlRoot);
00197     int epset_init_1_5(ezxml_t xmlRoot, int& stat);
00198     int epset_init_2_0(ezxml_t xmlRoot, int& stat);
00199     int register_program(ezxml_t xmlRoot);
00200     int inspect_connections(ezxml_t xmlRoot);
00201 
00202     int XJD_Validate(ezxml_t xmlRoot);
00203     int XJD_Validate_1_5(ezxml_t xmlRoot);
00204     int XJD_Validate_2_0(ezxml_t xmlRoot);
00205     int check_multi_import(ezxml_t xmlRoot);
00206 
00207     ezxml_t get_first_comp(ezxml_t xmlRoot);
00208     ezxml_t get_first_conn(ezxml_t xmlRoot);
00209     char* get_field_byID(char* id, ezxml_t xmlRoot, char* fieldname);
00210 };
00211 
00212 #endif /*_IC_ENDPOINTSET_H_*/

Generated on Mon Jun 4 14:42:41 2007 for InterComm by  doxygen 1.4.6