-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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
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
*/
//=============================================================================
-/*!
+/*!
* Default constructor, not for use
*/
//=============================================================================
//=============================================================================
Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa,
- PortableServer::ObjectId * contId,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
const char *instanceName,
const char *interfaceName,
bool notif,
_Executed(false) ,
_graphName("") ,
_nodeName(""),
- _studyId(-1),
_id(0),
_contId(0),
_CanceledThread(false)
_Executed(false) ,
_graphName("") ,
_nodeName(""),
- _studyId(-1),
_id(0),
_contId(0),
_CanceledThread(false)
setContainerName();
const CORBA::String_var ior = _orb->object_to_string(_container);
if(regist)
+ {
_myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str());
+ }
if(notif)
_notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
//=============================================================================
-/*!
+/*!
* Destructor: call Container for decrement of instances count.
* When instances count falls to 0, the container tries to remove the
* component library (dlclose)
}
//=============================================================================
-/*!
+/*!
* CORBA method: return name of the instance, unique in this Container
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: return name of the component class
*/
//=============================================================================
}
//=============================================================================
-/*!
- * 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
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: Deactivate this instance. CORBA object is deactivated (do not
* respond any more to CORBA calls), the connection to Regsitry is removed
* (Registry informed of deactivation), internal server reference counter on
}
//=============================================================================
-/*!
+/*!
* CORBA method: return CORBA reference of the Container
*
*/
}
//=============================================================================
-/*!
- * CORBA method:
- * Gives a sequence of (key=string,value=any) to the component.
+/*!
+ * CORBA method:
+ * Gives a sequence of (key=string,value=any) to the component.
* Base class component stores the sequence in a map.
* The map is cleared before.
- * This map is for use by derived classes.
+ * This map is for use by derived classes.
* \param dico sequence of (key=string,value=any)
*/
//=============================================================================
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
* returns a previously stored map (key=string,value=any) as a sequence.
* (see setProperties)
*/
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
* This method is to set an option specific to a certain EngineComponent.
*/
//=============================================================================
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
* This method is to get value of an option specific to a certain EngineComponent.
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: used by Supervision to give names to this instance
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
-bool Engines_Component_i::Kill_impl()
+bool Engines_Component_i::Kill_impl()
{
// MESSAGE("Engines_Component_i::Kill_i() pthread_t "<< pthread_self()
// << " pid " << getpid() << " instanceName "
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
<< " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << std::hex << _id
<< std::dec << " _ThreadId " << _ThreadId );
#endif
-
+
bool RetVal = false ;
#ifndef WIN32
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
{
return false ;
}
- else
+ else
{
#ifndef WIN32
RetVal = Killer( _ThreadId ,SIGINT ) ;
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
#endif
{
- if ( _Sleeping )
+ if ( _Sleeping )
{
_Sleeping = false ;
RetVal = true ;
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
*/
//=============================================================================
// << _serviceName << " " << cpu << endl ;
}
}
- else
+ else
{
cpu = _ThreadCpuUsed ;
// cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
//=============================================================================
-/*!
+/*!
* C++ method: return Container Servant
*/
//=============================================================================
}
//=============================================================================
-/*!
- * 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
* constructor, when instance is activated.
*/
}
//=============================================================================
-/*!
+/*!
* C++ method: used by derived classes for supervision
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: used by derived classes for supervision
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: -- CHECK IF USED --
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: -- CHECK IF USED --
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: used in Supervision (see kill_impl)
*/
//=============================================================================
perror("Killer pthread_kill error") ;
return false ;
}
- else
+ else
{
#ifdef WIN32
MESSAGE("Killer : ThreadId " << ThreadId.p << " pthread_killed(" << signum << ")") ;
void CallCancelThread();
//=============================================================================
-/*!
+/*!
* C++ method:
- */
+ */
//=============================================================================
void SetCpuUsed()
}
//=============================================================================
-/*!
+/*!
* C++ method:
*/
//=============================================================================
void Engines_Component_i::SetCurCpu()
{
_ThreadCpuUsed = CpuUsed() ;
- // MESSAGE(pthread_self() <<
+ // MESSAGE(pthread_self() <<
// " Engines_Component_i::SetCurCpu() _ThreadCpuUsed " << _ThreadCpuUsed) ;
}
//=============================================================================
-/*!
+/*!
* C++ method:
*/
//=============================================================================
else
{
// std::cout << pthread_self() << "Engines_Component_i::CpuUsed _ThreadId "
- // << _ThreadId << " " << _serviceName<< " _StartUsed "
+ // << _ThreadId << " " << _serviceName<< " _StartUsed "
// << _StartUsed << std::endl ;
}
-#else
+#else
// NOT implementet yet
#endif
}
//=============================================================================
-/*!
+/*!
* C++ method: Send message to event channel
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: return standard library name built on component name
*/
//=============================================================================
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";
-#endif
+ suffix = "so";
+#endif
+ std::string ret = prefix + cname + std::string("Engine.") + suffix;
return ret;
}
//=============================================================================
-/*!
+/*!
* C++ method: DumpPython default implementation
*/
//=============================================================================
-Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
+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);
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
isValidScript = true;
- return aStreamFile._retn();
+ return aStreamFile._retn();
}
-Engines::Salome_file_ptr
-Engines_Component_i::getInputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::getInputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we throw an exception.
_Service_file_map_it = _Input_Service_file_map.find(service_name);
return Sfile->_this();
}
-Engines::Salome_file_ptr
-Engines_Component_i::setInputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::setInputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we add it.
_Service_file_map_it = _Input_Service_file_map.find(service_name);
_Input_Service_file_map[service_name] = _map;
}
_t_Salome_file_map * _map = _Input_Service_file_map[service_name];
-
+
// Try to find the Salome_file ...
_Salome_file_map_it = _map->find(Salome_file_name);
if (_Salome_file_map_it == _map->end()) {
return Sfile->_this();
}
-void
-Engines_Component_i::checkInputFilesToService(const char* service_name)
+void
+Engines_Component_i::checkInputFilesToService(const char* service_name)
{
// Try to find the service, if it doesn't exist, nothing to do.
_Service_file_map_it = _Input_Service_file_map.find(service_name);
}
}
-Engines::Salome_file_ptr
-Engines_Component_i::getOutputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::getOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we throw an exception.
_Service_file_map_it = _Output_Service_file_map.find(service_name);
return Sfile->_this();
}
-Engines::Salome_file_ptr
-Engines_Component_i::setOutputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::setOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we add it.
_Service_file_map_it = _Output_Service_file_map.find(service_name);
_Output_Service_file_map[service_name] = _map;
}
_t_Salome_file_map * _map = _Output_Service_file_map[service_name];
-
+
// Try to find the Salome_file ...
_Salome_file_map_it = _map->find(Salome_file_name);
if (_Salome_file_map_it == _map->end()) {
return Sfile->_this();
}
-void
-Engines_Component_i::checkOutputFilesToService(const char* service_name)
+void
+Engines_Component_i::checkOutputFilesToService(const char* service_name)
{
// Try to find the service, if it doesn't exist, nothing to do.
_Service_file_map_it = _Output_Service_file_map.find(service_name);
}
//=============================================================================
-/*!
+/*!
* C++ method: used to configure the Salome_file into the runtime.
* \param service_name name of the service that use this Salome_file
* \param file_port_name name of the Salome_file
void
Engines_Component_i::configureSalome_file(std::string service_name,
std::string file_port_name,
- Salome_file_i * file)
-{
- // By default this method does nothing
-}
-
-//=============================================================================
-/*!
- * C++ method: allows to import data file into the Component internal data
- structure (like import operation of BRep file in GEOM module).
- * \param studyId identifier of the working study
- * \param data container of the file content
- * \param options additional options for import (if needed)
- */
-//=============================================================================
-Engines::ListOfIdentifiers* Engines_Component_i::importData(CORBA::Long studyId,
- Engines::DataContainer_ptr data,
- const Engines::ListOfOptions& options)
+ Salome_file_i * file)
{
// By default this method does nothing
- Engines::ListOfIdentifiers_var aList = new Engines::ListOfIdentifiers;
- return aList._retn();
}
//=============================================================================
-/*!
- * C++ method: allows to export data files from the Component internal data
- structure (like Export operation of Step file in GEOM module).
- * \param studyId identifier of the working study
- */
-//=============================================================================
-Engines::ListOfData* Engines_Component_i::getModifiedData(CORBA::Long studyId)
-{
- // By default this method does nothing
- Engines::ListOfData_var aList = new Engines::ListOfData;
- return aList._retn();
-}
-
-//=============================================================================
-/*!
+/*!
* C++ method: return the name of the container associated with this component
* This name does not contains the "/Containers" string and all "/" are replaced by "_"
* \return the container name (reformatted)
return _containerName;
}
//=============================================================================
-/*!
+/*!
* C++ method: set the name of the container associated with this component (attribute _containerName)
* This name does not contains the "/Containers" string and all "/" are replaced by "_"
* \return the container name (reformatted)
\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()