Back to index

salome-kernel  6.5.0
CalciumMacroCInterface.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 /*  
00021 File   : CalciumInterface.hxx
00022 Author : Eric Fayolle (EDF)
00023 Module : KERNEL
00024 Modified by : $LastChangedBy$
00025 Date        : $LastChangedDate: 2007-03-01 13:27:58 +0100 (jeu, 01 mar 2007) $
00026 Id          : $Id: CalciumMacroCInterface.hxx,v 1.1.2.3.14.3.12.1 2012-04-12 14:05:06 vsr Exp $
00027 */
00028 
00029 #ifndef _CALCIUM_MACRO_C_INTERFACE_H_
00030 #define _CALCIUM_MACRO_C_INTERFACE_H_
00031 
00032 
00033 
00034 /****** CALCIUM_C2CPP_INTERFACE_HXX_ :                                  ******/
00035 /****** Declarations: ecp_lecture_... , ecp_ecriture_..., ecp_free_... ******/
00036 
00037 #define CALCIUM_C2CPP_INTERFACE_HXX_(_name,_porttype,_type,_qual)                                                 \
00038   extern "C" CalciumTypes::InfoType ecp_lecture_##_name (void * component, int dependencyType,                    \
00039                                                          CalTimeType< _type _qual >::TimeType * ti,               \
00040                                                          CalTimeType< _type _qual >::TimeType * tf, long * i,     \
00041                                                          const char * const nomvar, size_t bufferLength,          \
00042                                                          size_t * nRead, _type _qual ** data );                   \
00043                                                                                                                   \
00044                                                                                                                   \
00045   extern "C" void ecp_lecture_##_name##_free ( _type _qual * data);                                               \
00046                                                                                                                   \
00047                                                                                                                   \
00048   extern "C" CalciumTypes::InfoType ecp_ecriture_##_name (void * component, int dependencyType,                   \
00049                                                           CalTimeType< _type _qual >::TimeType *t,                \
00050                                                           long  i,                                                \
00051                                                           const char * const nomvar, size_t bufferLength,         \
00052                                                           _type _qual * data );                                   \
00053   
00054 
00055 
00056 
00057                                                                         
00058 /****** CALCIUM_C2CPP_INTERFACE_CXX_ :                                ******/                                                                        
00059 /******Definitions: ecp_lecture_... , ecp_ecriture_..., ecp_free_... ******/
00060 #define CALCIUM_C2CPP_INTERFACE_CXX_(_name,_porttype,_type,_qual)                                                \
00061   extern "C" CalciumTypes::InfoType ecp_lecture_##_name (void * component, int dependencyType,                   \
00062                                                          CalTimeType< _type _qual >::TimeType * ti,              \
00063                                                          CalTimeType< _type _qual >::TimeType * tf, long * i,    \
00064                                                          const char * const nomvar, size_t bufferLength,         \
00065                                                          size_t * nRead, _type _qual ** data )                   \
00066   {                                                                                                              \
00067     Superv_Component_i * _component = static_cast<Superv_Component_i *>(component);                              \
00068     double         _ti=0.;                                                                                       \
00069     double         _tf=0.;                                                                                       \
00070     if(dependencyType == CalciumTypes::CP_TEMPS)                                                                               \
00071       {                                                                                                          \
00072         _ti=*ti;                                                                                                 \
00073         _tf=*tf;                                                                                                 \
00074       }                                                                                                          \
00075     size_t         _nRead=0;                                                                                     \
00076     size_t         _bufferLength=bufferLength;                                                                   \
00077                                                                                                                  \
00078     if ( IsSameType< _porttype , cplx >::value ) _bufferLength*=2;                                               \
00079     DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" )                        \
00080     try                                                                                                          \
00081       {                                                                                                          \
00082         CalciumInterface::ecp_lecture< _type,_porttype >( *_component, dependencyType, _ti, _tf, *i, nomvar,     \
00083                                                           _bufferLength, _nRead, *data);                         \
00084       }                                                                                                          \
00085     catch ( const CalciumException & ex)                                                                         \
00086       {                                                                                                          \
00087         DEBTRACE( ex.what() );                                                                                   \
00088         return ex.getInfo();                                                                                     \
00089       }                                                                                                          \
00090     catch ( ... )                                                                                                \
00091       {                                                                                                          \
00092         DEBTRACE( "Unexpected exception ") ;                                                                     \
00093         return CalciumTypes::CPATAL;                                                                             \
00094       }                                                                                                          \
00095     if ( IsSameType< _porttype , cplx >::value )                                                                 \
00096       {                                                                                                          \
00097         *nRead=_nRead/2;                                                                                         \
00098         DEBTRACE( "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" )                \
00099         DEBTRACE( "-------- CalciumInterface(lecture Inter Part) _nRead  : " << _nRead )                         \
00100         DEBTRACE( "-------- CalciumInterface(lecture Inter Part) *nRead  : " << *nRead )                         \
00101       }                                                                                                          \
00102     else                                                                                                         \
00103       *nRead = _nRead;                                                                                           \
00104     if (dependencyType == CalciumTypes::CP_SEQUENTIEL )                                                          \
00105       *ti=(CalTimeType< _type _qual >::TimeType)(_ti);                                                           \
00106     DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data )                             \
00107     return CalciumTypes::CPOK;                                                                                   \
00108   };                                                                                                             \
00109                                                                                                                  \
00110                                                                                                                  \
00111   extern "C" void ecp_lecture_##_name##_free ( _type _qual * data)                                               \
00112   {                                                                                                              \
00113     CalciumInterface::ecp_free< _type, _porttype >(data);                                                        \
00114   };                                                                                                             \
00115                                                                                                                  \
00116                                                                                                                  \
00117   extern "C" CalciumTypes::InfoType ecp_ecriture_##_name (void * component, int dependencyType,           \
00118                                                           CalTimeType< _type _qual >::TimeType *t,        \
00119                                                           long  i,                                        \
00120                                                           const char * const nomvar, size_t bufferLength, \
00121                                                           _type _qual * data )                            \
00122   {                                                                                                       \
00123     DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 0 ------------------" )                \
00124     Superv_Component_i * _component = static_cast<Superv_Component_i *>(component);                       \
00125     /* Je ne sais pas pourquoi, je n'arrive pas  passer t par valeur : corruption de la pile*/           \
00126     double         _t=0.;                                                                                 \
00127     if(dependencyType == CalciumTypes::CP_TEMPS)                                                                        \
00128       _t=*t;                                                                                              \
00129     size_t         _bufferLength=bufferLength;                                                            \
00130     if ( IsSameType< _porttype , cplx >::value ) _bufferLength=_bufferLength*2;                           \
00131     DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" )                \
00132     try                                                                                                   \
00133       {                                                                                                   \
00134         /*printf("-------- CalciumInterface(ecriture Inter Part), cp_name : Nom de la var. de type %s : %s\n",#_type,nomvar);*/ \
00135         DEBTRACE( "----------->-" << nomvar )                                                             \
00136         CalciumInterface::ecp_ecriture< _type, _porttype >( *_component, dependencyType,                  \
00137                                                             _t,i,nomvar,_bufferLength,*data);             \
00138       }                                                                                                   \
00139     catch ( const CalciumException & ex)                                                                  \
00140       {                                                                                                   \
00141         DEBTRACE( ex.what() );                                                                            \
00142         return ex.getInfo();                                                                              \
00143       }                                                                                                   \
00144     catch ( ... )                                                                                         \
00145       {                                                                                                   \
00146         DEBTRACE("Unexpected exception " );                                                               \
00147         return CalciumTypes::CPATAL;                                                                      \
00148       }                                                                                                   \
00149     DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Valeur de data :" << data )                \
00150     return CalciumTypes::CPOK;                                                                            \
00151   };                                                                                                      \
00152 
00153 
00154 #endif