1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // Author : Eric Fayolle (EDF)
29 #include "CalciumFortranInt.h"
35 // Interface C de SalomeCalcium
40 //TODO: ajouter les prototypes pour eviter les pbs de passage par valeur
41 InfoType ecp_fint_ (void * component, char* nomVar, float t);
42 InfoType ecp_fini_ (void * component, char* nomVar, int i);
43 InfoType ecp_efft_ (void * component, char* nomVar, float t);
44 InfoType ecp_effi_ (void * component, char* nomVar, int i);
46 /************************************/
47 /* INTERFACES DE LECTURE EN 0 COPIE */
48 /************************************/
50 /* Definition des méthodes calcium étendues en 0 copie */
51 /* Le buffer est alloué par le port pas par l'utilisateur */
52 /* Remarquer le type ** de data */
53 /* L'utilisateur devra appeler ecp_..._free pour désallouer le buffer interne */
54 /* Attention en cas de lectures multiples : le buffer retourné est le même */
55 /* Attention si les niveaux sont actifs le buffer peut être supprimé automatiquement par calcium. */
57 #define CALCIUM_EXT_LECT_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \
58 InfoType ecp_##_name (void * component, int mode, \
59 _timeType * ti, _timeType * tf, int * i, \
60 char * nomvar, int bufferLength, \
61 int * nRead, _type _qual ** data ) { \
67 InfoType info = ecp_lecture_##_typeName (component, mode, ti, tf, &_i, \
68 nomvar, bufferLength, &_nRead, \
70 /* std::cout << "-------- CalciumInterface(C Part), Valeur de data : " << std::endl; */ \
71 /* std::cout << "Ptr :" << *data << std::endl; */ \
72 /* for (int j=0; j<_nRead;++j) */ \
73 /* printf("--- Valeur de data[%d] : %d \n",j,(*data)[j]); */ \
74 /* std::cout << "Ptr :" << *data << std::endl; */ \
76 /* std::cerr << "-------- CalciumInterface(C Part) MARK 2 ------------------" << std::endl; */ \
77 if(mode == CP_SEQUENTIEL) \
80 /* std::cerr << "-------- CalciumInterface(C Part) MARK 3 ------------------" << std::endl; */ \
84 void ecp_##_name##_free ( _type _qual * data) { \
85 ecp_lecture_##_typeName##_free(data); \
89 /* L'interface de cette routine diffère de celle obtenue par la macro :
90 CALCIUM_LECT_INTERFACE_C_.
91 Le paramètre supplémentaire strSize indique la taille fixe et identique
92 des chaînes stockées dans data (les ports CALCIUM n'en n'ont pas besoin)
94 InfoType ecp_lch(void * component, int mode, float * ti, float * tf, int * i,
95 char * nomvar, int bufferLength, int * nRead,
96 char *** data, int strSize) {
100 fflush(stdout);fflush(stderr);
102 InfoType info = ecp_lecture_str (component, mode, ti, tf, &_i,
103 nomvar, bufferLength, &_nRead,
105 strSize est inutile pour les ports CALCIUM
106 qui gèrent des tailles quelconques de chaines. */
107 if(mode == CP_SEQUENTIEL)
110 fflush(stdout);fflush(stderr);
114 void ecp_lch_free (char* * data) { \
115 ecp_lecture_str_free(data); \
120 /*REVERIFIER MAINTENANT 0 COPY avec int2integer*/
121 CALCIUM_EXT_LECT_INTERFACE_C_(len,float,int,int2integer,);
122 CALCIUM_EXT_LECT_INTERFACE_C_(lre,float,float,float,);
123 CALCIUM_EXT_LECT_INTERFACE_C_(ldb,double,double,double,);
124 CALCIUM_EXT_LECT_INTERFACE_C_(llo,float,int,bool,);
125 CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,);
126 /* CALCIUM_EXT_LECT_INTERFACE_C_(lch,float,char,STAR[]); */
129 /**************************************/
130 /* INTERFACES DE LECTURE AVEC RECOPIE */
131 /**************************************/
133 #define CALCIUM_LECT_INTERFACE_C_(_name,_timeType,_calInt,_type,_typeName,_qual,lastarg) \
134 _calInt cp_##_name (void * component, _calInt mode, \
135 _timeType * ti, _timeType * tf, _calInt * i, \
136 char * nomvar, _calInt bufferLength, \
137 _calInt * nRead, _type _qual * data \
140 int _mode = (int) mode; \
141 size_t _bufferLength = bufferLength; \
147 if ( (data == NULL) || (_bufferLength < 1) ) return CPNTNULL; \
149 _calInt info = ecp_lecture_##_typeName (component, _mode, ti, tf, &_i, \
150 nomvar, _bufferLength, &_nRead, \
152 if(mode == CP_SEQUENTIEL) \
160 void cp_##_name##_free ( _type _qual * data) { \
161 ecp_lecture_##_typeName##_free(data); \
165 /* L'interface de cette routine diffère de celle obtenue par la macro :
166 CALCIUM_LECT_INTERFACE_C_.
167 Le paramètre supplémentaire strSize indique la taille fixe et identique
168 des chaînes stockées dans data (les ports CALCIUM n'en n'ont pas besoin)
171 /* InfoType cp_lch(void * component, int mode, float * ti, float * tf, int * i, */
172 /* char * nomvar, int bufferLength, int * nRead, */
173 /* char ** data, int strSize) { */
177 /* fflush(stdout);fflush(stderr); */
178 /* fprintf(stderr,"Beginning of cp_lch: %s %d %f\n",nomvar,*i,*ti); */
179 /* if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; */
180 /* InfoType info = ecp_lecture_str (component, mode, ti, tf, &_i, */
181 /* nomvar, bufferLength, &_nRead, */
184 /* strSize est inutile pour les ports CALCIUM */
185 /* qui gèrent des tailles quelconques de chaines. */
186 /* if(mode == CP_SEQUENTIEL) */
189 /* fprintf(stderr,"End of cp_lch: %s %d \n",nomvar,*i); */
190 /* fflush(stdout);fflush(stderr); */
195 /* Definition des méthodes calcium standard */
196 /* CALCIUM_LECT_INTERFACE_C_( <suffixe du nom de l'interface à générer>, <type du paramètre temporel>, <type d'entier à utiliser pour les paramètres de type entier>,
197 <type de données>, <nom de l'interface C2CPP à utiliser>, <qualificateur de type optionnel des données>,<paramètres supplémentaire ignoré>)*/
199 CALCIUM_LECT_INTERFACE_C_(len,float ,int,int ,int2integer,,);
200 /*llg ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
201 sinon problème de conversion de 64bits vers 32bits */
202 CALCIUM_LECT_INTERFACE_C_(llg,float ,int,long ,long2integer,,);
204 CALCIUM_LECT_INTERFACE_C_(lln,float ,int,long ,long,,);
206 CALCIUM_LECT_INTERFACE_C_(lre,float ,int,float ,float,,);
207 CALCIUM_LECT_INTERFACE_C_(ldb,double,int,double ,double,,);
208 CALCIUM_LECT_INTERFACE_C_(llo,float ,int,int ,bool,,);
209 CALCIUM_LECT_INTERFACE_C_(lcp,float ,int,float ,cplx,,);
211 #define LCH_LAST_PARAM ,int strsize
212 CALCIUM_LECT_INTERFACE_C_(lch,float ,int,char ,str,STAR, LCH_LAST_PARAM );
215 /* Definition des méthodes calcium destinées à l'interfaçage fortran
216 avec une taille des INTEGER fortran paramétrés à la configuration du KERNEL */
218 CALCIUM_LECT_INTERFACE_C_(len_fort_,float ,cal_int,cal_int ,integer,,);
219 CALCIUM_LECT_INTERFACE_C_(lin_fort_,float ,cal_int,int ,int2integer,,);
220 /*llg_fort_ ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
221 sinon problème de conversion de 64bits vers 32bits */
222 CALCIUM_LECT_INTERFACE_C_(llg_fort_,float ,cal_int,long ,long2integer,,);
224 CALCIUM_LECT_INTERFACE_C_(lre_fort_,float ,cal_int,float ,float,,);
225 CALCIUM_LECT_INTERFACE_C_(ldb_fort_,double,cal_int,double ,double,,);
226 CALCIUM_LECT_INTERFACE_C_(llo_fort_,float ,cal_int,int ,bool,,); /*int pour bool ou cal_int */
227 CALCIUM_LECT_INTERFACE_C_(lcp_fort_,float ,cal_int,float ,cplx,,);
228 CALCIUM_LECT_INTERFACE_C_(lch_fort_,float ,cal_int,char ,str,STAR, LCH_LAST_PARAM );
230 CALCIUM_LECT_INTERFACE_C_(lln_fort_,float ,cal_int,long ,long,,);
232 /**********************************************/
233 /* INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE */
234 /**********************************************/
236 InfoType cp_cd (void * component, char * instanceName) {
237 InfoType info = ecp_cd_(component,instanceName);
241 InfoType cp_fin (void * component, int code) {
242 /* TODO : gérer avec les callbacks des ports DSC */
244 InfoType info = ecp_fin_(component,code);
250 /***************************/
251 /* INTERFACES D'ECRITURE */
252 /***************************/
254 #define CALCIUM_ECR_INTERFACE_C_(_name,_timeType,_calInt,_type,_typeName,_qual,lastarg) \
255 _calInt cp_##_name (void * component, _calInt mode, \
256 _timeType t, _calInt i, \
257 char * nomvar, _calInt nbelem, \
263 size_t _nbelem = nbelem; \
267 if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; \
269 _calInt info = ecp_ecriture_##_typeName (component, _mode, &_t, _i, \
281 /* InfoType cp_ech(void * component, int mode, float t, int i, */
282 /* char * nomvar, int nbelem, */
283 /* char ** data, int strSize) { */
286 /* fflush(stdout);fflush(stderr); */
287 /* fprintf(stderr,"Beginning of cp_ech: %s %d %f\n",nomvar,i,t); */
288 /* if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; */
290 /* InfoType info = ecp_ecriture_str (component, mode, &t, i, */
291 /* nomvar, nbelem, */
294 /* fprintf(stderr,"End of cp_ech: %s %d \n",nomvar,i); */
295 /* fflush(stdout); */
296 /* fflush(stderr); */
301 /* Definition des méthodes calcium standard */
302 /* CALCIUM_ECR_INTERFACE_C_(_name,_timeType,_calInt,type,_typeName,_qual) */
303 CALCIUM_ECR_INTERFACE_C_(een,float ,int,int ,int2integer,,);
304 /*elg ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
305 sinon problème de conversion de 64bits vers 32bits */
306 CALCIUM_ECR_INTERFACE_C_(elg,float ,int,long ,long2integer,,);
307 CALCIUM_ECR_INTERFACE_C_(ere,float ,int,float ,float,,);
308 CALCIUM_ECR_INTERFACE_C_(edb,double,int,double,double,,);
309 CALCIUM_ECR_INTERFACE_C_(elo,float ,int,int ,bool,,);
310 CALCIUM_ECR_INTERFACE_C_(ecp,float ,int,float ,cplx,,);
311 CALCIUM_ECR_INTERFACE_C_(ech,float ,int,char ,str,STAR,LCH_LAST_PARAM );
313 CALCIUM_ECR_INTERFACE_C_(eln,float ,int,long ,long,,);
315 /* Definition des méthodes calcium destinées à l'interfaçage fortran
316 avec une taille des INTEGER fortran paramétrés à la configuration du KERNEL */
318 CALCIUM_ECR_INTERFACE_C_(een_fort_,float ,cal_int,cal_int,integer,,);
319 /*elg_fort_ ne fonctionnera pas toujours correctement (port calcium_integer) si sizeof(long) == 64 bits && cal_int==int (32 bits)
320 sinon problème de conversion de 64bits vers 32bits */
321 CALCIUM_ECR_INTERFACE_C_(elg_fort_,float ,cal_int,long ,long2integer,,);
322 CALCIUM_ECR_INTERFACE_C_(ein_fort_,float ,cal_int,int ,int2integer,,);
323 CALCIUM_ECR_INTERFACE_C_(ere_fort_,float ,cal_int,float ,float,,);
324 CALCIUM_ECR_INTERFACE_C_(edb_fort_,double,cal_int,double,double,,);
325 CALCIUM_ECR_INTERFACE_C_(elo_fort_,float ,cal_int,int ,bool,,);
326 CALCIUM_ECR_INTERFACE_C_(ecp_fort_,float ,cal_int,float ,cplx,,);
327 CALCIUM_ECR_INTERFACE_C_(ech_fort_,float ,cal_int,char ,str,STAR,LCH_LAST_PARAM );
329 CALCIUM_ECR_INTERFACE_C_(eln_fort_,float ,cal_int,long ,long,,);
331 /***************************/
332 /* Interface for cleaning */
333 /***************************/
335 InfoType cp_fini (void * component, char * nomvar, int i)
337 InfoType info = ecp_fini_(component,nomvar,i);
341 InfoType cp_fint (void * component, char * nomvar, float t)
343 InfoType info = ecp_fint_(component,nomvar,t);
347 InfoType cp_effi (void * component, char * nomvar, int i)
349 InfoType info = ecp_effi_(component,nomvar,i);
353 InfoType cp_efft (void * component, char * nomvar, float t)
355 InfoType info = ecp_efft_(component,nomvar,t);