1 // SALOME Container : implementation of container and engine for Kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : Component_i.cxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
29 //#define private protected // for pd_refCount trace
30 #include "SALOME_Component_i.hxx"
31 #include "SALOME_Container_i.hxx"
32 #include "RegistryConnexion.hxx"
39 #include "utilities.h"
43 #include <sys/resource.h>
46 #include <sys/timeb.h>
54 extern bool _Sleeping ;
55 static Engines_Component_i * theEngines_Component ;
57 bool Engines_Component_i::_isMultiStudy = true;
58 bool Engines_Component_i::_isMultiInstance = false;
60 //=============================================================================
62 * Default constructor, not for use
64 //=============================================================================
66 Engines_Component_i::Engines_Component_i():_myConnexionToRegistry(0), _notifSupplier(0)
69 MESSAGE("Default Constructor, not for normal use...");
72 //=============================================================================
74 * Standard Constructor for generic Component, used in derived class
75 * Connection to Registry and Notification
76 * \param orb Object Request broker given by Container
77 * \param poa Portable Object Adapter from Container (normally root_poa)
78 * \param contId container CORBA id inside the server
79 * \param instanceName unique instance name for this object (see Container_i)
80 * \param interfaceName component class name
81 * \param notif use of notification
83 //=============================================================================
85 Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
86 PortableServer::POA_ptr poa,
87 PortableServer::ObjectId * contId,
88 const char *instanceName,
89 const char *interfaceName,
91 _instanceName(instanceName),
92 _interfaceName(interfaceName),
93 _myConnexionToRegistry(0),
101 _CanceledThread(false)
103 MESSAGE("Component constructor with instanceName "<< _instanceName);
104 //SCRUTE(pd_refCount);
105 _orb = CORBA::ORB::_duplicate(orb);
106 _poa = PortableServer::POA::_duplicate(poa);
108 CORBA::Object_var o = _poa->id_to_reference(*contId); // container ior...
109 const CORBA::String_var ior = _orb->object_to_string(o);
110 _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession",
111 _instanceName.c_str());
113 _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
114 //SCRUTE(pd_refCount);
117 //=============================================================================
119 * Standard constructor for parallel component
120 * Connection Notification (no connection to Registry !)
121 * \param orb Object Request broker given by Container
122 * \param poa Portable Object Adapter from Container (normally root_poa)
123 * \param contId container CORBA id inside the server
124 * \param instanceName unique instance name for this object (see Container_i)
125 * \param interfaceName component class name
126 * \param flag not used...
127 * \param notif use of notification
129 //=============================================================================
131 Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
132 PortableServer::POA_ptr poa,
133 PortableServer::ObjectId * contId,
134 const char *instanceName,
135 const char *interfaceName,
138 _instanceName(instanceName),
139 _interfaceName(interfaceName),
140 _myConnexionToRegistry(0),
148 _CanceledThread(false)
150 _orb = CORBA::ORB::_duplicate(orb);
151 _poa = PortableServer::POA::_duplicate(poa);
154 _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
157 //=============================================================================
159 * Destructor: call Container for decrement of instances count.
160 * When instances count falls to 0, the container tries to remove the
161 * component library (dlclose)
163 //=============================================================================
165 Engines_Component_i::~Engines_Component_i()
167 MESSAGE("Component destructor");
168 Engines_Container_i::decInstanceCnt(_interfaceName);
169 if(_myConnexionToRegistry)delete _myConnexionToRegistry;
170 if(_notifSupplier)delete _notifSupplier;
173 //=============================================================================
175 * CORBA method: return name of the instance, unique in this Container
177 //=============================================================================
179 char* Engines_Component_i::instanceName()
181 return CORBA::string_dup(_instanceName.c_str()) ;
184 //=============================================================================
186 * CORBA method: return name of the component class
188 //=============================================================================
190 char* Engines_Component_i::interfaceName()
192 return CORBA::string_dup(_interfaceName.c_str()) ;
195 //=============================================================================
197 * CORBA method: Get study Id
198 * \return -1: not initialised (Internal Error)
199 * 0: multistudy component instance
200 * >0: study id associated to this instance
202 //=============================================================================
204 CORBA::Long Engines_Component_i::getStudyId()
209 //=============================================================================
211 * CORBA method: Test if instance is alive and responds
213 //=============================================================================
215 void Engines_Component_i::ping()
218 MESSAGE("Engines_Component_i::ping() pid "<< getpid() << " threadid "
221 MESSAGE("Engines_Component_i::ping() pid "<< _getpid()<< " threadid "
222 << pthread_self().p );
226 //=============================================================================
228 * CORBA method: Deactivate this instance. CORBA object is deactivated (do not
229 * respond any more to CORBA calls), the connection to Regsitry is removed
230 * (Registry informed of deactivation), internal server reference counter on
231 * the derived servant class is decremented, to allow destruction of the class
232 * (delete) by POA, when there are no more references.
233 * -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
235 //=============================================================================
237 void Engines_Component_i::destroy()
239 MESSAGE("Engines_Component_i::destroy()");
240 //SCRUTE(pd_refCount);
242 delete _notifSupplier;
245 delete _myConnexionToRegistry;
246 _myConnexionToRegistry = 0 ;
247 _poa->deactivate_object(*_id) ;
249 //SCRUTE(pd_refCount);
250 _thisObj->_remove_ref();
251 //SCRUTE(pd_refCount);
252 MESSAGE("Engines_Component_i::destroyed") ;
255 //=============================================================================
257 * CORBA method: return CORBA reference of the Container
260 //=============================================================================
262 Engines::Container_ptr Engines_Component_i::GetContainerRef()
264 // MESSAGE("Engines_Component_i::GetContainerRef");
265 CORBA::Object_var o = _poa->id_to_reference(*_contId) ;
266 return Engines::Container::_narrow(o);
269 //=============================================================================
272 * Gives a sequence of (key=string,value=any) to the component.
273 * Base class component stores the sequence in a map.
274 * The map is cleared before.
275 * This map is for use by derived classes.
276 * \param dico sequence of (key=string,value=any)
278 //=============================================================================
280 void Engines_Component_i::setProperties(const Engines::FieldsDict& dico)
283 for (CORBA::ULong i=0; i<dico.length(); i++)
285 std::string cle(dico[i].key);
286 _fieldsDict[cle] = dico[i].value;
290 //=============================================================================
293 * returns a previously stored map (key=string,value=any) as a sequence.
294 * (see setProperties)
296 //=============================================================================
298 Engines::FieldsDict* Engines_Component_i::getProperties()
300 Engines::FieldsDict_var copie = new Engines::FieldsDict;
301 copie->length(_fieldsDict.size());
302 map<std::string,CORBA::Any>::iterator it;
304 for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++, i++)
306 std::string cle((*it).first);
307 copie[i].key = CORBA::string_dup(cle.c_str());
308 copie[i].value = _fieldsDict[cle];
310 return copie._retn();
313 //=============================================================================
315 * CORBA method: used by Supervision to give names to this instance
317 //=============================================================================
319 void Engines_Component_i::Names( const char * graphName ,
320 const char * nodeName )
322 _graphName = graphName ;
323 _nodeName = nodeName ;
324 // MESSAGE("Engines_Component_i::Names( '" << _graphName << "' , '"
325 // << _nodeName << "' )");
328 //=============================================================================
330 * CORBA method: used in Supervision
332 //=============================================================================
334 bool Engines_Component_i::Kill_impl()
336 // MESSAGE("Engines_Component_i::Kill_i() pthread_t "<< pthread_self()
337 // << " pid " << getpid() << " instanceName "
338 // << _instanceName.c_str() << " interface " << _interfaceName.c_str()
339 // << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
340 // << dec << " _ThreadId " << _ThreadId << " this " << hex << this
343 bool RetVal = false ;
345 if ( _ThreadId > 0 && pthread_self() != _ThreadId )
347 RetVal = Killer( _ThreadId , SIGUSR2 ) ;
348 _ThreadId = (pthread_t ) -1 ;
352 if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
354 RetVal = Killer( *_ThreadId , 0 ) ;
355 _ThreadId = (pthread_t* ) 0 ;
362 //=============================================================================
364 * CORBA method: used in Supervision
366 //=============================================================================
368 bool Engines_Component_i::Stop_impl()
371 MESSAGE("Engines_Component_i::Stop_i() pthread_t "<< pthread_self()
372 << " pid " << getpid() << " instanceName "
373 << _instanceName.c_str() << " interface " << _interfaceName.c_str()
374 << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
375 << dec << " _ThreadId " << _ThreadId );
377 MESSAGE("Engines_Component_i::Stop_i() pthread_t "<< pthread_self().p
378 << " pid " << _getpid() << " instanceName "
379 << _instanceName.c_str() << " interface " << _interfaceName.c_str()
380 << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
381 << dec << " _ThreadId " << _ThreadId );
385 bool RetVal = false ;
387 if ( _ThreadId > 0 && pthread_self() != _ThreadId )
389 RetVal = Killer( _ThreadId , 0 ) ;
390 _ThreadId = (pthread_t ) -1 ;
393 if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
395 RetVal = Killer( *_ThreadId , 0 ) ;
396 _ThreadId = (pthread_t* ) 0 ;
402 //=============================================================================
404 * CORBA method: used in Supervision
406 //=============================================================================
408 bool Engines_Component_i::Suspend_impl()
411 MESSAGE("Engines_Component_i::Suspend_i() pthread_t "<< pthread_self()
412 << " pid " << getpid() << " instanceName "
413 << _instanceName.c_str() << " interface " << _interfaceName.c_str()
414 << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
415 << dec << " _ThreadId " << _ThreadId );
417 MESSAGE("Engines_Component_i::Suspend_i() pthread_t "<< pthread_self().p
418 << " pid " << _getpid() << " instanceName "
419 << _instanceName.c_str() << " interface " << _interfaceName.c_str()
420 << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
421 << dec << " _ThreadId " << _ThreadId );
424 bool RetVal = false ;
426 if ( _ThreadId > 0 && pthread_self() != _ThreadId )
428 if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
438 RetVal = Killer( _ThreadId ,SIGINT ) ;
440 RetVal = Killer( *_ThreadId ,SIGINT ) ;
442 //if ( RetVal ) _Sleeping = true;
449 //=============================================================================
451 * CORBA method: used in Supervision
453 //=============================================================================
455 bool Engines_Component_i::Resume_impl()
458 MESSAGE("Engines_Component_i::Resume_i() pthread_t "<< pthread_self()
459 << " pid " << getpid() << " instanceName "
460 << _instanceName.c_str() << " interface " << _interfaceName.c_str()
461 << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
462 << dec << " _ThreadId " << _ThreadId );
464 MESSAGE("Engines_Component_i::Resume_i() pthread_t "<< pthread_self().p
465 << " pid " << _getpid() << " instanceName "
466 << _instanceName.c_str() << " interface " << _interfaceName.c_str()
467 << " machineName " << GetHostname().c_str()<< " _id " << hex << _id
468 << dec << " _ThreadId " << _ThreadId );
470 bool RetVal = false ;
472 if ( _ThreadId > 0 && pthread_self() != _ThreadId )
474 if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
490 //=============================================================================
494 //=============================================================================
496 CORBA::Long Engines_Component_i::CpuUsed_impl()
499 if ( _ThreadId || _Executed )
504 if ( pthread_self() != _ThreadId )
506 if ( pthread_self().p != _ThreadId->p )
514 // Get Cpu in the appropriate thread with that object !...
515 theEngines_Component = this ;
517 Killer( _ThreadId ,SIGUSR1 ) ;
519 Killer( *_ThreadId ,SIGUSR11 ) ;
522 cpu = _ThreadCpuUsed ;
526 _ThreadCpuUsed = CpuUsed() ;
527 cpu = _ThreadCpuUsed ;
528 // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
529 // << _serviceName << " " << cpu << endl ;
534 cpu = _ThreadCpuUsed ;
535 // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
536 // << _serviceName << " " << cpu<< endl ;
541 // cout<< pthread_self()<<"Engines_Component_i::CpuUsed_impl _ThreadId "
542 // <<_ThreadId <<" "<<_serviceName<<" _StartUsed "<<_StartUsed<<endl;
548 //=============================================================================
550 * C++ method: return Container Servant
552 //=============================================================================
554 Engines_Container_i *Engines_Component_i::GetContainerPtr()
556 return dynamic_cast<Engines_Container_i*>(_poa->id_to_servant(*_contId)) ;
559 //=============================================================================
561 * C++ method: set study Id
562 * \param studyId 0 if instance is not associated to a study,
563 * >0 otherwise (== study id)
564 * \return true if the set of study Id is OK
565 * must be set once by Container, at instance creation,
566 * and cannot be changed after.
568 //=============================================================================
570 CORBA::Boolean Engines_Component_i::setStudyId(CORBA::Long studyId)
572 ASSERT( studyId >= 0);
573 CORBA::Boolean ret = false;
574 if (_studyId < 0) // --- not yet initialized
580 if ( _studyId == studyId) ret = true;
584 //=============================================================================
586 * C++ method: return CORBA instance id, the id is set in derived class
587 * constructor, when instance is activated.
589 //=============================================================================
591 PortableServer::ObjectId * Engines_Component_i::getId()
593 // MESSAGE("PortableServer::ObjectId * Engines_Component_i::getId()");
597 //=============================================================================
599 * C++ method: used by derived classes for supervision
601 //=============================================================================
603 void Engines_Component_i::beginService(const char *serviceName)
606 MESSAGE(pthread_self() << "Send BeginService notification for " <<serviceName
607 << endl << "Component instance : " << _instanceName << endl << endl);
609 MESSAGE(pthread_self().p << "Send BeginService notification for " <<serviceName
610 << endl << "Component instance : " << _instanceName << endl << endl);
613 _ThreadId = pthread_self() ;
615 _ThreadId = new pthread_t;
616 _ThreadId->p = pthread_self().p ;
617 _ThreadId->x = pthread_self().x ;
620 _StartUsed = CpuUsed_impl() ;
623 _serviceName = serviceName ;
624 theEngines_Component = this ;
625 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) )
627 perror("pthread_setcanceltype ") ;
630 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) )
632 perror("pthread_setcancelstate ") ;
635 // MESSAGE(pthread_self() << " Return from BeginService for " << serviceName
636 // << " ThreadId " << _ThreadId << " StartUsed " << _StartUsed
637 // << " _graphName " << _graphName << " _nodeName " << _nodeName );
639 // --- for supervisor : all strings given with setProperties
640 // are set in environment
641 bool overwrite = true;
642 map<std::string,CORBA::Any>::iterator it;
643 for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++)
645 std::string cle((*it).first);
646 if ((*it).second.type()->kind() == CORBA::tk_string)
649 (*it).second >>= value;
650 // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC.
652 // int ret = setenv(cle.c_str(), value, overwrite);
653 setenv(cle.c_str(), value, overwrite);
655 //CCRT porting : setenv not defined in stdlib.h
659 // char* cast because 1st arg of linux putenv function
660 // is not a const char* !
661 // int ret=putenv((char *)s.c_str());
662 putenv((char *)s.c_str());
663 //End of CCRT porting
665 MESSAGE("--- setenv: "<<cle<<" = "<< value);
670 //=============================================================================
672 * C++ method: used by derived classes for supervision
674 //=============================================================================
676 void Engines_Component_i::endService(const char *serviceName)
678 if ( !_CanceledThread )
679 _ThreadCpuUsed = CpuUsed_impl() ;
682 MESSAGE(pthread_self() << " Send EndService notification for " << serviceName
683 << endl << " Component instance : " << _instanceName << " StartUsed "
684 << _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
686 MESSAGE(pthread_self().p << " Send EndService notification for " << serviceName
687 << endl << " Component instance : " << _instanceName << " StartUsed "
688 << _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
693 //=============================================================================
695 * C++ method: -- CHECK IF USED --
697 //=============================================================================
699 char* Engines_Component_i::graphName()
701 return CORBA::string_dup( _graphName.c_str() ) ;
704 //=============================================================================
706 * C++ method: -- CHECK IF USED --
708 //=============================================================================
710 char* Engines_Component_i::nodeName()
712 return CORBA::string_dup( _nodeName.c_str() ) ;
715 //=============================================================================
717 * C++ method: used in Supervision (see kill_impl)
719 //=============================================================================
721 bool Engines_Component_i::Killer( pthread_t ThreadId , int signum )
731 if ( pthread_cancel( ThreadId ) )
733 perror("Killer pthread_cancel error") ;
739 MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
740 << " pthread_canceled") ;
742 MESSAGE(pthread_self().p << "Killer : ThreadId " << ThreadId.p
743 << " pthread_canceled") ;
749 if ( pthread_kill( ThreadId , signum ) == -1 )
751 perror("Killer pthread_kill error") ;
757 MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
758 << " pthread_killed(" << signum << ")") ;
760 MESSAGE(pthread_self().p << "Killer : ThreadId " << ThreadId.p
761 << " pthread_killed(" << signum << ")") ;
769 //=============================================================================
773 //=============================================================================
777 if ( theEngines_Component )
778 theEngines_Component->SetCurCpu() ;
781 //=============================================================================
785 //=============================================================================
787 void Engines_Component_i::SetCurCpu()
789 _ThreadCpuUsed = CpuUsed() ;
790 // MESSAGE(pthread_self() <<
791 // " Engines_Component_i::SetCurCpu() _ThreadCpuUsed " << _ThreadCpuUsed) ;
794 //=============================================================================
798 //=============================================================================
800 long Engines_Component_i::CpuUsed()
804 struct rusage usage ;
805 if ( _ThreadId || _Executed )
807 if ( getrusage( RUSAGE_SELF , &usage ) == -1 )
809 perror("Engines_Component_i::CpuUsed") ;
812 cpu = usage.ru_utime.tv_sec - _StartUsed ;
813 // cout << pthread_self() << " Engines_Component_i::CpuUsed " << " "
814 // << _serviceName << usage.ru_utime.tv_sec << " - " << _StartUsed
815 // << " = " << cpu << endl ;
819 // cout << pthread_self() << "Engines_Component_i::CpuUsed _ThreadId "
820 // << _ThreadId << " " << _serviceName<< " _StartUsed "
821 // << _StartUsed << endl ;
824 // NOT implementet yet
831 void CallCancelThread()
833 if ( theEngines_Component )
834 theEngines_Component->CancelThread() ;
837 //=============================================================================
841 //=============================================================================
843 void Engines_Component_i::CancelThread()
845 _CanceledThread = true;
848 //=============================================================================
850 * C++ method: Send message to event channel
852 //=============================================================================
854 void Engines_Component_i::sendMessage(const char *event_type,
857 _notifSupplier->Send(_graphName.c_str(), _nodeName.c_str(), event_type, message);
860 //=============================================================================
862 * C++ method: return standard library name built on component name
864 //=============================================================================
866 string Engines_Component_i::GetDynLibraryName(const char *componentName)
874 //=============================================================================
876 * C++ method: DumpPython default implementation
878 //=============================================================================
880 Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
881 CORBA::Boolean isPublished,
882 CORBA::Boolean& isValidScript)
884 const char* aScript = "def RebuildData(theStudy): pass";
885 char* aBuffer = new char[strlen(aScript)+1];
886 strcpy(aBuffer, aScript);
887 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
888 int aBufferSize = strlen(aBuffer)+1;
889 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
890 isValidScript = true;
891 return aStreamFile._retn();
894 Engines::Salome_file_ptr
895 Engines_Component_i::getInputFileToService(const char* service_name,
896 const char* Salome_file_name)
898 // Try to find the service, if it doesn't exist, we throw an exception.
899 _Service_file_map_it = _Input_Service_file_map.find(service_name);
900 if (_Service_file_map_it == _Input_Service_file_map.end()) {
901 SALOME::ExceptionStruct es;
902 es.type = SALOME::INTERNAL_ERROR;
903 es.text = "service doesn't have salome files";
904 throw SALOME::SALOME_Exception(es);
906 _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
908 // Try to find the Salome_file ...
909 _Salome_file_map_it = _map->find(Salome_file_name);
910 if (_Salome_file_map_it == _map->end()) {
911 SALOME::ExceptionStruct es;
912 es.type = SALOME::INTERNAL_ERROR;
913 es.text = "service doesn't have this Salome_file";
914 throw SALOME::SALOME_Exception(es);
916 Salome_file_i * Sfile = (*_map)[Salome_file_name];
918 return Sfile->_this();
921 Engines::Salome_file_ptr
922 Engines_Component_i::setInputFileToService(const char* service_name,
923 const char* Salome_file_name)
925 // Try to find the service, if it doesn't exist, we add it.
926 _Service_file_map_it = _Input_Service_file_map.find(service_name);
927 if (_Service_file_map_it == _Input_Service_file_map.end()) {
928 _t_Salome_file_map * _map = new _t_Salome_file_map();
929 _Input_Service_file_map[service_name] = _map;
931 _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
933 // Try to find the Salome_file ...
934 _Salome_file_map_it = _map->find(Salome_file_name);
935 if (_Salome_file_map_it == _map->end()) {
936 Salome_file_i * Sfile = new Salome_file_i();
937 Engines::Container_ptr container = this->GetContainerRef();
938 Sfile->setContainer(Engines::Container::_duplicate(container));
939 (*_map)[Salome_file_name] = Sfile;
942 Salome_file_i * Sfile = (*_map)[Salome_file_name];
943 return Sfile->_this();
947 Engines_Component_i::checkInputFilesToService(const char* service_name)
949 // Try to find the service, if it doesn't exist, nothing to do.
950 _Service_file_map_it = _Input_Service_file_map.find(service_name);
951 if (_Service_file_map_it != _Input_Service_file_map.end()) {
952 _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
953 _t_Salome_file_map::iterator begin = _map->begin();
954 _t_Salome_file_map::iterator end = _map->end();
956 for(;begin!=end;begin++) {
957 Salome_file_i * file = begin->second;
958 std::string file_port_name = begin->first;
959 configureSalome_file(service_name, file_port_name, file);
965 Engines::Salome_file_ptr
966 Engines_Component_i::getOutputFileToService(const char* service_name,
967 const char* Salome_file_name)
969 // Try to find the service, if it doesn't exist, we throw an exception.
970 _Service_file_map_it = _Output_Service_file_map.find(service_name);
971 if (_Service_file_map_it == _Output_Service_file_map.end()) {
972 SALOME::ExceptionStruct es;
973 es.type = SALOME::INTERNAL_ERROR;
974 es.text = "service doesn't have salome files";
975 throw SALOME::SALOME_Exception(es);
977 _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
979 // Try to find the Salome_file ...
980 _Salome_file_map_it = _map->find(Salome_file_name);
981 if (_Salome_file_map_it == _map->end()) {
982 SALOME::ExceptionStruct es;
983 es.type = SALOME::INTERNAL_ERROR;
984 es.text = "service doesn't have this Salome_file";
985 throw SALOME::SALOME_Exception(es);
987 Salome_file_i * Sfile = (*_map)[Salome_file_name];
989 return Sfile->_this();
992 Engines::Salome_file_ptr
993 Engines_Component_i::setOutputFileToService(const char* service_name,
994 const char* Salome_file_name)
996 // Try to find the service, if it doesn't exist, we add it.
997 _Service_file_map_it = _Output_Service_file_map.find(service_name);
998 if (_Service_file_map_it == _Output_Service_file_map.end()) {
999 _t_Salome_file_map * _map = new _t_Salome_file_map();
1000 _Output_Service_file_map[service_name] = _map;
1002 _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
1004 // Try to find the Salome_file ...
1005 _Salome_file_map_it = _map->find(Salome_file_name);
1006 if (_Salome_file_map_it == _map->end()) {
1007 Salome_file_i * Sfile = new Salome_file_i();
1008 Engines::Container_ptr container = this->GetContainerRef();
1009 Sfile->setContainer(Engines::Container::_duplicate(container));
1010 (*_map)[Salome_file_name] = Sfile;
1013 Salome_file_i * Sfile = (*_map)[Salome_file_name];
1014 return Sfile->_this();
1018 Engines_Component_i::checkOutputFilesToService(const char* service_name)
1020 // Try to find the service, if it doesn't exist, nothing to do.
1021 _Service_file_map_it = _Output_Service_file_map.find(service_name);
1022 if (_Service_file_map_it != _Output_Service_file_map.end()) {
1023 _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
1024 _t_Salome_file_map::iterator begin = _map->begin();
1025 _t_Salome_file_map::iterator end = _map->end();
1027 for(;begin!=end;begin++) {
1028 Salome_file_i * file = begin->second;
1029 std::string file_port_name = begin->first;
1030 configureSalome_file(service_name, file_port_name, file);
1037 //=============================================================================
1039 * C++ method: used to configure the Salome_file into the runtime.
1040 * \param service_name name of the service that use this Salome_file
1041 * \param file_port_name name of the Salome_file
1042 * \param file Salome_file C++ object
1044 //=============================================================================
1046 Engines_Component_i::configureSalome_file(std::string service_name,
1047 std::string file_port_name,
1048 Salome_file_i * file)
1050 // By default this method does nothing