SALOME documentation central

src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx

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