From 5b7bbcc7b1335fcd3aca6dc39490e56b1c5934b3 Mon Sep 17 00:00:00 2001 From: Konstantin LEONTEV Date: Fri, 7 Oct 2022 14:09:44 +0300 Subject: [PATCH] [bos #32517][EDF] Dynamic log messages switched on and off by SALOME_VERBOSE environment variable --- src/DSC/DSC_Basic/DSC_i.cxx | 11 +- src/DSC/DSC_Basic/DSC_interface.cxx | 19 +- .../DSC_User/Datastream/AdjacentFunctor.hxx | 38 ++- .../Datastream/Calcium/CalciumCInterface.cxx | 11 +- .../Calcium/CalciumCouplingPolicy.cxx | 12 +- .../Calcium/CalciumCouplingPolicy.hxx | 178 +++++----- .../Calcium/CalciumCxxInterface.hxx | 192 ++++++----- .../Calcium/CalciumGenericUsesPort.hxx | 3 +- .../Calcium/CalciumMacroCInterface.hxx | 20 +- .../Datastream/Calcium/Copy2CorbaSpace.hxx | 45 ++- .../Datastream/Calcium/Copy2UserSpace.hxx | 70 ++-- .../Datastream/CorbaTypeManipulator.hxx | 52 +-- src/DSC/DSC_User/Datastream/GenericPort.hxx | 321 +++++++++--------- .../DSC_User/Datastream/GenericUsesPort.hxx | 11 +- src/DSC/DSC_User/Superv_Component_i.cxx | 22 +- src/DSC/DSC_User/Superv_Component_i.hxx | 22 +- src/GenericObj/SALOME_GenericObj_i.cc | 22 +- src/Launcher/SALOME_Launcher_Handler.cxx | 2 +- .../SALOME_ModuleCatalog_Acomponent_impl.cxx | 84 +++-- .../SALOME_ModuleCatalog_Client.cxx | 2 +- .../SALOME_ModuleCatalog_Handler.cxx | 15 +- .../SALOME_ModuleCatalog_impl.cxx | 81 +++-- src/NamingService/SALOME_NamingService.cxx | 2 +- src/Registry/RegistryService.cxx | 4 +- src/Registry/SALOME_Registry_Server.cxx | 8 +- src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx | 8 +- src/SALOMEDS/SALOMEDS_Client.cxx | 16 +- src/SALOMELocalTrace/CMakeLists.txt | 3 + src/SALOMELocalTrace/libSALOMELog.cxx | 72 ++++ src/SALOMELocalTrace/libSALOMELog.hxx | 38 +++ src/SALOMELocalTrace/utilities.h | 39 +-- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx | 16 +- 32 files changed, 751 insertions(+), 688 deletions(-) create mode 100644 src/SALOMELocalTrace/libSALOMELog.cxx create mode 100644 src/SALOMELocalTrace/libSALOMELog.hxx diff --git a/src/DSC/DSC_Basic/DSC_i.cxx b/src/DSC/DSC_Basic/DSC_i.cxx index 62835e39a..5d34a8707 100644 --- a/src/DSC/DSC_Basic/DSC_i.cxx +++ b/src/DSC/DSC_Basic/DSC_i.cxx @@ -26,7 +26,6 @@ // #include "DSC_i.hxx" -//#define MYDEBUG Engines_DSC_i:: Engines_DSC_i(CORBA::ORB_ptr orb, @@ -43,9 +42,8 @@ Engines_DSC_i(CORBA::ORB_ptr orb, false ) { -#ifdef MYDEBUG - std::cerr << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; } Engines_DSC_i:: @@ -58,9 +56,8 @@ Engines_DSC_i(CORBA::ORB_ptr orb, bool regist) : Engines_Component_i(orb, poa, container, instanceName, interfaceName,notif,regist) { -#ifdef MYDEBUG - std::cerr << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; } Engines_DSC_i::~Engines_DSC_i() {} diff --git a/src/DSC/DSC_Basic/DSC_interface.cxx b/src/DSC/DSC_Basic/DSC_interface.cxx index e67d6b396..82a911b97 100644 --- a/src/DSC/DSC_Basic/DSC_interface.cxx +++ b/src/DSC/DSC_Basic/DSC_interface.cxx @@ -35,7 +35,7 @@ #include #include -//#define MYDEBUG +#include "utilities.h" Engines_DSC_interface::Engines_DSC_interface() {} @@ -154,9 +154,10 @@ Engines_DSC_interface::get_uses_port(const char* uses_port_name) Engines::DSC::BadPortType BPT; BPT.expected = CORBA::string_dup("Expected a uses port"); BPT.received = CORBA::string_dup((std::string("Received a provides/none port : ")+uses_port_name).c_str()); -#ifdef MYDEBUG - std::cout << "---- DSC_Interface : MARK 1 ---- exception : " << uses_port_name << "----" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "---- DSC_Interface : MARK 1 ---- exception : " << uses_port_name << "----" << std::endl; + throw BPT; } @@ -165,12 +166,12 @@ Engines_DSC_interface::get_uses_port(const char* uses_port_name) rtn_port = new Engines::DSC::uses_port(my_ports[uses_port_name]->uses_port_refs); } else - { -#ifdef MYDEBUG - std::cout << "---- DSC_Interface : MARK 2 ---- exception : " << uses_port_name << "----" << std::endl; -#endif + { + if (SALOME::VerbosityActivated()) + std::cout << "---- DSC_Interface : MARK 2 ---- exception : " << uses_port_name << "----" << std::endl; + throw Engines::DSC::PortNotConnected(); - } + } return rtn_port; } diff --git a/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx b/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx index 804c6959b..e167120b0 100644 --- a/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx +++ b/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx @@ -34,8 +34,7 @@ // Pour affichage #include "DisplayPair.hxx" // - -//#define MYDEBUG +#include "utilities.h" // Suppose que le container est trié template < typename T > struct AdjacentFunctor { @@ -53,31 +52,34 @@ template < typename T > struct AdjacentFunctor { // Suppose que les valeurs passées en paramètres sont triées par ordre croissant bool operator()(const T &v1) { -#ifdef MYDEBUG - std::cout << "AdjacentFunctor: " << _minValue << _maxValue << std::endl; - std::cout << "AdjacentFunctor: " << _min << _max << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "AdjacentFunctor: " << _minValue << _maxValue << std::endl; + std::cout << "AdjacentFunctor: " << _min << _max << std::endl; + } + if ( v1 <= _minValue && v1 >= _maxValue) { _equal= true; -#ifdef MYDEBUG - std::cout << "AdjacentFunctor: _equal : " << v1 << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "AdjacentFunctor: _equal : " << v1 << std::endl; + return true; } if ( v1 < _minValue ) { _min=v1;_minFound=true; -#ifdef MYDEBUG - std::cout << "AdjacentFunctor: _minFound : " <<_min << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "AdjacentFunctor: _minFound : " <<_min << std::endl; } else if ( v1 > _maxValue ) { _max=v1;_maxFound=true; -#ifdef MYDEBUG - std::cout << "AdjacentFunctor: _maxFound : " <<_max << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "AdjacentFunctor: _maxFound : " <<_max << std::endl; } @@ -104,9 +106,9 @@ template < typename T > struct AdjacentFunctor { bool isEqual() const { return _equal;} bool isBounded() const { return _minFound && _maxFound;} bool getBounds(TNoConst & min, TNoConst & max) const { -#ifdef MYDEBUG - std::cout << "_minFound : " <<_minFound << ", _maxFound " << _maxFound << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "_minFound : " <<_minFound << ", _maxFound " << _maxFound << std::endl; + if (_minFound && _maxFound ) { min=_min; max=_max; return true; } return false; } diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx index 5e410c436..143aa2ec9 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx @@ -23,13 +23,10 @@ #include -//#define MYDEBUG -#ifdef MYDEBUG -#define DEBTRACE(msg) {std::cerr<::value_type value_type; -#ifdef MYDEBUG - std::cout << "-------- Calcium Generic BoundedDataIdProcessor.apply() called " << std::endl; -#endif - + if (SALOME::VerbosityActivated()) + std::cout << "-------- Calcium Generic BoundedDataIdProcessor.apply() called " << std::endl; } }; @@ -203,60 +200,67 @@ struct CalciumCouplingPolicy::BoundedDataIdProcessor< MapIterator it2=it1; ++it2; size_t dataSize1 = DataManipulator::size(it1->second); -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Taille de donnée dataId1 : " << dataSize1 << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Taille de donnée dataId1 : " << dataSize1 << std::endl; // Gérer dans calcium la limite de la taille du buffer donnée par // l'utilisateur. size_t dataSize2 = DataManipulator::size(it2->second); -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Taille de donnée dataId2 : " << dataSize2 << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Taille de donnée dataId2 : " << dataSize2 << std::endl; size_t dataSize = std::min< size_t >( dataSize1, dataSize2 ); DataId dataId2 = it2->first; DataId dataId1 = it1->first; TimeType t2 = dataId2.first; TimeType t1 = dataId1.first; -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t1 : " << t1 << std::endl; - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t2 : " << t2 << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t1 : " << t1 << std::endl; + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t2 : " << t2 << std::endl; + } + TimeType t = dataId.first; -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t : " << t << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t : " << t << std::endl; + TimeType timeDiff = t2-t1; -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de timeDiff : " << timeDiff << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de timeDiff : " << timeDiff << std::endl; + TimeType coeff = (t2-t)/timeDiff; -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de coeff : " << coeff << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de coeff : " << coeff << std::endl; InnerType const * const InIt1 = DataManipulator::getPointer(it1->second); -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données à t1 : " << std::endl; - std::copy(InIt1,InIt1+dataSize1,std::ostream_iterator(std::cout," ")); - std::cout << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données à t1 : " << std::endl; + std::copy(InIt1,InIt1+dataSize1,std::ostream_iterator(std::cout," ")); + std::cout << std::endl; + } + InnerType const * const InIt2 = DataManipulator::getPointer(it2->second); -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données à t2 : " << std::endl; - std::copy(InIt2,InIt2+dataSize2,std::ostream_iterator(std::cout," ")); - std::cout << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données à t2 : " << std::endl; + std::copy(InIt2,InIt2+dataSize2,std::ostream_iterator(std::cout," ")); + std::cout << std::endl; + } Type dataOut = DataManipulator::create(dataSize); InnerType * const OutIt = DataManipulator::getPointer(dataOut); -#ifdef MYDEBUG - std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : interpolationSchem : " << _couplingPolicy._interpolationSchem << std::endl; - std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : alpha : " << _couplingPolicy._alpha << std::endl; - std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : datecalschem : " << _couplingPolicy._dateCalSchem << std::endl; - std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : storageLevel : " << _couplingPolicy._storageLevel << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : interpolationSchem : " << _couplingPolicy._interpolationSchem << std::endl; + std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : alpha : " << _couplingPolicy._alpha << std::endl; + std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : datecalschem : " << _couplingPolicy._dateCalSchem << std::endl; + std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : storageLevel : " << _couplingPolicy._storageLevel << std::endl; + } + if ( timeDiff == 0.0 || _couplingPolicy._interpolationSchem == CalciumTypes::L0_SCHEM ) { std::copy(InIt1,InIt1+dataSize,OutIt); } else { @@ -272,11 +276,13 @@ struct CalciumCouplingPolicy::BoundedDataIdProcessor< // } } -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données calculées à t : " << std::endl; - std::copy(OutIt,OutIt+dataSize,std::ostream_iterator(std::cout," ")); - std::cout << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données calculées à t : " << std::endl; + std::copy(OutIt,OutIt+dataSize,std::ostream_iterator(std::cout," ")); + std::cout << std::endl; + } data = dataOut; } @@ -297,10 +303,12 @@ bool CalciumCouplingPolicy::isDataIdConveniant( AssocContainer & storedDatas, co AdjacentFunctor< key_type > af(expectedDataId); if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY ) { -#ifdef MYDEBUG - std::cout << "-------- time expected : " << expectedDataId.first << std::endl; - std::cout << "-------- time expected corrected : " << expectedDataId.first*(1.0-_deltaT) << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- time expected : " << expectedDataId.first << std::endl; + std::cout << "-------- time expected corrected : " << expectedDataId.first*(1.0-_deltaT) << std::endl; + } + af.setMaxValue(key_type(expectedDataId.first*(1.0-_deltaT),0)); } isBounded = false; @@ -324,9 +332,11 @@ bool CalciumCouplingPolicy::isDataIdConveniant( AssocContainer & storedDatas, co typename AssocContainer::iterator current = prev; while ( (current != storedDatas.end()) && !af(current->first) ) { -#ifdef MYDEBUG - std::cerr << "------- stored time : " << current->first << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cerr << "------- stored time : " << current->first << std::endl; + } + // if ( af(current->first) ) break; prev = current++; } @@ -343,9 +353,8 @@ bool CalciumCouplingPolicy::isDataIdConveniant( AssocContainer & storedDatas, co else wDataIt1 = storedDatas.end(); -#ifdef MYDEBUG - std::cout << "-------- isDataIdConvenient : isEqual : " << isEqual << " , isBounded " << isBounded << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- isDataIdConvenient : isEqual : " << isEqual << " , isBounded " << isBounded << std::endl; return isEqual || isBounded; } @@ -437,9 +446,8 @@ struct CalciumCouplingPolicy::EraseDataIdProcessor { typedef typename Container::value_type value_type; typedef typename Container::iterator iterator; -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::eraseDataId, storedDatasSize : " << storedDatas.size() << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::eraseDataId, storedDatasSize : " << storedDatas.size() << std::endl; if ( _couplingPolicy._storageLevel == (size_t)CalciumTypes::UNLIMITED_STORAGE_LEVEL ) return; @@ -459,9 +467,10 @@ struct CalciumCouplingPolicy::EraseDataIdProcessor { " has just removed the data to send"))); } } -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::eraseDataId, new storedDatasSize : " << storedDatas.size() << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::eraseDataId, new storedDatasSize : " << storedDatas.size() << std::endl; + return; } @@ -493,23 +502,20 @@ struct CalciumCouplingPolicy::DisconnectProcessor { typedef typename Container::iterator iterator; // Pas de traitement particulier a effectuer -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK1 ("<< _couplingPolicy._disconnectDirective<<") --------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK1 ("<< _couplingPolicy._disconnectDirective<<") --------" << std::endl; + if ( (_couplingPolicy._disconnectDirective) == (CalciumTypes::UNDEFINED_DIRECTIVE) ) return false; -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK2 --------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK2 --------" << std::endl; // TODO : Ds GenericPort::next il faut convertir en CPSTOPSEQ if ( _couplingPolicy._disconnectDirective == CalciumTypes::CP_ARRET ) throw(CalciumException(CalciumTypes::CPINARRET,LOC(OSS()<< "CP_ARRET directive" << " interrupts all further data reading"))); -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK3 --------" << std::endl; -#endif - + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK3 --------" << std::endl; // S'il n'y a plus de données indique que l'on a pas pu effectuer de traitement // TODO : Dans la gestion des niveaux il faut peut être interdire un niveau == 0 @@ -521,33 +527,33 @@ struct CalciumCouplingPolicy::DisconnectProcessor { // qu'en mode itératif il ne soit pas plus grand que le plus grand DataId stocké auquel // cas on doit renvoyer une expection car on n'est plus connecté et on ne pourra jamais // fournir de données pour ce dataId. -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK4 " << expectedDataId <<" --------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK4 " << expectedDataId <<" --------" << std::endl; // >= expectedDataId iterator it1 = storedDatas.lower_bound(expectedDataId); -#ifdef MYDEBUG - std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK5 " << std::endl; - for (iterator it=storedDatas.begin();it!=storedDatas.end();++it) - std::cout <<" "<<(*it).first ; - std::cout < { 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,24 +594,24 @@ 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; } diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx index c207d6be7..67ccf93c9 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericUsesPort.hxx @@ -54,9 +54,8 @@ CalciumGenericUsesPort< DataManipulator,CorbaPortType, repositoryName >::disconn for(int i = 0; i < (int)this->_my_ports->length(); i++) { CorbaPortTypePtr port = CorbaPortType::_narrow((*this->_my_ports)[i]); try { -#ifdef MYDEBUG + if (SALOME::VerbosityActivated()) std::cerr << "-------- CalciumGenericUsesPort<>::disconnect: "<< i << std::endl; -#endif port->disconnect(provideLastGivenValue); } catch(const CORBA::SystemException& ex){ diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx index ef3c97b12..181efcff3 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumMacroCInterface.hxx @@ -76,7 +76,7 @@ Id : $Id$ size_t _bufferLength=bufferLength; \ \ if ( IsSameType< _porttype , cplx >::value ) _bufferLength*=2; \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) \ + DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ); \ try \ { \ CalciumInterface::ecp_lecture< _type,_porttype >( *_component, dependencyType, _ti, _tf, *i, nomvar, \ @@ -89,21 +89,21 @@ Id : $Id$ } \ catch ( ... ) \ { \ - DEBTRACE( "Unexpected exception ") ; \ + DEBTRACE( "Unexpected exception "); \ return CalciumTypes::CPATAL; \ } \ if ( IsSameType< _porttype , cplx >::value ) \ { \ *nRead=_nRead/2; \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" ) \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part) _nRead : " << _nRead ) \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part) *nRead : " << *nRead ) \ + DEBTRACE( "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" ); \ + DEBTRACE( "-------- CalciumInterface(lecture Inter Part) _nRead : " << _nRead ); \ + DEBTRACE( "-------- CalciumInterface(lecture Inter Part) *nRead : " << *nRead ); \ } \ else \ *nRead = _nRead; \ if (dependencyType == CalciumTypes::CP_SEQUENTIEL ) \ *ti=(CalTimeType< _type _qual >::TimeType)(_ti); \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) \ + DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ); \ return CalciumTypes::CPOK; \ } \ \ @@ -120,7 +120,7 @@ Id : $Id$ const char * const nomvar, size_t bufferLength, \ _type _qual * data ) \ { \ - DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 0 ------------------" ) \ + DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 0 ------------------" ); \ Superv_Component_i * _component = static_cast(component); \ /* Je ne sais pas pourquoi, je n'arrive pas à passer t par valeur : corruption de la pile*/ \ double _t=0.; \ @@ -128,11 +128,11 @@ Id : $Id$ _t=*t; \ size_t _bufferLength=bufferLength; \ if ( IsSameType< _porttype , cplx >::value ) _bufferLength=_bufferLength*2; \ - DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ) \ + DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ); \ try \ { \ /*printf("-------- CalciumInterface(ecriture Inter Part), cp_name : Nom de la var. de type %s : %s\n",#_type,nomvar);*/ \ - DEBTRACE( "----------->-" << nomvar ) \ + DEBTRACE( "----------->-" << nomvar ); \ CalciumInterface::ecp_ecriture< _type, _porttype >( *_component, dependencyType, \ _t,i,nomvar,_bufferLength,*data); \ } \ @@ -146,7 +146,7 @@ Id : $Id$ DEBTRACE("Unexpected exception " ); \ return CalciumTypes::CPATAL; \ } \ - DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Valeur de data :" << data ) \ + DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Valeur de data :" << data ); \ return CalciumTypes::CPOK; \ } \ diff --git a/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx b/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx index 5d01cd5e1..eb1801c3e 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx @@ -35,7 +35,6 @@ #include #include "CalciumPortTraits.hxx" -//#define MYDEBUG template struct Copy2CorbaSpace { @@ -48,19 +47,17 @@ struct Copy2CorbaSpace { //ESSAI: typedef typename PortType::DataManipulator DataManipulator; typedef typename DataManipulator::InnerType InnerType; -#ifdef MYDEBUG - std::cerr << "-------- Copy2CorbaSpace MARK 1 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "-------- Copy2CorbaSpace MARK 1 ------------------" << std::endl; + // Crée le type corba à partir du data sans lui en donner la propriété. // Le const_cast supprime le caractère const du type T2 const & de data car // DataManipulator::create n'a pas le caractère const sur son paramètre data pour le // cas de figure où la propriété de la donnée lui est donnée. corbaData = DataManipulator::create(nRead,const_cast (&data),false); -#ifdef MYDEBUG - std::cerr << "-------- Copy2CorbaSpace MARK 2 --(dataPtr : " + if (SALOME::VerbosityActivated()) + std::cerr << "-------- Copy2CorbaSpace MARK 2 --(dataPtr : " << DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl; -#endif - } }; @@ -79,25 +76,25 @@ Copy2CorbaSpace { corbaData = DataManipulator::create(nRead); InnerType * dataPtr = DataManipulator::getPointer(corbaData,false); -#ifdef MYDEBUG - std::cerr << "-------- Copy2CorbaSpace MARK 1 --(dataPtr : " << - dataPtr<<")----------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "-------- Copy2CorbaSpace MARK 1 --(dataPtr : " << + dataPtr<<")----------------" << std::endl; + // Attention : Pour les chaines ou tout autre object complexe il faut utiliser une recopie profonde ! std::copy(&data,&data+nRead,dataPtr); -#ifdef MYDEBUG - std::cerr << "-------- Copy2CorbaSpace MARK 2 --(nRead: "< MARK 3 : " ; - std::copy(dataPtr,dataPtr+nRead,std::ostream_iterator(std::cout," ")); - std::cout << std::endl; - std::cerr << "-------- Copy2CorbaSpace MARK 4 --(data : " < MARK 2 --(nRead: "< MARK 3 : " ; + std::copy(dataPtr,dataPtr+nRead,std::ostream_iterator(std::cout," ")); + std::cout << std::endl; + std::cerr << "-------- Copy2CorbaSpace MARK 4 --(data : " < -//#define MYDEBUG - //Les demandes de copies vers l'espace utilisateur //proviennent d'une procédure de lecture @@ -105,31 +103,30 @@ struct Copy2UserSpace { //Recopie le contenu de la donnée CORBA dans le buffer utilisateur de longueur nRead template static void apply( T1 * &data, T2 & corbaData, size_t nRead){ - - typedef typename DataManipulator::InnerType InnerType; + typedef typename DataManipulator::InnerType InnerType; - -#ifdef MYDEBUG - InnerType * dataPtr = NULL; - // Affiche la valeur du pointeur de la structure corba - // et les pointeurs contenus le cas échéant - dataPtr = DataManipulator::getPointer(corbaData,false); - std::cerr << "-------- Copy2UserSpace MARK 1a --dataPtr("<(std::cerr," ")); - for (int i=0; i< DataManipulator::size(corbaData); ++i) - fprintf(stderr,"pointer[%d]=%p ",i, dataPtr[i]); - std::cerr << std::endl; - - T1 * tmpData = data; - //Cette affichage peut provoquer la détection d'écriture d'un espace non initailisé. - std::cerr << "-------- Copy2UserSpace MARK 1b --data("<(std::cerr," ")); - for (int i=0; i< DataManipulator::size(corbaData); ++i) - fprintf(stderr,"pointer[%d]=%p ",i, tmpData[i]); - std::cerr << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + InnerType * dataPtr = NULL; + // Affiche la valeur du pointeur de la structure corba + // et les pointeurs contenus le cas échéant + dataPtr = DataManipulator::getPointer(corbaData,false); + std::cerr << "-------- Copy2UserSpace MARK 1a --dataPtr("<(std::cerr," ")); + for (int i=0; i< DataManipulator::size(corbaData); ++i) + fprintf(stderr,"pointer[%d]=%p ",i, dataPtr[i]); + std::cerr << std::endl; + + T1 * tmpData = data; + //Cette affichage peut provoquer la détection d'écriture d'un espace non initailisé. + std::cerr << "-------- Copy2UserSpace MARK 1b --data("<(std::cerr," ")); + for (int i=0; i< DataManipulator::size(corbaData); ++i) + fprintf(stderr,"pointer[%d]=%p ",i, tmpData[i]); + std::cerr << std::endl; + } // Pour les types pointeurs et ref il faut effectuer une recopie profonde. // On la délègue au manipulateur de données. @@ -142,18 +139,17 @@ struct Copy2UserSpace { //std::copy(dataPtr,dataPtr+nRead,data); DataManipulator::copy(corbaData,data,nRead); -#ifdef MYDEBUG - tmpData = data; - std::cerr << "-------- Copy2UserSpace MARK 1c --data("<(std::cerr," ")); - for (int i=0; i< DataManipulator::size(corbaData); ++i) - fprintf(stderr,"pointer[%d]=%p ",i, tmpData[i]); - std::cerr << std::endl; -#endif - + if (SALOME::VerbosityActivated()) + { + T1 * tmpData = data; + std::cerr << "-------- Copy2UserSpace MARK 1c --data("<(std::cerr," ")); + for (int i=0; i< DataManipulator::size(corbaData); ++i) + fprintf(stderr,"pointer[%d]=%p ",i, tmpData[i]); + std::cerr << std::endl; + } } - }; diff --git a/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx b/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx index 098edb989..d2f217ada 100644 --- a/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx +++ b/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx @@ -30,12 +30,12 @@ #ifndef _CORBA_TYPE_MANIPULATION_HXX_ #define _CORBA_TYPE_MANIPULATION_HXX_ +#include "utilities.h" + #include #include #include -//#define MYDEBUG - // Classes manipulation // ------------------- // @@ -229,24 +229,24 @@ public: // En non collocalisé on recrée une séquence avec le buffer de la première dont on // a demandé la propriété. -#ifdef MYDEBUG - std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1 ------------------" << std::endl; + if ( data.release() ) { InnerType * p_data = const_cast(data).get_buffer(true); // Crée une nouvelle sequence propriétaire des données du buffer (pas de recopie) // Les données de la nouvelle séquence seront automatiquement désallouées // par appel à la méthode freebuf dans le destructeur de la séquence (cf delete_data). -#ifdef MYDEBUG - std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1(0 copy) bis ------"<< p_data <<"------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1(0 copy) bis ------" << p_data << "------------" << std::endl; return new seq_T (max, len, p_data, true); } -#ifdef MYDEBUG - std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1(recopie) bis ------"<< &data <<"------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1(recopie) bis ------" << &data << "------------" << std::endl; + // Crée une nouvelle sequence propriétaire des données du buffer (avec recopie) return new seq_T(data); @@ -393,23 +393,23 @@ public: // Récupère et devient propriétaire des données reçues dans la séquence // la séquence sera désalloué (mais pas le buffer) // au retour de la méthode put (car mapping de type IN : const seq & ) - if ( data.release() ) { - InnerType * p_data = const_cast(data).get_buffer(true); - - // Crée une nouvelle sequence propriétaire des données du buffer (généralement pas de recopie) - // Les données seront automatiquement désallouées par appel interne à la méthode freebuf - // lors de la destruction de l'objet par appel à delete_data. -#ifdef MYDEBUG - std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1bis Pas de Duplication -----------" << std::endl; -#endif - return new seq_T (len, p_data, true); - } -#ifdef MYDEBUG - std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1bis Duplication pour en devenir propriétaire -----------" << std::endl; -#endif + if ( data.release() ) { + InnerType * p_data = const_cast(data).get_buffer(true); + + // Crée une nouvelle sequence propriétaire des données du buffer (généralement pas de recopie) + // Les données seront automatiquement désallouées par appel interne à la méthode freebuf + // lors de la destruction de l'objet par appel à delete_data. + if (SALOME::VerbosityActivated()) + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1bis Pas de Duplication -----------" << std::endl; + + return new seq_T (len, p_data, true); + } + + if (SALOME::VerbosityActivated()) + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1bis Duplication pour en devenir propriétaire -----------" << std::endl; + // Crée une nouvelle sequence propriétaire des données du buffer (avec recopie) return new seq_T(data); - } static inline size_t size(Type data) { diff --git a/src/DSC/DSC_User/Datastream/GenericPort.hxx b/src/DSC/DSC_User/Datastream/GenericPort.hxx index 0e1a15ad2..5a191470a 100644 --- a/src/DSC/DSC_User/Datastream/GenericPort.hxx +++ b/src/DSC/DSC_User/Datastream/GenericPort.hxx @@ -47,8 +47,6 @@ #include #include -//#define MYDEBUG - // Classe GenericPort // -------------------------------- // @@ -111,9 +109,9 @@ template < typename DataManipulator, typename COUPLING_POLICY> GenericPort::~GenericPort() { typename DataTable::iterator it; for (it=storedDatas.begin(); it!=storedDatas.end(); ++it) { -#ifdef MYDEBUG - std::cerr << "~GenericPort() : destruction de la donnnée associée au DataId :"<< (*it).first << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "~GenericPort() : destruction de la donnnée associée au DataId :" << (*it).first << std::endl; + DataManipulator::delete_data( (*it).second ); } } @@ -129,19 +127,21 @@ GenericPort::close (PortableServer::POA_var po template < typename DataManipulator, typename COUPLING_POLICY> void GenericPort::wakeupWaiting() { -#ifdef MYDEBUG - std::cout << "-------- wakeupWaiting ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- wakeupWaiting ------------------" << std::endl; + storedDatas_mutex.lock(); if (waitingForAnyDataId || waitingForConvenientDataId) { -#ifdef MYDEBUG - std::cout << "-------- wakeupWaiting:signal --------" << std::endl; - std::cout << std::flush; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- wakeupWaiting:signal --------" << std::endl; + std::cout << std::flush; + } + cond_instance.signal(); - } - storedDatas_mutex.unlock(); + } + storedDatas_mutex.unlock(); } /* Methode put_generique @@ -157,11 +157,12 @@ void GenericPort::put(CorbaInDataType dataPara fflush(stdout); fflush(stderr); try { -#ifdef MYDEBUG - // Affichage des donnees pour DEBUGging - std::cerr << "parametres emis: " << time << ", " << tag << std::endl; - DataManipulator::dump(dataParam); -#endif + if (SALOME::VerbosityActivated()) + { + // Affichage des donnees pour DEBUGging + std::cerr << "parametres emis: " << time << ", " << tag << std::endl; + DataManipulator::dump(dataParam); + } // L'intérêt des paramètres time et tag pour ce port est décidé dans la politique de couplage // Il est possible de filtrer en prenant en compte uniquement un paramètre time/tag ou les deux @@ -180,45 +181,42 @@ void GenericPort::put(CorbaInDataType dataPara bool expectedDataReceived = false; -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 1 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 1 ------------------" << std::endl; + if ( dataIds.empty() ) return; -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 1bis ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 1bis ------------------" << std::endl; // Recupere les donnees venant de l'ORB et relâche les structures CORBA // qui n'auraient plus cours en sortie de méthode put DataType data = DataManipulator::get_data(dataParam); - int nbOfIter = 0; -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 2 ------ "<< (dataIdIt == dataIds.end()) << "------------" << std::endl; - std::cout << "-------- Put : MARK 2bis "<< (*dataIdIt) <<"------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- Put : MARK 2 ------ "<< (dataIdIt == dataIds.end()) << "------------" << std::endl; + std::cout << "-------- Put : MARK 2bis "<< (*dataIdIt) <<"------------------" << std::endl; + } storedDatas_mutex.lock(); for (;dataIdIt != dataIds.end();++dataIdIt) { + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 3 ------------------" << std::endl; -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 3 ------------------" << std::endl; -#endif // Duplique l'instance de donnée pour les autres dataIds if (nbOfIter > 0) data = DataManipulator::clone(data); -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 3bis -----"<< dataIdIt.operator*() <<"------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 3bis -----"<< dataIdIt.operator*() <<"------------" << std::endl; DataId currentDataId=*dataIdIt; -#ifdef MYDEBUG + if (SALOME::VerbosityActivated()) + { std::cerr << "processing dataId : "<< currentDataId << std::endl; - std::cout << "-------- Put : MARK 4 ------------------" << std::endl; -#endif + } // Ajoute l'instance de la donnee a sa place dans la table de données // ou remplace une instance précédente si elle existe @@ -228,24 +226,23 @@ void GenericPort::put(CorbaInDataType dataPara // <=> premier emplacement où l'on pourrait insérer notre DataId // <=> en général équivaux à (*wDataIt).first >= currentDataId typename DataTable::iterator wDataIt = storedDatas.lower_bound(currentDataId); -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 5 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 5 ------------------" << std::endl; // On n'a pas trouvé de dataId supérieur au notre ou // on a trouvé une clé > à cet Id if (wDataIt == storedDatas.end() || storedDatas.key_comp()(currentDataId,(*wDataIt).first) ) { -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 6 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 6 ------------------" << std::endl; + // Ajoute la donnee dans la table wDataIt = storedDatas.insert(wDataIt, make_pair (currentDataId, data)); } else { // Si on n'est pas en fin de liste et qu'il n'y a pas de relation d'ordre strict // entre notre dataId et le DataId pointé c'est qu'ils sont identiques -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 7 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 7 ------------------" << std::endl; + // Les données sont remplacées par les nouvelles valeurs // lorsque que le dataId existe déjà DataType old_data = (*wDataIt).second; @@ -254,19 +251,20 @@ void GenericPort::put(CorbaInDataType dataPara DataManipulator::delete_data (old_data); } -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 8 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 8 ------------------" << std::endl; + // Compte le nombre de dataIds à traiter ++nbOfIter; -#ifdef MYDEBUG - std::cout << "-------- Put : waitingForConvenientDataId : " << waitingForConvenientDataId <<"---" << std::endl; - std::cout << "-------- Put : waitingForAnyDataId : " << waitingForAnyDataId <<"---" << std::endl; - std::cout << "-------- Put : currentDataId : " << currentDataId <<"---" << std::endl; - std::cout << "-------- Put : expectedDataId : " << expectedDataId <<"---" << std::endl; - std::cout << "-------- Put : MARK 9 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- Put : waitingForConvenientDataId : " << waitingForConvenientDataId << "---" << std::endl; + std::cout << "-------- Put : waitingForAnyDataId : " << waitingForAnyDataId << "---" << std::endl; + std::cout << "-------- Put : currentDataId : " << currentDataId << "---" << std::endl; + std::cout << "-------- Put : expectedDataId : " << expectedDataId << "---" << std::endl; + std::cout << "-------- Put : MARK 9 ------------------" << std::endl; + } // A simplifier mais : // - pas possible de mettre des arguments optionnels à cause @@ -284,19 +282,20 @@ void GenericPort::put(CorbaInDataType dataPara if ( waitingForAnyDataId || ( waitingForConvenientDataId && this->isDataIdConveniant(storedDatas, expectedDataId, dummy1, dummy2, dummy3) ) - ) { -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 10 ------------------" << std::endl; -#endif + ) + { + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 10 ------------------" << std::endl; + //Doit pouvoir réveiller le get ici (a vérifier) expectedDataReceived = true; } } if (expectedDataReceived) { -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 11 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 11 ------------------" << std::endl; + // si waitingForAnyDataId était positionné, c'est forcément lui qui a activer // expectedDataReceived à true if (waitingForAnyDataId) @@ -312,22 +311,22 @@ void GenericPort::put(CorbaInDataType dataPara // Pb2 : également si deux attentes de DataIds même différents car on n'en stocke qu'un ! // Conclusion : Pour l'instant on ne gère pas un service multithreadé qui effectue // des lectures simultanées sur le même port ! -#ifdef MYDEBUG - std::cerr << "-------- Put : new datas available ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "-------- Put : new datas available ------------------" << std::endl; + fflush(stdout);fflush(stderr); cond_instance.signal(); } -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 12 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 12 ------------------" << std::endl; // Deverouille l'acces a la table : On peut remonter l'appel au dessus de expected... storedDatas_mutex.unlock(); -#ifdef MYDEBUG - std::cout << "-------- Put : MARK 13 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Put : MARK 13 ------------------" << std::endl; + fflush(stdout); fflush(stderr); @@ -373,13 +372,12 @@ GenericPort::get(TimeType time, bool isEqual, isBounded; typedef typename DataManipulator::InnerType InnerType; -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 1 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 1 ------------------" << std::endl; + expectedDataId = DataId(time,tag); -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 2 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 2 ------------------" << std::endl; typename DataTable::iterator wDataIt1; @@ -395,46 +393,44 @@ GenericPort::get(TimeType time, // - l'itérateur wDataIt1 est tel que wDataIt1->first < wdataId < (wDataIt1+1)->first // Méthode provenant de la COUPLING_POLICY this->isDataIdConveniant(storedDatas,expectedDataId,isEqual,isBounded,wDataIt1); -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 3 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 3 ------------------" << std::endl; // L'ordre des différents tests est important if ( isEqual ) { - -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 4 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 4 ------------------" << std::endl; + // La propriété de la données N'EST PAS transmise à l'utilisateur en mode CALCIUM. // Si l'utilisateur supprime la donnée, storedDataIds devient incohérent // C'est EraseDataId qui choisi ou non de supprimer la donnée // Du coup interaction potentielle entre le 0 copy et gestion de l'historique dataToTransmit = (*wDataIt1).second; -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 5 ------------------" << std::endl; - std::cout << "-------- Get : Données trouvées à t : " << std::endl; - typename DataManipulator::InnerType const * const InIt1 = DataManipulator::getPointer(dataToTransmit); - size_t N = DataManipulator::size(dataToTransmit); - std::copy(InIt1, InIt1 + N, - std::ostream_iterator< InnerType > (std::cout," ")); - std::cout << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- Get : MARK 5 ------------------" << std::endl; + std::cout << "-------- Get : Données trouvées à t : " << std::endl; + typename DataManipulator::InnerType const * const InIt1 = DataManipulator::getPointer(dataToTransmit); + size_t N = DataManipulator::size(dataToTransmit); + std::copy(InIt1, InIt1 + N, + std::ostream_iterator< InnerType > (std::cout," ")); + std::cout << std::endl; + } // Décide de la suppression de certaines instances de données // La donnée contenu dans la structure CORBA et son dataId sont désallouées // Méthode provenant de la COUPLING_POLICY typename COUPLING_POLICY::template EraseDataIdProcessor processEraseDataId(*this); processEraseDataId.apply(storedDatas,wDataIt1); -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 6 ------------------" << std::endl; -#endif - break; + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 6 ------------------" << std::endl; + break; } -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 7 ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 7 ------------------" << std::endl; //if ( isBounded() && COUPLING_POLICY::template needToProcessBoundedDataId() ) { // Le DataId demandé n'est pas trouvé mais est encadré ET la politique de couplage @@ -446,9 +442,8 @@ GenericPort::get(TimeType time, // Cependant comme les données sont censées être produites // par ordre croissant de DataId, de nouvelles données ne devrait pas améliorer // l'interpolation. -#ifdef MYDEBUG + if (SALOME::VerbosityActivated()) std::cout << "-------- Get : MARK 8 ------------------" << std::endl; -#endif typedef typename COUPLING_POLICY::template BoundedDataIdProcessor BDI; BDI processBoundedDataId(*this); @@ -464,16 +459,17 @@ GenericPort::get(TimeType time, // A déplacer en paramètre de la méthode précédente ? ou déléguer ce choix au mode de couplage ? storedDatas[expectedDataId]=dataToTransmit; -#ifdef MYDEBUG - std::cout << "-------- Get : Données calculées à t : " << std::endl; - typename DataManipulator::InnerType const * const InIt1 = DataManipulator::getPointer(dataToTransmit); - size_t N = DataManipulator::size(dataToTransmit); - - std::copy(InIt1, InIt1 + N, - std::ostream_iterator< InnerType > (std::cout," ")); - std::cout << std::endl; - std::cout << "-------- Get : MARK 9 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- Get : Données calculées à t : " << std::endl; + typename DataManipulator::InnerType const * const InIt1 = DataManipulator::getPointer(dataToTransmit); + size_t N = DataManipulator::size(dataToTransmit); + + std::copy(InIt1, InIt1 + N, + std::ostream_iterator< InnerType > (std::cout," ")); + std::cout << std::endl; + std::cout << "-------- Get : MARK 9 ------------------" << std::endl; + } typename COUPLING_POLICY::template EraseDataIdProcessor processEraseDataId(*this); processEraseDataId.apply(storedDatas,wDataIt1); @@ -488,17 +484,19 @@ GenericPort::get(TimeType time, // Réception bloquante sur le dataId demandé // Si l'instance de donnée n'est pas trouvee -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 10 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 10 ------------------" << std::endl; + //Positionné à faux dans la méthode put waitingForConvenientDataId = true; -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 11 ------------------" << std::endl; - - // Ici on attend que la méthode put recoive la donnée - std::cout << "-------- Get : waiting datas ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- Get : MARK 11 ------------------" << std::endl; + + // Ici on attend que la méthode put recoive la donnée + std::cout << "-------- Get : waiting datas ------------------" << std::endl; + } + fflush(stdout);fflush(stderr); unsigned long ts, tns,rs=Superv_Component_i::dscTimeOut; if(rs==0) @@ -518,12 +516,9 @@ GenericPort::get(TimeType time, } } - -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 12 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 12 ------------------" << std::endl; } - } catch (...) { waitingForConvenientDataId = true; storedDatas_mutex.unlock(); @@ -532,9 +527,8 @@ GenericPort::get(TimeType time, // Deverouille l'acces a la table storedDatas_mutex.unlock(); -#ifdef MYDEBUG - std::cout << "-------- Get : MARK 13 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Get : MARK 13 ------------------" << std::endl; // La propriété de la données N'EST PAS transmise à l'utilisateur en mode CALCIUM // Si l'utilisateur supprime la donnée, storedDataIds devient incohérent @@ -571,9 +565,8 @@ GenericPort::next(TimeType &t, try { storedDatas_mutex.lock();// Gérer les Exceptions ds le corps de la méthode -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 1 ---lastDataIdSet ("<::next(TimeType &t, waitingForAnyDataId = false; break; } -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 2 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 2 ------------------" << std::endl; + //Positionné à faux dans la méthode put waitingForAnyDataId = true; -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 3 ------------------" << std::endl; - // Ici on attend que la méthode put recoive la donnée - std::cout << "-------- Next : waiting datas ------------------" << std::endl; -#endif + + if (SALOME::VerbosityActivated()) + { + std::cout << "-------- Next : MARK 3 ------------------" << std::endl; + // Ici on attend que la méthode put recoive la donnée + std::cout << "-------- Next : waiting datas ------------------" << std::endl; + } + fflush(stdout);fflush(stderr); unsigned long ts, tns,rs=Superv_Component_i::dscTimeOut; if(rs==0) @@ -634,51 +630,48 @@ GenericPort::next(TimeType &t, } if (lastDataIdSet) { -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 4 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 4 ------------------" << std::endl; + wDataIt1 = storedDatas.upper_bound(lastDataId); } else { -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 5 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 5 ------------------" << std::endl; + lastDataIdSet = true; wDataIt1 = storedDatas.begin(); } } -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 6 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 6 ------------------" << std::endl; t = this->getTime( (*wDataIt1).first ); tag = this->getTag ( (*wDataIt1).first ); dataToTransmit = (*wDataIt1).second; -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 7 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 7 ------------------" << std::endl; + lastDataId = (*wDataIt1).first; typename COUPLING_POLICY::template EraseDataIdProcessor processEraseDataId(*this); processEraseDataId.apply(storedDatas, wDataIt1); -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 8 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 8 ------------------" << std::endl; } catch (...) { -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 8bis ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 8bis ------------------" << std::endl; + waitingForAnyDataId = false; storedDatas_mutex.unlock(); throw; } storedDatas_mutex.unlock(); -#ifdef MYDEBUG - std::cout << "-------- Next : MARK 9 ------------------" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "-------- Next : MARK 9 ------------------" << std::endl; // La propriété de la données N'EST PAS transmise à l'utilisateur en mode CALCIUM // Si l'utilisateur supprime la donnée, storedDataIds devient incohérent diff --git a/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx b/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx index db98331f5..631685a69 100644 --- a/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx +++ b/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx @@ -108,9 +108,8 @@ GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort >::put CorbaPortTypeVar port = CorbaPortType::_narrow((*_my_ports)[i]); //if (i) { PB1 //OLD : copyOfData = DataManipulator::clone(data); -#ifdef MYDEBUG - std::cerr << "-------- GenericUsesPort::put -------- " << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "-------- GenericUsesPort::put -------- " << std::endl; //} PB1 try { port->put(data,time,tag); @@ -138,9 +137,9 @@ GenericUsesPort< DataManipulator, CorbaPortType, repositoryName, UsesPort { if (_my_ports) delete _my_ports; -#ifdef MYDEBUG - std::cerr << "GenericUsesPort::uses_port_changed" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "GenericUsesPort::uses_port_changed" << std::endl; + _my_ports = new_uses_port; } diff --git a/src/DSC/DSC_User/Superv_Component_i.cxx b/src/DSC/DSC_User/Superv_Component_i.cxx index b7b15e330..9df08a93c 100644 --- a/src/DSC/DSC_User/Superv_Component_i.cxx +++ b/src/DSC/DSC_User/Superv_Component_i.cxx @@ -48,9 +48,9 @@ Superv_Component_i::Superv_Component_i(CORBA::ORB_ptr orb, bool /*notif*/) : Engines_DSC_i(orb, poa, contId, instanceName, interfaceName) { -#ifdef MYDEBUG - std::cerr << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; + setTimeOut(); } Superv_Component_i::Superv_Component_i(CORBA::ORB_ptr orb, @@ -62,9 +62,9 @@ Superv_Component_i::Superv_Component_i(CORBA::ORB_ptr orb, bool regist) : Engines_DSC_i(orb, poa, container, instanceName, interfaceName,notif,regist) { -#ifdef MYDEBUG - std::cerr << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; + setTimeOut(); } @@ -168,13 +168,13 @@ Superv_Component_i::add_port(const char * port_fab_type, add_port(port, port_name); } else if (s_port_type == "uses") { -#ifdef MYDEBUG + if (SALOME::VerbosityActivated()) std::cerr << "---- Superv_Component_i::add_port : MARK 1 ---- " << std::endl; -#endif + uses_port * port = create_uses_data_port(port_fab_type); -#ifdef MYDEBUG - std::cerr << "---- Superv_Component_i::add_port : MARK 2 ---- " << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cerr << "---- Superv_Component_i::add_port : MARK 2 ---- " << std::endl; + add_port(port, port_name); } else diff --git a/src/DSC/DSC_User/Superv_Component_i.hxx b/src/DSC/DSC_User/Superv_Component_i.hxx index 30d892a47..5288627ab 100644 --- a/src/DSC/DSC_User/Superv_Component_i.hxx +++ b/src/DSC/DSC_User/Superv_Component_i.hxx @@ -36,8 +36,6 @@ #include "DSC_Exception.hxx" #include -//#define MYDEBUG - /*! \class Superv_Component_i * \brief This class implements DSC_User component. * @@ -316,9 +314,8 @@ Superv_Component_i::add_port(const char * port_fab_type, assert(port_name); SpecificPortType * retPort; -#ifdef MYDEBUG - std::cout << "---- Superv_Component_i::add_port : Mark 0 ---- " << port_name << "----" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "---- Superv_Component_i::add_port : Mark 0 ---- " << port_name << "----" << std::endl; std::string s_port_type(port_type); if (s_port_type == "provides") { @@ -332,14 +329,15 @@ Superv_Component_i::add_port(const char * port_fab_type, else if (s_port_type == "uses") { uses_port * port = create_uses_data_port(port_fab_type); add_port(port, port_name); -#ifdef MYDEBUG - std::cout << "---- Superv_Component_i::add_port : Mark 1 ---- " << port << "----" << std::endl; - std::cout << "---- Superv_Component_i::add_port : Mark 1 ---- get_repository_id()" << port->get_repository_id() << std::endl; -#endif + if (SALOME::VerbosityActivated()) + { + std::cout << "---- Superv_Component_i::add_port : Mark 1 ---- " << port << "----" << std::endl; + std::cout << "---- Superv_Component_i::add_port : Mark 1 ---- get_repository_id()" << port->get_repository_id() << std::endl; + } retPort = dynamic_cast(port); -#ifdef MYDEBUG - std::cout << "---- Superv_Component_i::add_port : Mark 2 ---- " << retPort << "----" << std::endl; -#endif + if (SALOME::VerbosityActivated()) + std::cout << "---- Superv_Component_i::add_port : Mark 2 ---- " << retPort << "----" << std::endl; + if ( retPort == NULL ) { delete port; throw BadCast( LOC("Can't cast to asked port type " )); } diff --git a/src/GenericObj/SALOME_GenericObj_i.cc b/src/GenericObj/SALOME_GenericObj_i.cc index c08192ecb..3f201514f 100644 --- a/src/GenericObj/SALOME_GenericObj_i.cc +++ b/src/GenericObj/SALOME_GenericObj_i.cc @@ -29,12 +29,6 @@ #include #include -// note: in KERNEL _DEBUG_ is not defined by default -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif //#define IS_OBJ_IN_QUESTION(where) is_obj_in_question(this, myRefCounter, where) #define IS_OBJ_IN_QUESTION(where) @@ -79,9 +73,9 @@ namespace SALOME */ GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1) { - if(MYDEBUG) - MESSAGE("GenericObj_i::GenericObj_i() - this = "< -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalog_Handler @@ -51,7 +46,7 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler(ParserPathPrefixes& p _typeMap(typeMap),_typeList(typeList) { - if(MYDEBUG) BEGIN_OF("SALOME_ModuleCatalog_Handler"); + BEGIN_OF("SALOME_ModuleCatalog_Handler"); // XML Tags initialisation // Used in the function endElement @@ -108,7 +103,7 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler(ParserPathPrefixes& p test_component_list = "component-list"; test_component="component"; - if(MYDEBUG) END_OF("SALOME_ModuleCatalog_Handler"); + END_OF("SALOME_ModuleCatalog_Handler"); } //---------------------------------------------------------------------- @@ -117,8 +112,8 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler(ParserPathPrefixes& p //---------------------------------------------------------------------- SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler() { - if(MYDEBUG) BEGIN_OF("~SALOME_ModuleCatalog_Handler()") - if(MYDEBUG) END_OF("~SALOME_ModuleCatalog_Handler()") + BEGIN_OF("~SALOME_ModuleCatalog_Handler()"); + END_OF("~SALOME_ModuleCatalog_Handler()"); } @@ -130,7 +125,7 @@ SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler() void SALOME_ModuleCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) { - if(MYDEBUG) MESSAGE("Begin parse document"); + MESSAGE("Begin parse document"); // Empty the private elements _pathList.resize(0); _pathPrefix.listOfComputer.resize(0); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 0642fc095..fba41d393 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -53,11 +53,6 @@ # include #endif -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif static const char* SEPARATOR = "::"; static const char* OLD_SEPARATOR = ":"; @@ -213,7 +208,7 @@ public: SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb) { myPrivate = new Private; - if(MYDEBUG) MESSAGE("Catalog creation"); + MESSAGE("Catalog creation"); /* Init libxml */ xmlInitParser(); @@ -252,12 +247,12 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: // Parse the arguments given at server run if (!_parseArguments(argc, argv,&myPrivate->_general_path,&myPrivate->_personal_path)) - if(MYDEBUG) MESSAGE( "Error while argument parsing" ); + MESSAGE( "Error while argument parsing" ); // Test existency of files if (myPrivate->_general_path == NULL) { - if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" ); + MESSAGE( "Error the general catalog should be indicated" ); } else { @@ -296,11 +291,11 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: // Verification of _general_path_list content if (!myPrivate->_verify_path_prefix(myPrivate->_general_path_list)) { - if(MYDEBUG) MESSAGE( "Error while parsing the general path list, " + MESSAGE( "Error while parsing the general path list, " "different paths are associated to the same computer," "the first one will be chosen"); } else { - if(MYDEBUG) MESSAGE("General path list OK"); + MESSAGE("General path list OK"); } if (myPrivate->_personal_path != NULL) { @@ -314,14 +309,14 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: // Verification of _general_path_list content if(!myPrivate->_verify_path_prefix(myPrivate->_personal_path_list)){ - if(MYDEBUG) MESSAGE("Error while parsing the personal path list, " + MESSAGE("Error while parsing the personal path list, " "different paths are associated to the same computer, " "the first one will be chosen" ); }else { - if(MYDEBUG) MESSAGE("Personal path list OK"); + MESSAGE("Personal path list OK"); } }else - if(MYDEBUG) MESSAGE("No personal catalog indicated or error while " + MESSAGE("No personal catalog indicated or error while " "opening the personal catalog"); } } @@ -332,7 +327,7 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: //---------------------------------------------------------------------- SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl() { - if(MYDEBUG) MESSAGE("Catalog Destruction"); + MESSAGE("Catalog Destruction"); delete myPrivate; } @@ -424,7 +419,7 @@ SALOME_ModuleCatalogImpl::GetComputerList() //---------------------------------------------------------------------- char* SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { - if(MYDEBUG) MESSAGE("Begin of GetPathPrefix"); + MESSAGE("Begin of GetPathPrefix"); // Variables initialisation std::string _path; bool _find = false; @@ -471,7 +466,7 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { SALOME_ModuleCatalog::ListOfComponents* SALOME_ModuleCatalogImpl::GetComponentList() { - if(MYDEBUG) MESSAGE("Begin of GetComponentList"); + MESSAGE("Begin of GetComponentList"); SALOME_ModuleCatalog::ListOfComponents_var _list_components = new SALOME_ModuleCatalog::ListOfComponents; @@ -480,7 +475,7 @@ SALOME_ModuleCatalogImpl::GetComponentList() // All the components defined in the personal catalog are taken for(unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++){ _list_components[ind]=(myPrivate->_personal_module_list[ind].name).c_str(); - if(MYDEBUG) SCRUTE(_list_components[ind]) ; + SCRUTE(_list_components[ind]) ; } size_t indice = myPrivate->_personal_module_list.size(); @@ -497,21 +492,21 @@ SALOME_ModuleCatalogImpl::GetComponentList() _find = true; } if(!_find){ - if(MYDEBUG) MESSAGE("A new component " << myPrivate->_general_module_list[ind].name + MESSAGE("A new component " << myPrivate->_general_module_list[ind].name << " has to be to added in the list"); _list_components->length((CORBA::ULong)indice+1); // The component is not already defined => has to be taken _list_components[(CORBA::ULong)indice]=(myPrivate->_general_module_list[ind].name).c_str(); - if(MYDEBUG) SCRUTE(_list_components[(CORBA::ULong)indice]) ; + SCRUTE(_list_components[(CORBA::ULong)indice]) ; indice++; }else{ - if(MYDEBUG) MESSAGE("The component " <_general_module_list[ind].name + MESSAGE("The component " <_general_module_list[ind].name << " was already defined in the personal catalog") ; } } - if(MYDEBUG) MESSAGE ( "End of GetComponentList" ); + MESSAGE("End of GetComponentList"); return _list_components._retn(); } @@ -526,7 +521,7 @@ SALOME_ModuleCatalogImpl::GetComponentList() SALOME_ModuleCatalog::ListOfIAPP_Affich* SALOME_ModuleCatalogImpl::GetComponentIconeList() { - if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList"); + MESSAGE("Begin of GetComponentIconeList"); SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone = new SALOME_ModuleCatalog::ListOfIAPP_Affich; @@ -540,8 +535,8 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() _list_components_icone[ind].moduleicone=(myPrivate->_personal_module_list[ind].icon).c_str(); _list_components_icone[ind].moduleversion=(myPrivate->_personal_module_list[ind].version).c_str(); _list_components_icone[ind].modulecomment=(myPrivate->_personal_module_list[ind].comment).c_str(); - //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename); - //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone); + //SCRUTE(_list_components_icone[ind].modulename); + //SCRUTE(_list_components_icone[ind].moduleicone); } size_t indice = myPrivate->_personal_module_list.size(); @@ -558,7 +553,7 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() _find = true; } if(!_find){ - // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); + //MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); _list_components_icone->length((CORBA::ULong)indice+1); // The component is not already defined => has to be taken _list_components_icone[(CORBA::ULong)indice].modulename=myPrivate->_general_module_list[ind].name.c_str(); @@ -566,13 +561,13 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() _list_components_icone[(CORBA::ULong)indice].moduleicone=myPrivate->_general_module_list[ind].icon.c_str(); _list_components_icone[(CORBA::ULong)indice].moduleversion=myPrivate->_general_module_list[ind].version.c_str(); _list_components_icone[(CORBA::ULong)indice].modulecomment=myPrivate->_general_module_list[ind].comment.c_str(); - //if(MYDEBUG) SCRUTE(_list_components_icone[(CORBA::ULong)indice].modulename) ; - //if(MYDEBUG) SCRUTE(_list_components_icone[(CORBA::ULong)indice].moduleicone); + //SCRUTE(_list_components_icone[(CORBA::ULong)indice].modulename) ; + //SCRUTE(_list_components_icone[(CORBA::ULong)indice].moduleicone); indice++; } // else - //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog"); + //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog"); } return _list_components_icone._retn() ; @@ -588,7 +583,7 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() SALOME_ModuleCatalog::ListOfComponents* SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type) { - if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList"); + MESSAGE("Begin of GetTypedComponentList"); SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component = new SALOME_ModuleCatalog::ListOfComponents; int _j = 0; @@ -630,7 +625,7 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT { _list_typed_component->length(_j + 1); _list_typed_component[_j] = myPrivate->_personal_module_list[ind].name.c_str(); - //if(MYDEBUG) SCRUTE(_list_typed_component[_j]); + //SCRUTE(_list_typed_component[_j]); _j++; } } @@ -655,16 +650,16 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT } if (!_find) { - //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); + //MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); _list_typed_component->length(indice+1); // The component is not already defined => has to be taken _list_typed_component[indice]=(myPrivate->_general_module_list[ind].name).c_str(); - //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ; + //SCRUTE(_list_typed_component[indice]) ; indice++; } //else - //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ; + //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ; } } @@ -712,7 +707,7 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* name) else { // Not found in the personal catalog and in the general catalog // return NULL object - if(MYDEBUG) MESSAGE("Component with name " << name + MESSAGE("Component with name " << name << " not found in catalog"); } @@ -817,7 +812,7 @@ SALOME_ModuleCatalogImpl::Private::findComponent(const std::string & name) { if (name.compare(_personal_module_list[ind].name) == 0) { - if(MYDEBUG) MESSAGE("Component named " << name + MESSAGE("Component named " << name << " found in the personal catalog"); C_parser = &(_personal_module_list[ind]); break; @@ -829,7 +824,7 @@ SALOME_ModuleCatalogImpl::Private::findComponent(const std::string & name) { if (name.compare(_general_module_list[ind].name) == 0) { - // if(MYDEBUG) MESSAGE("Component named " << name + //MESSAGE("Component named " << name // << " found in the general catalog"); C_parser = &(_general_module_list[ind]); break; @@ -850,8 +845,8 @@ SALOME_ModuleCatalogImpl::Private::_parse_xml_file(const char* file, ParserTypes& typeMap, TypeList& typeList) { - if(MYDEBUG) BEGIN_OF("_parse_xml_file"); - if(MYDEBUG) SCRUTE(file); + BEGIN_OF("_parse_xml_file"); + SCRUTE(file); //Local path and module list for the file to parse ParserPathPrefixes _pathList; @@ -958,7 +953,7 @@ void SALOME_ModuleCatalogImpl::Private::duplicate // duplicate service list size_t _length = I_parser.services.size(); - // if(MYDEBUG) SCRUTE(_length); + // SCRUTE(_length); // I_corba.interfaceservicelist // = new SALOME_ModuleCatalog::ListOfInterfaceService; I_corba.interfaceservicelist.length((CORBA::ULong)_length); @@ -1012,7 +1007,7 @@ void SALOME_ModuleCatalogImpl::Private::duplicate // duplicate out DataStreamParameters _length = S_parser.outDataStreamParameters.size(); - // if(MYDEBUG) SCRUTE(_length); + // SCRUTE(_length); S_corba.ServiceoutDataStreamParameter.length((CORBA::ULong)_length); for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) @@ -1062,7 +1057,7 @@ void SALOME_ModuleCatalogImpl::Private::duplicate // duplicate parameter dependency - if(MYDEBUG) SCRUTE(P_parser.dependency); + SCRUTE(P_parser.dependency); P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED; for (it_dep = DataStreamDepConvert.begin(); it_dep != DataStreamDepConvert.end(); @@ -1072,7 +1067,7 @@ void SALOME_ModuleCatalogImpl::Private::duplicate break; } - if(MYDEBUG) SCRUTE(P_corba.Parameterdependency); + SCRUTE(P_corba.Parameterdependency); } //---------------------------------------------------------------------- @@ -1115,7 +1110,7 @@ SALOME_ModuleCatalogImpl::Private::_verify_path_prefix(ParserPathPrefixes & path { if(_machine_list[ind].compare(_machine_list[ind1]) == 0) { - if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list"); + MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list"); _return_value = false; } } diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 1505f2e3f..93408ff3f 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -787,7 +787,7 @@ char *SALOME_NamingService::Current_Directory() path += splitPath[k]; } - SCRUTE(path) + SCRUTE(path); _current_context = ref_context ; return strdup(path.c_str()); diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx index c1d9762e3..e0426758b 100644 --- a/src/Registry/RegistryService.cxx +++ b/src/Registry/RegistryService.cxx @@ -109,7 +109,7 @@ void RegistryService::remove( CORBA::ULong id) ASSERT(_SessionName) ; ASSERT(strlen(_SessionName)>0) ; - ASSERT(_reg.find(id)!=_reg.end()) + ASSERT(_reg.find(id)!=_reg.end()); _reg[id]->_status=TERMINATED; _reg[id]->_ts_end = (long)time(NULL) ; //!< TODO: conversation from time_t to long @@ -131,7 +131,7 @@ void RegistryService::hello( CORBA::ULong id ) ASSERT(_SessionName) ; ASSERT(strlen(_SessionName)>0) ; - ASSERT(_reg.find(id)!=_reg.end()) + ASSERT(_reg.find(id)!=_reg.end()); _reg[id]->_ts_hello = (long)time(NULL) ; //!< TODO: conversation from time_t to long END_OF("RegistryService::hello") ; diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index d4aaac8df..bc46f9a9c 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -54,9 +54,9 @@ int main( int argc , char **argv ) SetArgcArgv( argc, argv ); CORBA::ORB_var orb = KERNEL::GetRefToORB(); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); - BEGIN_OF( argv[0] ) - INFOS_COMPILATION - SCRUTE(argc) + BEGIN_OF( argv[0] ); + INFOS_COMPILATION; + SCRUTE(argc); if( argc<3 ) { MESSAGE("you must provide the Salome session name when you call SALOME_Registry_Server") ; @@ -224,7 +224,7 @@ int main( int argc , char **argv ) } catch( const SALOME_Exception &ex ) { - MESSAGE( "Communication Error : " << ex.what() ) + MESSAGE( "Communication Error : " << ex.what() ); return EXIT_FAILURE ; } diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index 5eef8c963..34c4047b3 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -34,13 +34,13 @@ static SALOMEDSImpl_AttributeTreeNode* GetNode(SALOMEDS::AttributeTreeNode_ptr v SALOMEDSImpl_AttributeTreeNode* aResult = NULL; DF_Label aLabel = DF_Label::Label(aNode->Label(), value->Label()); if (aLabel.IsNull()) { - MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label") - MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label") + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label"); + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label"); return aResult; } if (!(aResult=(SALOMEDSImpl_AttributeTreeNode*)aLabel.FindAttribute(aNode->ID()))) { - MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute") - MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute") + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute"); + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute"); } return aResult; } diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index 3ef7d686d..26c11a419 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -246,7 +246,7 @@ static void Test() } catch(HDFexception) { - MESSAGE( "HDFexception ! " ) + MESSAGE("HDFexception ! "); } } @@ -275,19 +275,19 @@ int main(int argc, char** argv) orb->destroy(); } catch(CORBA::SystemException&) { - MESSAGE("Caught CORBA::SystemException." ) + MESSAGE("Caught CORBA::SystemException."); } catch(CORBA::Exception&) { - MESSAGE( "Caught CORBA::Exception." ) + MESSAGE("Caught CORBA::Exception."); } catch(omniORB::fatalException& fe) { //!< TODO: unused variable - MESSAGE( "Caught omniORB::fatalException:" ) - MESSAGE( " file: " << fe.file() ) - MESSAGE( " line: " << fe.line() ) - MESSAGE( " mesg: " << fe.errmsg() ) + MESSAGE("Caught omniORB::fatalException:"); + MESSAGE(" file: " << fe.file()); + MESSAGE(" line: " << fe.line()); + MESSAGE(" mesg: " << fe.errmsg()); } catch(...) { - MESSAGE( "Caught unknown exception." ) + MESSAGE("Caught unknown exception."); } return 0; } diff --git a/src/SALOMELocalTrace/CMakeLists.txt b/src/SALOMELocalTrace/CMakeLists.txt index d9f56b824..747bba435 100644 --- a/src/SALOMELocalTrace/CMakeLists.txt +++ b/src/SALOMELocalTrace/CMakeLists.txt @@ -28,6 +28,7 @@ SET(COMMON_HEADERS LocalTraceBufferPool.hxx BaseTraceCollector.hxx SALOME_LocalTrace.hxx + libSALOMELog.hxx ) SET(SALOMELocalTrace_SOURCES @@ -40,6 +41,8 @@ SET(SALOMELocalTrace_SOURCES LocalTraceBufferPool.cxx LocalTraceBufferPool.hxx SALOME_LocalTrace.hxx + libSALOMELog.hxx + libSALOMELog.cxx ) ADD_LIBRARY(SALOMELocalTrace ${SALOMELocalTrace_SOURCES}) diff --git a/src/SALOMELocalTrace/libSALOMELog.cxx b/src/SALOMELocalTrace/libSALOMELog.cxx new file mode 100644 index 000000000..1d22d33ca --- /dev/null +++ b/src/SALOMELocalTrace/libSALOMELog.cxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Author : Konstantin Leontev (OpenCascade) +// Module : KERNEL +// $Header$ +// + +#include "libSALOMELog.hxx" + +#include +#include + +namespace SALOME +{ + +// ============================================================================ +/*! + * Called by any log message macros to decide about log output in Release and + * Debug mode dynamically rely on SALOME_VERBOSE environment variable. + * Checks SALOME_VERBOSE only on the very first call and returns cached result + * for all followed calls. + * Returns true if SALOME_VERBOSE is positioned and not empty and if its + * numeric value greater than 0. + */ +// ============================================================================ + + bool VerbosityActivated() + { + auto isEnvVarSet = []() -> bool + { + const char* envVar = std::getenv("SALOME_VERBOSE"); + + if (envVar && (envVar[0] != '\0')) + { + try + { + const long long numValue = std::stoll(envVar); + return numValue > 0; + } + catch(const std::exception& e) + { + std::cerr << e.what() << '\n'; + } + } + + return false; + }; + + static const bool isActivated = isEnvVarSet(); + return isActivated; + } +} diff --git a/src/SALOMELocalTrace/libSALOMELog.hxx b/src/SALOMELocalTrace/libSALOMELog.hxx new file mode 100644 index 000000000..47f364a4f --- /dev/null +++ b/src/SALOMELocalTrace/libSALOMELog.hxx @@ -0,0 +1,38 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : libSALOMELog.hxx +// Author : Konstantin Leontev (OpenCascade) +// Module : KERNEL +// $Header$ +// +#ifndef _LIBSALOMELOG_HXX_ +#define _LIBSALOMELOG_HXX_ + +#include "SALOME_LocalTrace.hxx" + +namespace SALOME +{ + bool SALOMELOCALTRACE_EXPORT VerbosityActivated(); +} + +#endif diff --git a/src/SALOMELocalTrace/utilities.h b/src/SALOMELocalTrace/utilities.h index fc6b2bf16..aeea32f8d 100644 --- a/src/SALOMELocalTrace/utilities.h +++ b/src/SALOMELocalTrace/utilities.h @@ -37,6 +37,7 @@ #include "LocalTraceBufferPool.hxx" +#include "libSALOMELog.hxx" /*! * For each message to put in the trace, a specific ostingstream object is @@ -101,40 +102,26 @@ #error INFOS_COMPILATION already defined #endif -#if defined(_DEBUG_) || defined(_DEBUG) +// --- the following MACROS can be enabled in debug and release versions +// --- by SALOME_VERBOSE environment variable -// --- the following MACROS are useful at debug time - -#define INFOS_COMPILATION { MESS_BEGIN("COMPILED with ") << COMPILER \ +#define INFOS_COMPILATION { if (SALOME::VerbosityActivated()) { MESS_BEGIN("COMPILED with ") << COMPILER \ << ", " << __DATE__ \ - << " at " << __TIME__ << MESS_END } + << " at " << __TIME__ << MESS_END }} + -#define MESSAGE(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END} -#define SCRUTE(var) {MESS_BEGIN("- Trace ") << #var << "=" << var < *DESTRUCTEUR_GENERIQUE_::Destructeurs=0 ; /*! \class ATEXIT_ @@ -116,16 +110,16 @@ static ATEXIT_ nettoyage = ATEXIT_( false ); /* singleton statique */ void Nettoyage( void ) { //cerr << "Nettoyage()" << endl; - //if(MYDEBUG) BEGIN_OF("Nettoyage( void )") ; + //BEGIN_OF("Nettoyage( void )") ; assert(DESTRUCTEUR_GENERIQUE_::Destructeurs) ; - //if(MYDEBUG) SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ; + //SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ; if( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) { std::list::iterator it = DESTRUCTEUR_GENERIQUE_::Destructeurs->end() ; do { - //if(MYDEBUG) MESSAGE( "DESTRUCTION d'un SINGLETON"); + //MESSAGE( "DESTRUCTION d'un SINGLETON"); it-- ; DESTRUCTEUR_GENERIQUE_* ptr = *it ; //DESTRUCTEUR_GENERIQUE_::Destructeurs->remove( *it ) ; @@ -134,14 +128,14 @@ void Nettoyage( void ) }while( it!= DESTRUCTEUR_GENERIQUE_::Destructeurs->begin() ) ; DESTRUCTEUR_GENERIQUE_::Destructeurs->clear() ; - //if(MYDEBUG) SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ; + //SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ; assert( DESTRUCTEUR_GENERIQUE_::Destructeurs->size()==0 ) ; assert( DESTRUCTEUR_GENERIQUE_::Destructeurs->empty() ) ; } delete DESTRUCTEUR_GENERIQUE_::Destructeurs; DESTRUCTEUR_GENERIQUE_::Destructeurs=0; - //if(MYDEBUG) END_OF("Nettoyage( void )") ; + //END_OF("Nettoyage( void )") ; return ; } -- 2.39.2