Salome HOME
Updated copyright comment
[modules/kernel.git] / src / DSC / DSC_User / Datastream / Calcium / CalciumCxxInterface.hxx
index c8fe3e278da0d0fec0a0b6e73eed25808a365e0c..df471fe019144399e19e70b77a6023fd1fe5c022 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -57,7 +57,6 @@ struct IsSameType<T1,T1> {
 
 extern const char * CPMESSAGE[];
 
-//#define MYDEBUG
 
 #include <boost/type_traits/remove_all_extents.hpp>
 
@@ -102,11 +101,12 @@ namespace CalciumInterface {
 //         calcium_uses_port* myCalciumUsesPort=
 //           dynamic_cast<calcium_uses_port*>(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 --"<<typeid(port).name()<<"----------------" << std::endl;
-    T1 t1;
-    T2 t2;
-    std::cout << "-------- CalciumInterface(lecture) MARK 2b1 -----" << typeid(t1).name() << "-------------" << std::endl;
-    std::cout << "-------- CalciumInterface(lecture) MARK 2b2 -----" << typeid(t2).name() << "-------------" << std::endl;
-#endif
+
+    if (SALOME::VerbosityActivated())
+    {
+      std::cout << "-------- CalciumInterface(lecture) MARK 2 --"<<typeid(port).name()<<"----------------" << std::endl;
+      T1 t1;
+      T2 t2;
+      std::cout << "-------- CalciumInterface(lecture) MARK 2b1 -----" << typeid(t1).name() << "-------------" << std::endl;
+      std::cout << "-------- CalciumInterface(lecture) MARK 2b2 -----" << typeid(t2).name() << "-------------" << std::endl;
+    }
 
     try 
       {
         port  = component.Superv_Component_i::get_port< PortType > (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<T1,InnerType>::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<T1,InnerType>::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<false, DataManipulator >::apply(data,corbaData,nRead);
-        //Déjà fait ci-dessus : 
-        //DataManipulator::copy(corbaData,data,nRead);
-#ifdef MYDEBUG
+
+      Copy2UserSpace<false, DataManipulator >::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<T1>(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<T1>(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<CalciumTypes::DependencyType>(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 ---"<<typeid(port).name()<<"---------------" << std::endl;
-    T1 t1;
-    T2 t2;
-    std::cout << "-------- CalciumInterface(ecriture) MARK 2b1 -----" << typeid(t1).name() << "-------------" << std::endl;
-    std::cout << "-------- CalciumInterface(ecriture) MARK 2b2 -----" << typeid(t2).name() << "-------------" << std::endl;
-#endif
+
+    if (SALOME::VerbosityActivated())
+    {
+      std::cout << "-------- CalciumInterface(ecriture) MARK 2 ---"<<typeid(port).name()<<"---------------" << std::endl;
+      T1 t1;
+      T2 t2;
+      std::cout << "-------- CalciumInterface(ecriture) MARK 2b1 -----" << typeid(t1).name() << "-------------" << std::endl;
+      std::cout << "-------- CalciumInterface(ecriture) MARK 2b2 -----" << typeid(t2).name() << "-------------" << std::endl;
+    }
 
     try 
       {
         port  = component.Superv_Component_i::get_port< UsesPortType > (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<IsSameType<T1_without_extent,InnerType>::value, DataManipulator >::apply(corbaData,_data,bufferLength);
  
@@ -568,9 +577,8 @@ namespace CalciumInterface {
           }
         //Le -1 peut être traité par le cst DataIdContainer et transformé en 0 
         //Etre obligé de mettre une étoile ds (*corbadata) va poser des pb pour les types <> seq
-#ifdef MYDEBUG
-        std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl;
-#endif
+        if (SALOME::VerbosityActivated())
+          std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl;
       } 
     else if ( _dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) 
       {
@@ -586,27 +594,27 @@ namespace CalciumInterface {
             Engines_DSC_interface::writeEvent("WRITE",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPATAL],ex.what());
             throw (CalciumException(CalciumTypes::CPATAL,ex.what()));
           }
-#ifdef MYDEBUG
-        std::cout << "-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl;
-#endif
+
+        if (SALOME::VerbosityActivated())
+          std::cout << "-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl;
       } 
     
-#ifdef MYDEBUG
-    std::cout << "-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl;
-    for (int i = 0; i < corbaData->length(); ++i)
-      std::cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << std::endl;
-#endif
+    if (SALOME::VerbosityActivated())
+    {
+      std::cout << "-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl;
+      for (int i = 0; i < corbaData->length(); ++i)
+        std::cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << std::endl;
+    }
     
     //    if ( !IsSameType<T1,InnerType>::value ) delete corbaData;
     // Supprime l'objet CORBA avec eventuellement les données qu'il contient (cas de la recopie)
     delete corbaData;
 
-#ifdef MYDEBUG
-    std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl;
-#endif
+    if (SALOME::VerbosityActivated())
+      std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl;
    
     return;
-  };
+  }
   
   template <typename T1> static void
   ecp_ecriture ( Superv_Component_i & component,
@@ -618,7 +626,7 @@ namespace CalciumInterface {
                  T1 const & data ) 
   {
     ecp_ecriture<T1,T1> (component,dependencyType,t,i,nomVar,bufferLength,data); 
-  };
+  }
 
   static inline void
   ecp_fini(Superv_Component_i & component,const std::string  & nomVar,long const  & i)
@@ -677,7 +685,7 @@ namespace CalciumInterface {
     msg << "i<=" << i ;
     Engines_DSC_interface::writeEvent("CP_FINI",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
 
-  };
+  }
 
   static inline void
   ecp_fint(Superv_Component_i & component,const std::string  & nomVar,double const  & t)
@@ -736,7 +744,7 @@ namespace CalciumInterface {
     msg << "t<=" << t ;
     Engines_DSC_interface::writeEvent("CP_FINT",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
 
-  };
+  }
 
   static inline void
   ecp_effi(Superv_Component_i & component,const std::string  & nomVar,long const  & i)
@@ -795,7 +803,7 @@ namespace CalciumInterface {
     msg << "i>=" << i ;
     Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
 
-  };
+  }
 
   static inline void
   ecp_efft(Superv_Component_i & component,const std::string  & nomVar,double const  & t)
@@ -854,8 +862,8 @@ namespace CalciumInterface {
     msg << "t>=" << t ;
     Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
 
-  };
+  }
 
-};
+}
 
 #endif