- Timestamp:
- 10/14/10 14:52:38 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/XMLIO
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r131 r132 29 29 /* ********************************************************** */ 30 30 31 void xios_handle_create_(XHandle * _ret, const XDType * const _dtype, const XString * const_id)31 void xios_handle_create_(XHandle * _ret, const XDType * const _dtype, XString _id) 32 32 { 33 try { 34 switch(*_dtype) 35 { 36 /*ECONTEXT, 37 EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, 38 GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ 39 case (ECONTEXT): 40 //if (Context::) 41 break; 33 // Si le handle n'est pas initialisé à 0, on ne fait aucun traitement. 34 if (!isNullHandle(*_ret)) return; 35 std::string __id = stringXtoStd(_id); 36 switch(*_dtype) 37 { 38 /* EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ 39 case (ECONTEXT): 40 // Si le context n'existe pas, on retourne un handle vide/nul. 41 if (!Context::HasContext(__id)) { *_ret = NULLHANDLE; return ; } 42 _ret->data_type = *_dtype; 43 _ret->data_ptr = Context::GetContext(__id); 44 return ; 42 45 43 default : 44 break; 45 }; 46 } catch(const Exception &exc) 47 { ERROR(exc.displayText()); } 48 } 49 50 void xios_handle_verify_(XBool * _ret, const XHandle * const _hd) 51 { 52 try { 53 54 } catch(const Exception &exc) 55 { ERROR(exc.displayText()); } 56 } 57 58 void xios_handle_getType_(XDType * _ret, const XHandle * const _hd) 59 { 60 try { 61 62 } catch(const Exception &exc) 63 { ERROR(exc.displayText()); } 64 } 65 66 void xios_handle_isType_(XBool * _ret, const XHandle * const _hd, const XDType * const _dtype) 67 { 68 try { 69 70 } catch(const Exception &exc) 71 { ERROR(exc.displayText()); } 72 } 73 74 void xios_handle_isId_(XBool * _ret, const XHandle * const _hd, const XString * const _id) 75 { 76 try { 77 78 } catch(const Exception &exc) 79 { ERROR(exc.displayText()); } 80 } 81 82 void xios_handle_isGroup_(XBool * _ret, const XHandle * const _hd) 83 { 84 try { 85 86 } catch(const Exception &exc) 87 { ERROR(exc.displayText()); } 88 } 89 90 void xios_handle_isElement_(XBool * _ret, const XHandle * const _hd) 91 { 92 try { 93 94 } catch(const Exception &exc) 95 { ERROR(exc.displayText()); } 46 default : 47 *_ret = NULLHANDLE; 48 return ; 49 }; 96 50 } 97 51 … … 102 56 void xios_xml_parse_file_(XString _filename) 103 57 { 104 try { 105 std::string __filename = stringXtoStd(_filename); 106 std::ifstream __istr( __filename.c_str() , std::ifstream::in ); 58 std::string __filename = stringXtoStd(_filename); 59 std::ifstream __istr( __filename.c_str() , std::ifstream::in ); 107 60 108 109 61 // On commence la lecture du flux de donnée xml. 62 XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 110 63 111 // On parse le fichier xml noeud par noeud 112 // (ie on construit dynamiquement notre arbre d'objets). 113 XMLParser::Parse(node); 114 115 } catch(const Exception &exc) 116 { ERROR(exc.displayText()); } 64 // On parse le fichier xml noeud par noeud 65 // (ie on construit dynamiquement notre arbre d'objets). 66 XMLParser::Parse(node); 117 67 } 118 68 119 69 void xios_xml_parse_string_(XString _xmlcontent) 120 70 { 121 try { 122 std::string __xmlcontent = stringXtoStd(_xmlcontent); 123 std::istringstream __istr(__xmlcontent); 71 std::string __xmlcontent = stringXtoStd(_xmlcontent); 72 std::istringstream __istr(__xmlcontent); 124 73 125 126 74 // On commence la lecture du flux de donnée xml. 75 XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 127 76 128 // On parse le fichier xml noeud par noeud 129 // (ie on construit dynamiquement notre arbre d'objets). 130 XMLParser::Parse(node); 77 // On parse le fichier xml noeud par noeud 78 // (ie on construit dynamiquement notre arbre d'objets). 79 XMLParser::Parse(node); 80 } 81 /* ********************************************************** */ 82 /* DATA TREATMENT INTERFACE */ 83 /* ********************************************************** */ 131 84 132 } catch(const Exception &exc) 133 { ERROR(exc.displayText()); } 85 static std::vector<DataTreatment *> AllDataTreatment; 86 87 static void deleteAllDataTreatment(void) 88 { 89 std::vector<DataTreatment *>::iterator it; 90 for (it = AllDataTreatment.begin(); 91 it != AllDataTreatment.end(); it++) 92 delete (*it); 134 93 } 135 94 136 /* ********************************************************** */ 137 /* MAIN ENTRY */ 138 /* ********************************************************** */ 95 void xios_dtreatment_new_(XHandle * _dt, const XHandle * const _hd) 96 { 97 static bool called = false; 139 98 140 void main_c_(void) // voué à disparaître 141 { /* Ne rien faire de plus */ } 99 // Si le handle de traitement n'est pas initialisé à 0, on ne fait aucun traitement. 100 if (!isNullHandle(*_dt) || (_hd->data_type != ECONTEXT)) return; 101 Context* const __ctxt = (Context*) _hd->data_ptr; 102 103 _dt->data_type = DTREATMENT; 104 _dt->data_ptr = new DataTreatment(__ctxt); 105 106 if (!called) 107 { 108 atexit (&deleteAllDataTreatment); 109 called = true; 110 } 111 } 112 113 void xios_dtreatment_create_files_and_headers_(const XHandle * const _hd, const XFileType * const _ft) 114 { 115 // Si le handle de traitement n'est pas initialisé à 0, on ne fait aucun traitement. 116 if (isNullHandle(*_hd) || (_hd->data_type != DTREATMENT)) return; 117 DataTreatment * const __dt = (DataTreatment*)_hd->data_ptr; 118 AllDataTreatment.push_back (__dt); 119 switch(*_ft) 120 { 121 case (NETCDF4): 122 __dt->createDataOutput<NetCDF4DataOutput>(); 123 return; 124 // Autres formats de fichiers si disponibles... 125 default: 126 return; 127 } 128 } 129 -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.hpp
r131 r132 12 12 #endif //__cplusplus 13 13 14 typedef long int XInt; //integer 15 typedef bool XBool; //logical 14 typedef long int XInt; // Integer 15 typedef bool XBool; // Logical 16 typedef void *XPtr; // Pointeur C non typé 16 17 17 18 typedef enum _datatype 18 19 { 20 NOTYPE = 0, 19 21 DTREATMENT, DATE, CALENDAR, ECONTEXT, 20 22 EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, … … 24 26 typedef enum _filetype 25 27 { 26 NETCDF4 28 NETCDF4 = 0 27 29 } XFileType; 28 29 typedef struct _ptr // Pointeur C non-typé.30 { void * ptr; } XPtr;31 30 32 31 typedef struct _handle // Référence C à une objet de la bibliothÚque. … … 39 38 { int year, month, day, hour, minute, second; } XDate, XDuration; 40 39 40 const XHandle NULLHANDLE = { NOTYPE, NULL }; 41 42 #define isNullHandle(hdl) ((hdl).data_type == NOTYPE && (hdl).data_ptr == NULL) 43 41 44 /* ******************** HANDLE INTERFACE ******************** */ 42 void xios_handle_create_ (XHandle * _ret, const XDType * const _dtype, const XString * const_id);45 void xios_handle_create_ (XHandle * _ret, const XDType * const _dtype, XString _id); 43 46 void xios_handle_verify_ (XBool * _ret, const XHandle * const _hd); 44 47 void xios_handle_getType_(XDType * _ret, const XHandle * const _hd); 45 48 46 49 void xios_handle_isType_ (XBool * _ret, const XHandle * const _hd, const XDType * const _dtype); 47 void xios_handle_isId_ (XBool * _ret, const XHandle * const _hd, const XString * const _id);50 void xios_handle_isId_ (XBool * _ret, const XHandle * const _hd, const XString * const _id); 48 51 void xios_handle_isGroup_ (XBool * _ret, const XHandle * const _hd); 49 52 void xios_handle_isElement_(XBool * _ret, const XHandle * const _hd); … … 54 57 55 58 /* ******************** DATA TREATMENT INTERFACE ************ */ 56 void xios_dtreatment_new (XHandle * _dt, const XHandle * const _hd);57 void xios_dtreatment_create FilesAndHeaders(const XHandle * const _hd);59 void xios_dtreatment_new_(XHandle * _dt, const XHandle * const _hd); 60 void xios_dtreatment_create_files_and_headers_(const XHandle * const _hd, const XFileType * const _ft); 58 61 59 62 /* ******************** CALENDAR INTERFACE ****************** */ -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r131 r132 191 191 } 192 192 193 static bool HasContext(const string& id) 194 { 195 Poco::HashMap<string, StrHashMap<Context> > &AllListContext = Context::GetAllListObject(); 196 return (AllListContext.find(id) != AllListContext.end()); 197 } 198 199 static Context* GetContext(const string& id) 200 { return (Context::GetAllListObject()[id][id]); } 201 193 202 static Context* SwapContext(void) 194 203 { … … 208 217 { return (Context::GetObject(Context::GetCurrentContextId())); } 209 218 210 static void SetCurrentContext(const string& id, bool withSwap = false )219 static void SetCurrentContext(const string& id, bool withSwap = false, bool withcheck = true) 211 220 { 212 221 if (withSwap) Stid.push (Context::GetCurrentContextId()); 222 223 if (!Context::HasContext(id) && withcheck) 224 throw new XMLIOUndefinedValueException 225 ("Impossible de se placer dans le contexte "+id+" car celui-ci n'existe pas dans l'arborescence!"); 213 226 214 227 // On modifie le context courrant pour tout les ObjectTemplate -
XMLIO_V2/dev/dev_rv/src/XMLIO/main.f90
r131 r132 3 3 ! --------------------------------------------------- ! 4 4 5 MODULE XML 5 MODULE XTYPE 6 IMPLICIT NONE 7 8 ! Ne jamais modifier les valeurs internes de ce type dans le code fortran. 9 TYPE XHandle 10 INTEGER :: dtype 11 INTEGER :: daddr 12 END TYPE XHandle 13 14 TYPE XDate 15 INTEGER :: year, month, day, hour, minute, second 16 END TYPE XDate 17 18 TYPE XDuration 19 REAL(kind = 4) :: year, month, day, hour, minute, second 20 END TYPE XDuration 21 22 ! enum XDType 23 INTEGER, PARAMETER :: NOTYPE = 0 24 INTEGER, PARAMETER :: DTREATMENT = 1, DDATE = 2, CALENDAR = 3, ECONTEXT = 4 25 INTEGER, PARAMETER :: EAXIS = 5 , EDOMAIN = 6 , EFIELD = 7 , EFILE = 8 , EGRID = 9 26 INTEGER, PARAMETER :: GAXIS = 10, GDOMAIN = 11, GFIELD = 12, GFILE = 13, GGRID = 14 27 28 ! enum XFileType 29 INTEGER, PARAMETER :: NETCDF4 = 0 30 31 ! Autres constantes 32 TYPE(XHandle) , PARAMETER :: NULLHANDLE = XHandle(0, 0) 33 TYPE(XDuration), PARAMETER :: NONEDUR = XDuration(0., 0., 0., 0., 0., 0.) 34 35 END MODULE XTYPE 36 37 MODULE IXHANDLE 38 39 INTERFACE 40 41 SUBROUTINE xios_handle_create(ret, dtype, idt) 42 USE XTYPE 43 TYPE(XHandle), INTENT(OUT) :: ret 44 INTEGER , INTENT(IN) :: dtype 45 CHARACTER*(*), INTENT(IN) :: idt 46 END SUBROUTINE xios_handle_create 47 48 END INTERFACE 49 50 END MODULE IXHANDLE 51 52 MODULE IXML 53 IMPLICIT NONE 6 54 INTERFACE 7 55 … … 15 63 16 64 END INTERFACE 17 END MODULE XML 65 END MODULE IXML 66 67 MODULE IDATATREATMENT 68 IMPLICIT NONE 69 INTERFACE 70 71 SUBROUTINE xios_dtreatment_new(dt, context) 72 USE XTYPE 73 TYPE(XHandle), INTENT(OUT) :: dt 74 TYPE(XHandle), INTENT(IN) :: context 75 END SUBROUTINE xios_dtreatment_new 76 77 SUBROUTINE xios_dtreatment_create_files_and_headers(dt, ftype) 78 USE XTYPE 79 TYPE(XHandle), INTENT(IN) :: dt 80 INTEGER , INTENT(IN) :: ftype 81 END SUBROUTINE xios_dtreatment_create_files_and_headers 82 83 END INTERFACE 84 END MODULE IDATATREATMENT 18 85 19 86 PROGRAM MAIN 20 USE XML 87 USE XTYPE 88 USE IXHANDLE 89 USE IXML 90 USE IDATATREATMENT 91 21 92 IMPLICIT NONE 22 93 23 CHARACTER(LEN = 100):: filename 94 TYPE(XHandle) :: context1 = NULLHANDLE 95 TYPE(XHandle) :: dtreat = NULLHANDLE 24 96 25 filename = "/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml" 97 ! Parsing du document xml depuis un fichier situé sur le disque. 98 CALL xios_xml_Parse_File("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml") 26 99 27 CALL xios_xml_Parse_File(filename) 100 ! Création d'un handle sur le contexte dans lequel on souhaite travailler, cà d 'context1' ici. 101 CALL xios_handle_create(context1, ECONTEXT, "context1") 102 iF ((context1%dtype == 0) .AND. (context1%daddr == 0)) THEN 103 PRINT *, "Impossible de créer un handle sur l'élément context1 !" 104 STOP 105 END IF 106 107 ! ----------- Début du traitement ----------- ! 108 109 ! Création et initialisation d'une instance de traitement des données dans 'context1'. 110 CALL xios_dtreatment_new(dtreat, context1) 111 iF ((dtreat%dtype == 0) .AND. (dtreat%daddr == 0)) THEN 112 PRINT *, "Impossible d'initialiser l'instance de traitement !" 113 STOP 114 END IF 115 116 ! Création des fichiers et des entêtes dans le contexte. 117 CALL xios_dtreatment_create_files_and_headers(dtreat, NETCDF4) 28 118 29 119 END PROGRAM MAIN -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_node.hpp
r127 r132 79 79 { THashAttributes __attributes; this->getAttributes(__attributes); return (__attributes); } 80 80 81 ~XMLNode( )81 ~XMLNode(void) 82 82 { /* Ne rien faire de plus */ } 83 83 -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_parser.hpp
r127 r132 35 35 { WARNING("Le context ne sera pas traité car il existe déjà un autre context possédant le même nom !"); continue; } 36 36 37 Context::SetCurrentContext(attributes["id"] );37 Context::SetCurrentContext(attributes["id"], false, false); 38 38 Context& context = *Context::CreateObject(attributes["id"]); 39 39
Note: See TracChangeset
for help on using the changeset viewer.