X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FDSC%2FDSC_User%2FDatastream%2FCalcium%2FCalciumCxxInterface.hxx;h=df471fe019144399e19e70b77a6023fd1fe5c022;hb=HEAD;hp=c8fe3e278da0d0fec0a0b6e73eed25808a365e0c;hpb=641929d327319a80b4fc6f6157605a21f46413c4;p=modules%2Fkernel.git diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx old mode 100755 new mode 100644 index c8fe3e278..df471fe01 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -57,7 +57,6 @@ struct IsSameType { extern const char * CPMESSAGE[]; -//#define MYDEBUG #include @@ -102,11 +101,12 @@ namespace CalciumInterface { // calcium_uses_port* myCalciumUsesPort= // dynamic_cast(myUsesPort); -#ifdef MYDEBUG - std::cerr << "-------- CalciumInterface(ecp_fin) MARK 1 -|"<< *it <<"|----"<< - // typeid(myUsesPort).name() <<"-------------" << - typeid(myCalciumUsesPort).name() <<"-------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cerr << "-------- CalciumInterface(ecp_fin) MARK 1 -|" << *it << "|----" << + //typeid(myUsesPort).name() <<"-------------" << + typeid(myCalciumUsesPort).name() << "-------------" << std::endl; + } // if ( !myCalciumUsesPort ) // throw Superv_Component_i::BadCast(LOC(OSS()<<"Impossible de convertir le port " @@ -195,9 +195,8 @@ namespace CalciumInterface { CorbaDataType corbaData; -#ifdef MYDEBUG - std::cerr << "-------- CalciumInterface(ecp_lecture) MARK 1 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "-------- CalciumInterface(ecp_lecture) MARK 1 ------------------" << std::endl; if (nomVar.empty()) { @@ -205,20 +204,21 @@ namespace CalciumInterface { throw CalciumException(CalciumTypes::CPNMVR, LOC("Empty variable name")); } PortType * port; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(lecture) MARK 2 --"< (nomVar.c_str()); -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 3 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 3 ------------------" << std::endl; } catch ( const Superv_Component_i::PortNotDefined & ex) { @@ -265,9 +265,9 @@ namespace CalciumInterface { Engines_DSC_interface::writeEvent("BEGIN_READ",containerName,componentName,nomVar.c_str(),"",msg.str().c_str()); corbaData = port->get(tt,tf, 0); msgout << "read t=" << tt ; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 5 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 5 ------------------" << std::endl; } catch ( const DSC_Exception & ex) { @@ -283,9 +283,9 @@ namespace CalciumInterface { Engines_DSC_interface::writeEvent("BEGIN_READ",containerName,componentName,nomVar.c_str(),"",msg.str().c_str()); corbaData = port->get(0, i); msgout << "read i=" << i ; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 6 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 6 ------------------" << std::endl; } catch ( const DSC_Exception & ex) { @@ -298,9 +298,9 @@ namespace CalciumInterface { // Sequential read try { -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 7 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 7 ------------------" << std::endl; + Engines_DSC_interface::writeEvent("BEGIN_READ",containerName,componentName,nomVar.c_str(),"","Sequential read"); corbaData = port->next(ti,i); msgout << "read "; @@ -314,13 +314,13 @@ namespace CalciumInterface { } } -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 8 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 8 ------------------" << std::endl; + size_t corbaDataSize = DataManipulator::size(corbaData); -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) corbaDataSize : " << corbaDataSize << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) corbaDataSize : " << corbaDataSize << std::endl; // Vérifie si l'utilisateur demande du 0 copie if ( data == NULL ) @@ -332,9 +332,10 @@ namespace CalciumInterface { nRead = corbaDataSize; // Si les types T1 et InnerType sont différents, il faudra effectuer tout de même une recopie if (!IsSameType::value) data = new T1[nRead]; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 9 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 9 ------------------" << std::endl; + // On essaye de faire du 0 copy si les types T1 et InnerType sont les mêmes. // Copy2UserSpace : // La raison d'être du foncteur Copy2UserSpace est qu'il n'est pas possible de compiler @@ -344,9 +345,10 @@ namespace CalciumInterface { // En utilisant le foncteur Copy2UserSpace, seule la spécialisation en adéquation // avec la compatibilité des types sera compilée Copy2UserSpace< IsSameType::value, DataManipulator >::apply(data,corbaData,nRead); -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 10 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 10 ------------------" << std::endl; + // Attention : Seul CalciumCouplingPolicy via eraseDataId doit décider de supprimer ou non // la donnée corba associée à un DataId ! Ne pas effectuer la desallocation suivante : // DataManipulator::delete_data(corbaData); @@ -359,24 +361,28 @@ namespace CalciumInterface { // de désallouer un buffer intermédiaire ( types différents) ou de rendre la propriété } else - { - nRead = std::min < size_t > (corbaDataSize,bufferLength); -#ifdef MYDEBUG + { + nRead = std::min < size_t > (corbaDataSize,bufferLength); + + if (SALOME::VerbosityActivated()) std::cout << "-------- CalciumInterface(ecp_lecture) MARK 11 ------------------" << std::endl; -#endif - Copy2UserSpace::apply(data,corbaData,nRead); - //Déjà fait ci-dessus : - //DataManipulator::copy(corbaData,data,nRead); -#ifdef MYDEBUG + + Copy2UserSpace::apply(data,corbaData,nRead); + //Déjà fait ci-dessus : + //DataManipulator::copy(corbaData,data,nRead); + + if (SALOME::VerbosityActivated()) std::cout << "-------- CalciumInterface(ecp_lecture) MARK 12 ------------------" << std::endl; -#endif - } -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecp_lecture), Valeur de data : " << std::endl; - std::copy(data,data+nRead,std::ostream_iterator(std::cout," ")); - std::cout << "Ptr :" << data << std::endl; - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 13 ------------------" << std::endl; -#endif + } + + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- CalciumInterface(ecp_lecture), Valeur de data : " << std::endl; + std::copy(data,data+nRead,std::ostream_iterator(std::cout," ")); + std::cout << "Ptr :" << data << std::endl; + std::cout << "-------- CalciumInterface(ecp_lecture) MARK 13 ------------------" << std::endl; + } + Engines_DSC_interface::writeEvent("END_READ",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPOK],msgout.str().c_str()); return; } @@ -432,29 +438,31 @@ namespace CalciumInterface { CalciumTypes::DependencyType _dependencyType= static_cast(dependencyType); -#ifdef MYDEBUG - std::cerr << "-------- CalciumInterface(ecriture) MARK 1 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "-------- CalciumInterface(ecriture) MARK 1 ------------------" << std::endl; + if ( nomVar.empty() ) { Engines_DSC_interface::writeEvent("WRITE",containerName,componentName,"",CPMESSAGE[CalciumTypes::CPNMVR],""); throw CalciumException(CalciumTypes::CPNMVR, LOC("Empty variable name")); } UsesPortType * port; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture) MARK 2 ---"< (nomVar.c_str()); -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture) MARK 3 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecriture) MARK 3 ------------------" << std::endl; } catch ( const Superv_Component_i::PortNotDefined & ex) { @@ -518,9 +526,9 @@ namespace CalciumInterface { } CorbaDataType corbaData; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture) MARK 4 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecriture) MARK 4 ------------------" << std::endl; // Si les types Utilisateurs et CORBA sont différents // il faut effectuer une recopie sinon on utilise directement le @@ -542,12 +550,13 @@ namespace CalciumInterface { // OLD : Il faut effectuer une copie dans le port provides. // OLD : Cette copie est effectuée dans GenericPortUses::put // OLD : en fonction de la collocalisation ou non. -#ifdef MYDEBUG - T1_without_extent t1b; - InnerType t2b; - std::cout << "-------- CalciumInterface(ecriture) MARK 4b1 -----" << typeid(t1b).name() << "-------------" << std::endl; - std::cout << "-------- CalciumInterface(ecriture) MARK 4b2 -----" << typeid(t2b).name() << "-------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + T1_without_extent t1b; + InnerType t2b; + std::cout << "-------- CalciumInterface(ecriture) MARK 4b1 -----" << typeid(t1b).name() << "-------------" << std::endl; + std::cout << "-------- CalciumInterface(ecriture) MARK 4b2 -----" << typeid(t2b).name() << "-------------" << std::endl; + } Copy2CorbaSpace::value, DataManipulator >::apply(corbaData,_data,bufferLength); @@ -568,9 +577,8 @@ namespace CalciumInterface { } //Le -1 peut être traité par le cst DataIdContainer et transformé en 0 //Etre obligé de mettre une étoile ds (*corbadata) va poser des pb pour les types <> seq -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl; } else if ( _dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { @@ -586,27 +594,27 @@ namespace CalciumInterface { Engines_DSC_interface::writeEvent("WRITE",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPATAL],ex.what()); throw (CalciumException(CalciumTypes::CPATAL,ex.what())); } -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl; } -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl; - for (int i = 0; i < corbaData->length(); ++i) - std::cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl; + for (int i = 0; i < corbaData->length(); ++i) + std::cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << std::endl; + } // if ( !IsSameType::value ) delete corbaData; // Supprime l'objet CORBA avec eventuellement les données qu'il contient (cas de la recopie) delete corbaData; -#ifdef MYDEBUG - std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl; return; - }; + } template static void ecp_ecriture ( Superv_Component_i & component, @@ -618,7 +626,7 @@ namespace CalciumInterface { T1 const & data ) { ecp_ecriture (component,dependencyType,t,i,nomVar,bufferLength,data); - }; + } static inline void ecp_fini(Superv_Component_i & component,const std::string & nomVar,long const & i) @@ -677,7 +685,7 @@ namespace CalciumInterface { msg << "i<=" << i ; Engines_DSC_interface::writeEvent("CP_FINI",containerName,componentName,nomVar.c_str(),"",msg.str().c_str()); - }; + } static inline void ecp_fint(Superv_Component_i & component,const std::string & nomVar,double const & t) @@ -736,7 +744,7 @@ namespace CalciumInterface { msg << "t<=" << t ; Engines_DSC_interface::writeEvent("CP_FINT",containerName,componentName,nomVar.c_str(),"",msg.str().c_str()); - }; + } static inline void ecp_effi(Superv_Component_i & component,const std::string & nomVar,long const & i) @@ -795,7 +803,7 @@ namespace CalciumInterface { msg << "i>=" << i ; Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),"",msg.str().c_str()); - }; + } static inline void ecp_efft(Superv_Component_i & component,const std::string & nomVar,double const & t) @@ -854,8 +862,8 @@ namespace CalciumInterface { msg << "t>=" << t ; Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),"",msg.str().c_str()); - }; + } -}; +} #endif