MED fichier
MEDfileObjectDescriptionRd.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2023 EDF R&D, CEA/DEN
4  * MED is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * MED is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with MED. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #include <med.h>
20 #include <med_config.h>
21 #include <med_outils.h>
22 
23 #include <string.h>
24 
25 
26 /*
27 Les objets de class medclass dont il est ici question sont représentés par des noms de groupes
28 dans le modèle HDF.
29 */
30 #define MY_CASE(OBJ)\
31  case MED_##OBJ :\
32  strcpy(_datagroupname,MED_##OBJ##_GRP);\
33  _objsize = MED_##OBJ##_GRP_SIZE;\
34  break;
35 
48 med_err
50  const med_class medclass,
51  const char * const objectname,
52  char * const description)
53 {
54  med_err _ret = -1;
55  char _datagroupname[2*MED_NAME_SIZE+1]="";
56  int _objsize = 0;
57 
58  /*
59  * On inhibe le gestionnaire d'erreur HDF
60  */
62 
63  /*
64  * Give access to the class object in the local file
65  */
66  switch(medclass) {
67 
68  MY_CASE(MESH);
69  MY_CASE(FIELD);
70  MY_CASE(MESH_SUPPORT);
71  MY_CASE(ELSTRUCT);
72  MY_CASE(EQUIVALENCE);
73  MY_CASE(LOCALIZATION);
74  MY_CASE(PROFILE);
75  MY_CASE(INTERPOLATION);
76  MY_CASE(NUMERICAL_DATA);
77  MY_CASE(FILE);
78 
79 
80  /* MY_CASE(FAMILY); Idem Suivant */
81  /* MY_CASE(GROUP); C'est un dataset, non un group hdf */
82  /* Il serait possible d'ajouter un commentaire au datatset <groupname> */
83  /* mais il faudrait en plus de son nom : */
84  /* - le nom du maillage concerné */
85  /* - le nom de la famille d'éléments à laquelle */
86  /* or l'API ne prévoit qu'un nom */
87  /* MEDmodel/MEDfile/FAS/<FAMILY_MESH_NAME_REF>/_ELEME/<FAMILY_NAME_ELEM>/_GRO/NOM */
88  /* Une première solution pourrait être une liste de noms séparés par le caractère '/' : */
89  /* objectname == <FAMILY_MESH_NAME_REF>/<FAMILY_NAME_ELEM>/NOM */
90  /* Une deuxième solution pourrait être un objectname de type const char * const [] */
91  /* mais il faudrait un paramètre supplémentaire indiquant le nombre de chaînes */
92  /* Une troisième solution pourraît être l'utlisation d'un objectId au lieu du fid avec */
93  /* une gestion du chemin relatif à l'objectId et une API permettant d'obtenir l'objectID */
94  /* en sélectionnant n'importe quel objet, mais cela necessiterait une revue complète d'API */
95  /* La solution retenue est la création de l'API MEDfilePathCommentWr.c */
96 
97  /* MY_CASE(JOINT); */
98  /* Besoin du nom du maillage */
99  /* MEDmodel/MEDfile/JNT/<MESH_NAME_REF>/<JNTNAME> */
100 
101  default :
102  MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_CLASS,_datagroupname);
103  goto ERROR;
104  }
105 
106  strncpy(_datagroupname+_objsize,objectname,MED_NAME_SIZE+1);
107  _datagroupname[2*MED_NAME_SIZE]='\0';
108 
110  _datagroupname,
111  MED_NOM_DES,
113  description ) <0 ) {
114  MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDattributeStringRdByName");
115  SSCRUTE(_datagroupname);
117  goto ERROR;
118  }
119 
120  _ret=0;
121 
122  ERROR:
123 
124  return _ret;
125 }
MED_ERR_API
#define MED_ERR_API
Definition: med_err.h:111
MED_ERR_CLASS
#define MED_ERR_CLASS
Definition: med_err.h:130
med_err
herr_t med_err
Definition: med.h:336
description
const char *const description
Definition: medfile.h:65
MED_COMMENT_SIZE
#define MED_COMMENT_SIZE
Definition: med.h:80
MEDfileObjectDescriptionRd
med_err MEDfileObjectDescriptionRd(const med_idt fid, const med_class medclass, const char *const objectname, char *const description)
Lit une description associée à l'objet objectname de type med_class dans le fichier fid .
Definition: MEDfileObjectDescriptionRd.c:49
med_config.h
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:160
med_idt
hid_t med_idt
Definition: med.h:335
_MEDattributeStringRdByName
MEDC_EXPORT med_err _MEDattributeStringRdByName(med_idt pid, const char *const path, const char *const attname, const med_size attsize, char *const val)
MED_ERR_CALL
#define MED_ERR_CALL
Definition: med_err.h:48
med_outils.h
MY_CASE
#define MY_CASE(OBJ)
Definition: MEDfileObjectDescriptionRd.c:30
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
med.h
med_class
med_class
Definition: med.h:191
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:82
MED_NOM_DES
#define MED_NOM_DES
Definition: med_outils.h:53
MED_ERR_RANGE
#define MED_ERR_RANGE
Definition: med_err.h:34
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)