Salome HOME
Copyright update 2021
[modules/kernel.git] / src / Container / Component_i.cxx
index d45bd4ed81f7c65c928cb7184d67a319472bf34c..879329b2a2f67b555c4dfb8fa2555660027bda36 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
@@ -51,7 +51,6 @@ int SIGUSR11 = 1000;
 extern bool _Sleeping ;
 static Engines_Component_i * theEngines_Component ;
 
-bool Engines_Component_i::_isMultiStudy = true;
 bool Engines_Component_i::_isMultiInstance = false;
 
 /*! \class Engines_Component_i
@@ -65,7 +64,7 @@ bool Engines_Component_i::_isMultiInstance = false;
  */
 //=============================================================================
 
-Engines_Component_i::Engines_Component_i():_myConnexionToRegistry(0), _notifSupplier(0), _id(0)
+Engines_Component_i::Engines_Component_i(): _id(0), _myConnexionToRegistry(0), _notifSupplier(0)
 {
   //ASSERT(0);
   MESSAGE("Default Constructor, not for normal use...");
@@ -94,16 +93,15 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
                                          bool regist ) :
   _instanceName(instanceName),
   _interfaceName(interfaceName),
+  _id(0),
+  _contId(0),
   _myConnexionToRegistry(0),
   _notifSupplier(0),
+  _graphName("") ,
+  _nodeName(""),
   _ThreadId(0) ,
   _ThreadCpuUsed(0) ,
   _Executed(false) ,
-  _graphName("") ,
-  _nodeName(""),
-  _studyId(-1),
-  _id(0),
-  _contId(0),
   _CanceledThread(false)
 {
   MESSAGE("Component constructor with instanceName "<< _instanceName);
@@ -148,16 +146,15 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
                                          bool regist) :
   _instanceName(instanceName),
   _interfaceName(interfaceName),
+  _id(0),
+  _contId(0),
   _myConnexionToRegistry(0),
   _notifSupplier(0),
+  _graphName("") ,
+  _nodeName(""),
   _ThreadId(0) ,
   _ThreadCpuUsed(0) ,
   _Executed(false) ,
-  _graphName("") ,
-  _nodeName(""),
-  _studyId(-1),
-  _id(0),
-  _contId(0),
   _CanceledThread(false)
 {
   MESSAGE("Component constructor with instanceName "<< _instanceName);
@@ -227,20 +224,6 @@ char* Engines_Component_i::interfaceName()
   return CORBA::string_dup(_interfaceName.c_str()) ;
 }
 
-//=============================================================================
-/*!
- *  CORBA method: Get study Id
- *  \return -1: not initialised (Internal Error)
- *           0: multistudy component instance
- *          >0: study id associated to this instance
- */
-//=============================================================================
-
-CORBA::Long Engines_Component_i::getStudyId()
-{
-  return _studyId;
-}
-
 //=============================================================================
 /*!
  *  CORBA method: Test if instance is alive and responds
@@ -324,7 +307,7 @@ void Engines_Component_i::setProperties(const Engines::FieldsDict& dico)
 Engines::FieldsDict* Engines_Component_i::getProperties()
 {
   Engines::FieldsDict_var copie = new Engines::FieldsDict;
-  copie->length(_fieldsDict.size());
+  copie->length((CORBA::ULong)_fieldsDict.size());
   std::map<std::string,CORBA::Any>::iterator it;
   CORBA::ULong i = 0;
   for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++, i++)
@@ -606,31 +589,6 @@ Engines_Container_i *Engines_Component_i::GetContainerPtr()
   return dynamic_cast<Engines_Container_i*>(_poa->id_to_servant(contId)) ;
 }
 
-//=============================================================================
-/*!
- *  C++ method: set study Id
- *  \param studyId         0 if instance is not associated to a study,
- *                         >0 otherwise (== study id)
- *  \return true if the set of study Id is OK
- *  must be set once by Container, at instance creation,
- *  and cannot be changed after.
- */
-//=============================================================================
-
-CORBA::Boolean Engines_Component_i::setStudyId(CORBA::Long studyId)
-{
-  ASSERT( studyId >= 0);
-  CORBA::Boolean ret = false;
-  if (_studyId < 0) // --- not yet initialized
-    {
-      _studyId = studyId;
-      ret = true;
-    }
-  else
-    if ( _studyId == studyId) ret = true;
-  return ret;
-}
-
 //=============================================================================
 /*!
  *  C++ method: return CORBA instance id, the id is set in derived class
@@ -707,7 +665,7 @@ void Engines_Component_i::endService(const char *serviceName)
   if ( !_CanceledThread )
     _ThreadCpuUsed = CpuUsed_impl() ;
 
-  float cpus=_ThreadCpuUsed/1000.;
+  float cpus=_ThreadCpuUsed/1000.f;
   std::cerr << "endService for " << serviceName << " Component instance : " << _instanceName ;
   std::cerr << " Cpu Used: " << cpus << " (s) " << std::endl;
   MESSAGE("Send EndService notification for " << serviceName
@@ -849,7 +807,7 @@ long Engines_Component_i::CpuUsed()
       //      << _StartUsed << std::endl ;
     }
 #else
-        // NOT implementet yet
+        // NOT implemented yet
 #endif
 
 
@@ -893,14 +851,19 @@ void Engines_Component_i::sendMessage(const char *event_type,
 
 std::string Engines_Component_i::GetDynLibraryName(const char *componentName)
 {
-#ifndef WIN32
-  std::string ret="lib";
-  ret+=componentName;
-  ret+="Engine.so";
+  std::string prefix, suffix;
+  std::string cname = componentName;
+#if !defined(WIN32)
+  prefix = "lib";
+#endif
+#if defined(WIN32)
+  suffix = "dll";
+#elif defined(__APPLE__)
+  suffix = "dylib";
 #else
-  std::string ret=componentName;
-  ret+="Engine.dll";
+  suffix = "so";
 #endif
+  std::string ret = prefix + cname + std::string("Engine.") + suffix;
   return ret;
 }
 
@@ -910,17 +873,15 @@ std::string Engines_Component_i::GetDynLibraryName(const char *componentName)
  */
 //=============================================================================
 
-Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
-                                                  CORBA::Boolean isPublished,
+Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Boolean /*isPublished*/,
                                                   CORBA::Boolean isMultiFile,
                                                   CORBA::Boolean& isValidScript)
 {
-  const char* aScript = isMultiFile ? "def RebuildData(theStudy): pass" : "";
+  const char* aScript = isMultiFile ? "def RebuildData(): pass" : "";
   char* aBuffer = new char[strlen(aScript)+1];
   strcpy(aBuffer, aScript);
-  CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
-  int aBufferSize = strlen(aBuffer)+1;
-  Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
+  size_t aBufferSize = strlen(aBuffer)+1;
+  Engines::TMPFile_var aStreamFile = new Engines::TMPFile((CORBA::ULong)aBufferSize, (CORBA::ULong)aBufferSize, (CORBA::Octet*)aBuffer, 1);
   isValidScript = true;
   return aStreamFile._retn();
 }
@@ -1077,9 +1038,9 @@ Engines_Component_i::checkOutputFilesToService(const char* service_name)
  */
 //=============================================================================
 void
-Engines_Component_i::configureSalome_file(std::string service_name,
-                                          std::string file_port_name,
-                                          Salome_file_i * file)
+Engines_Component_i::configureSalome_file(std::string /*service_name*/,
+                                          std::string /*file_port_name*/,
+                                          Salome_file_i* /*file*/)
 {
   // By default this method does nothing
 }
@@ -1115,16 +1076,37 @@ void Engines_Component_i::setContainerName()
 
 //=============================================================================
 /*!
-  \brief Get version of the component
-
-  This method is supposed to be implemented in all derived classes; default implementation
-  returns empty string that means that no version information about the component is available.
+ * \brief Return \c true if component can provide creation information.
+ */
+//=============================================================================
+bool Engines_Component_i::hasObjectInfo()
+{
+  return false;
+}
 
-  \note The version of the component is stored to the study, as a part of general persistence
-  mechanism; once stored, version information in the study cannot be changed.
+//=============================================================================
+/*!
+ * \brief Get creation information for object addressed by given entry.
+ */
+//=============================================================================
+char* Engines_Component_i::getObjectInfo(const char* /*entry*/)
+{
+  return CORBA::string_dup("");
+}
 
-  \return string containing component's version, e.g. "1.0"
-*/
+//=============================================================================
+/*!
+ * \brief Get version of the component
+ *
+ * This method is supposed to be implemented in all derived classes; default implementation
+ * returns empty string that means that no version information about the component is available.
+ *
+ * \note The version of the component is stored to the study, as a part of general persistence
+ * mechanism; once stored, version information in the study cannot be changed.
+ *
+ * \return string containing component's version, e.g. "1.0"
+ */
+//=============================================================================
 char* Engines_Component_i::getVersion()
 {
   return CORBA::string_dup( "" );