1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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
23 // File : SALOME_Component.idl
24 // Author : Paul RASCLE, EDF
26 #ifndef _SALOME_COMPONENT_IDL_
27 #define _SALOME_COMPONENT_IDL_
29 #include "SALOME_GenericObj.idl"
30 #include "SALOMEDS.idl"
31 #include "SALOME_Exception.idl"
32 #include "SALOME_PyNode.idl"
33 #include "SALOME_Embedded_NamingService.idl"
34 #include "SALOME_Comm.idl"
36 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
40 This is a package of interfaces used for connecting new components to %SALOME
41 application. It also contains a set of interfaces used for management of %FIELDS
42 component in %SALOME application.
47 A byte stream which is used for binary data transfer between different
50 typedef sequence<octet> TMPFile;
52 //! General Key Value Structure to set or get properties, for component
59 //! Structure data type to hold reference on data
65 typedef sequence<KeyValuePair> FieldsDict;
66 typedef sequence<double> vectorOfDouble;
67 typedef sequence<string> vectorOfString;
69 interface EngineComponent ;
71 interface fileTransfer ;
72 interface Salome_file;
74 /*! \brief Interface of the %Container.
75 This interface defines the process of loading and registration
76 of new components in %SALOME application
82 void override_environment( in FieldsDict env );
84 void override_environment_python( in FieldsDict env );
86 FieldsDict get_os_environment();
88 void execute_python_code( in string code ) raises(SALOME::SALOME_Exception);
90 /*! \brief Loads a new component class (dynamic library).
92 \param componentName like COMPONENT, (Python or C++ implementation)
93 try to make a Python import of COMPONENT,
94 then a lib open of libCOMPONENTEngine.so
95 \param reason in case of error (return false) a string explaining the error
96 \return true if load successful or already done, false otherwise
98 boolean load_component_Library(in string componentName, out string reason);
100 //! Create a new servant instance of a component.
102 Component library must be loaded.
103 \param componentName Name of the component which will be registered
104 in Registry and Name Service,
105 (instance number suffix added to the registered name)
106 \return a loaded component
108 Engines::EngineComponent create_component_instance(in string componentName);
110 //! Create a new Python servant instance of a generic service.
112 This simply loads the service in the current container by importing the
113 corresponding Python module.
114 Warning: no internal registration is done, so it is up to the caller to
115 manage the various instantiation.
116 \param serviceName Name of the service
117 \param reason in case of error (return void string) a string explaining the error
118 \return the IOR of the loaded service.
120 string create_python_service_instance(in string serviceName,
123 //! Create a new servant instance of a component with environment variables specified.
125 Component library must be loaded.
126 \param componentName Name of the component which will be registered
127 in Registry and Name Service,
128 (instance number suffix added to the registered name)
129 \param env a dict of env variables
130 \param reason in case of error (return nil) a string explaining the error
131 \return a loaded component
133 Engines::EngineComponent create_component_instance_env(in string componentName,
136 //! Find a servant instance of a component
138 \param registeredName Name of the component in Registry or Name Service,
139 without instance suffix number
140 \return the first instance found
142 EngineComponent find_component_instance(in string registeredName);
144 //! Find a servant instance of a component, or create a new one.
146 Loads the component library if needed.
147 Only applicable to multiStudy components.
148 \param nameToRegister Name of the component which will be registered
149 in Registry (or Name Service)
150 \param componentName Name of the constructed library of the %component
151 (not used any more, give empty string)
152 \return a loaded component
154 EngineComponent load_impl(in string nameToRegister,
155 in string componentName);
157 //! Remove the component servant, and deletes all related objects
159 \param component_i Component to be removed
161 void remove_impl(in EngineComponent component_i);
163 //! In case of SSL mode Returns entry to Embedded NS
164 EmbeddedNamingService get_embedded_NS_if_ssl();
166 boolean is_SSL_mode();
168 //! Unload component libraries from the container.
169 void finalize_removal() ;
171 //! Determines whether the server has been loaded or not.
174 //! Name of the %container
175 readonly attribute string name ;
177 //! working directory of the %container
178 readonly attribute string workingdir ;
180 //! name of the %container log file (this has been set by the launcher)
181 attribute string logfilename ;
183 //! name of the %container log file
184 attribute string locallogfilename ;
186 //! interval of time between two measures of CPU/time process container
187 attribute long monitoringtimeresms;
189 void verbosity(out boolean activated, out string level);
191 void setVerbosity(in boolean activated, in string level);
193 //! Shutdown the Container process.
196 //! Returns the hostname of the container
197 string getHostName();
199 //! Returns the PID of the container
202 //! Kill the container
204 Returns True if the %container has been killed.
205 Kept for Superv compilation but can't work, unless oneway...
208 boolean Kill_impl() ;
212 returns a fileRef object if origFileName exists and is readable
213 else returns null object. Only one fileRef is created for a given
214 file name, so, several calls with the same file name returns the
217 fileRef createFileRef(in string origFileName);
219 //! Create a Salome_file
221 returns a Salome_file object if origFileName exists and is readable
222 else returns null object.
224 \param origFileName name of the file to be managed (can contain the path).
226 \return Salome_file CORBA reference.
228 Salome_file createSalome_file(in string origFileName);
230 //! Create a fileTransfer
232 returns a fileTransfer object used to copy files from the container
233 machine to the clients machines. Only one fileTransfer instance is
234 created in a container.
236 fileTransfer getFileTransfer();
238 //! Copy a file from a remote host (container) to a local file
240 \param contai the remote container
241 \param remoteFile the file on the remote host to copy
242 \param localFile the local file to create by copy
244 void copyFile(in Container contai, in string remoteFile, in string localFile);
246 //! Create a PyNode in the container
248 \param nodeName the name of the PyNode
249 \param code python code as text to load in the node
251 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
253 //! Retrieves the last created PyNode instance with createPyNode.
254 PyNode getDefaultPyNode(in string nodeName);
256 //! Create a PyScriptNode in the container
258 \param nodeName the name of the PyScriptNode
259 \param code python code as text to load in the node
261 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
263 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
265 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
266 PyScriptNode getDefaultPyScriptNode(in string nodeName);
268 //! This method remove all refs of PyScriptNode servant objects stored in server.
270 * Previous scripts created on container may have been stored in a map. This method removes them. It then clean all the contexts dict attached to them.
272 void cleanAllPyScripts();
274 //! Return number of CPU cores in the calculation node.
275 long getNumberOfCPUCores();
277 //! Return a load of each CPU core.
278 vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
280 //! Set custom script to calculate a load of each CPU core.
282 \param script Python script to execute
284 void setPyScriptForCPULoad(in string script);
286 //! Nullify custom script to calculate each CPU core's load.
287 void resetScriptForCPULoad();
289 //! Get total physical memory of calculation node, in megabytes.
290 long getTotalPhysicalMemory();
292 //! Get used physical memory of calculation node, in megabytes.
293 long getTotalPhysicalMemoryInUse();
295 //! Obtain physical memory, used by the current process, in megabytes.
296 long getTotalPhysicalMemoryInUseByMe();
299 /*! \brief Interface of the %component.
300 This interface is used for interaction between the %container and the
301 %component and between the components inside the container.
303 interface EngineComponent
305 //! The name of the instance of the %Component
306 readonly attribute string instanceName ;
308 //! The name of the interface of the %Component
309 readonly attribute string interfaceName ;
311 //! Determines whether the server has already been loaded or not.
314 boolean isSSLMode() raises(SALOME::SALOME_Exception);
315 //! Remove component instance from container
317 Deactivates the %Component.
318 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
319 use remove_impl from Container instead !
323 //! Returns the container that the %Component refers to.
324 Container GetContainerRef() ;
326 //! Set component instance properties
328 Gives a sequence of (key=string,value=any) to the component.
329 Base class component stores the sequence in a map.
330 The map is cleared before.
331 This map is for use by derived classes.
333 void setProperties(in FieldsDict dico);
335 //! Get component instance properties
337 returns a previously stored map (key=string,value=any) as a sequence.
338 See setProperties(in FieldsDict dico).
340 FieldsDict getProperties();
342 //! Set an option value
344 This method is to set an option specific to a certain EngineComponent.
346 void SetOption(in string optionName, in string value);
348 //! Return an option value
350 This method is to get value of an option specific to a certain EngineComponent.
352 string GetOption(in string optionName);
354 //! Set name of a node in a graph (for %SUPERVISOR use)
356 This method is used by the %SUPERVISOR component. It sets the names of
357 the graph and of the node.
358 \param aGraphName Name of graph
359 \param aNodeName Name of node
361 void Names( in string aGraphName , in string aNodeName ) ;
363 //! Kill the component (if you can)
365 Returns True if the %Component has been killed.
367 boolean Kill_impl() ;
369 //! Stop the component (if you can)
371 Returns True if the activity of the %Component has been stopped.
372 (It's action can't be resumed)
374 boolean Stop_impl() ;
376 //! Suspend the component
378 Returns True if the activity of the %Component has been suspended.
379 (It's action can be resumed)
381 boolean Suspend_impl() ;
383 //! Resume the component
385 Returns True if the activity of the %Component has been resumed.
387 boolean Resume_impl() ;
393 long CpuUsed_impl() ;
395 //! Get a python dump
397 Returns a python script, which is being played back reproduces
398 the data model of component
400 TMPFile DumpPython(in boolean isPublished,
401 in boolean isMultiFile,
402 out boolean isValidScript);
405 //! Returns a CORBA Ref of a input Salome_file managed by a service.
408 \param service_name service's name.
409 \param file_name name of the requested file.
411 \return CORBA Ref of the requested file.
413 \exception contains information of what if the component cannot
414 sends the file's reference.
416 Engines::Salome_file getInputFileToService(in string service_name,
417 in string Salome_file_name) raises(SALOME::SALOME_Exception);
419 //! Check service input files (transfer them if needed)
421 This method is used before the activation of the service. It calls
422 recvFiles() on all the input Salome_file files of the service.
424 Before each recvFiles(), it uses the callback method named configureSalome_file.
425 This method allows the user to configure the files managed by the Salome_file.
427 By default, there is no files managed when a Salome_file is created,
428 but the supervisor set some files managed by the Salome_file from the information contained
429 into the schema file.
431 \param service_name service's name.
433 \exception contains information about files that are not in a good state.
435 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
437 //! This method adds a input Salome_file to a service of the component.
440 \param service_name service's name.
441 \param Salome_file_name name of the Salome_file
443 \return a reference of the Salome_file
445 \exception raises an exception if there is already
446 a Salome_file with this name for the service.
448 Engines::Salome_file setInputFileToService(in string service_name,
449 in string Salome_file_name) raises(SALOME::SALOME_Exception);
451 //! Returns a CORBA Ref of a output Salome_file managed by a service.
454 \param service_name service's name.
455 \param file_name name of the requested file.
457 \return CORBA Ref of the requested file.
459 \exception contains information of what if the component cannot
460 sends the file's reference.
462 Engines::Salome_file getOutputFileToService(in string service_name,
463 in string Salome_file_name) raises(SALOME::SALOME_Exception);
465 //! Check service output files (transfer them if needed)
467 This method is used at the end of the service. It calls
468 recvFiles() on all the output Salome_file files of the service.
470 Before each recvFiles(), it uses the callback method named configureSalome_file.
471 This method allows the user to configure the files managed by the Salome_file.
473 By default, there is no files managed when a Salome_file is created,
474 but the supervisor set some files managed by the Salome_file from the information contained
475 into the schema file.
477 \param service_name service's name.
479 \exception contains information about files that are not in a good state.
481 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
483 //! This method adds an output Salome_file to a service of the component.
486 \param service_name service's name.
487 \param Salome_file_name name of the Salome_file
489 \return a reference of the Salome_file
491 \exception raises an exception if there is already
492 a Salome_file with this name for the service.
494 Engines::Salome_file setOutputFileToService(in string service_name,
495 in string Salome_file_name) raises(SALOME::SALOME_Exception);
497 //! Indicate if the component instance provides custom information about its objects.
499 Returns true if the component provides custom information about its objects, false otherwise.
500 Should be redefined in the certain component to return true in case of this
501 component provides such information.
503 boolean hasObjectInfo();
505 //! Get custom information about the given object.
507 This method is used to get the custom information about the given object.
508 Should be redefined in the certain component in case of this
509 component provides such information.
510 It is worth using this method only if hasObjectInfo() method returns true.
512 \param entry object's entry.
514 \return an information about the given object.
516 string getObjectInfo(in string entry);
518 //! Get version of the component
520 This method is supposed to be implemented in all derived classes; default implementation
521 returns "unknown" string that means that no version information about the component is available.
522 \note The version of the component is stored to the study, as a part of general persistence
523 mechanism; once stored, version information in the study cannot be changed.
525 \return string containing component's version, e.g. "1.0"
531 \brief Base interface of the %component that supports exporting data.
533 interface ImportableComponent
535 /*! \brief Get a list of supported formats */
536 SALOME::StringSeq GetImportableFormats();
537 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
540 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
541 typedef sequence<octet> fileBlock;
543 /*! \brief Interface of fileTransfer.
544 The fileTransfer and fileRef interfaces provide a file transfer service
545 between different computers.
547 interface fileTransfer : SALOME::GenericObj
549 //! Open the file transfer
551 open method returns a key (fileId) that identifies the structure
552 (ex: C FILE), associated to the original file on the server.
553 The structure is created by a container for transfer of files availables
554 on the computer which runs the container.
555 Each open gives a unique fileId, to allow concurrent reads of the same
558 long open(in string fileName);
559 //! Open the file transfer in write mode for file fileName
561 \param fileName the file to copy into with putBlock
562 \return the id to use with putBlock
564 long openW(in string fileName);
566 //! Close the file transfer
568 when the file transfer is finished, close method releases structures
569 created by open method, identified by fileId.
571 void close(in long fileId);
573 //! Get a file data block
575 Get successive blocks of octets from the original file.
576 The last block is empty, and identifies the end of file.
578 fileBlock getBlock(in long fileId);
580 //! Put a file data block
582 \param fileId identification of the file obtained by openW
583 \param block a data block to copy into the file identified by fileId
585 void putBlock(in long fileId, in fileBlock block);
589 //! A file managed by a Salome_file.
596 string source_file_name;
597 //! status ("present" or "notpresent")
600 Engines::Container container;
603 //! A sequence of Engines::file.
604 typedef sequence<Engines::file> files;
607 //! The state of a Salome_file.
611 //! hdf5 file where the file can be saved
612 string hdf5_file_name;
613 //! number of files managed
614 long number_of_files;
615 //! information if all the files are received
620 /*! \brief Interface of a Salome_file managed
621 This file is independent of a Salome module. It can managed one or more
622 real files. It's useful for parallel files. Currently Salome_file cannot manage
623 two files that have the same name but not the same path.
625 interface Salome_file : Engines::fileTransfer
627 //! Load a Salome_file from a hdf5 file.
630 \param hdf5_file name (with path) of the hdf5_file.
632 \exception contains information of errors if the loading doesn't succeed.
634 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
636 //! Save a Salome_file into a hdf5_file.
639 \param hdf5_file name (with path) of the hdf5_file.
641 \exception contains information of errors if the save doesn't succeed.
644 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
646 //! Save a Salome_file into a hdf5_file.
648 All files that are managed are saved into the hdf5_file
650 \param hdf5_file name (with path) of the hdf5_file.
652 \exception contains information of errors if the save doesn't succeed.
655 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
659 //! Add a Local file to the Salome_file.
662 \param file_name name of the file with the path.
664 \exception raised if the file is already added into the Salome_file.
666 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
668 //! Add a Distributed file to the Salome_file.
671 \param comp_file_name name of the file with the path.
673 \exception raised if the file is already added into the Salome_file.
675 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
677 //! Connect a Salome_file with another Salome_file.
679 It works only if the Salome_file managed only one file
681 \param source_Salome_file Salome_file that managed the distributed version of the file.
683 \exception raised if there is more or less than one file.
685 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
687 //! Connect the managed file file_name to a Salome_file.
690 \param file_name name of the file without the path.
691 \param source_Salome_file Salome_file that managed the distributed version of the file.
693 \exception raised if the file doesn't exist.
695 void connectDistributedFile(in string file_name,
696 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
698 //! Connect the file_name with a Distributed file_name.
701 \param file_name name of the file without the path.
702 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
704 \exception raised if the file doesn't exist.
706 void setDistributedSourceFile(in string file_name,
707 in string source_file_name) raises (SALOME::SALOME_Exception);
711 //! Get all the distributed files managed by the Salome_file and check all the local files.
714 \exception raised if some of the files are not ok.
716 void recvFiles() raises (SALOME::SALOME_Exception) ;
720 //! Remove a file of the Salome_file.
723 \param file_name name of the file.
725 \exception raised if the file doesn't exist.
727 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
729 //! Remove all the files of the Salome_file.
734 //! Get the list of the files managed by the Salome_file.
736 The list can be empty.
738 Engines::files getFilesInfos();
740 //! Get a file managed by the Salome_file.
743 \param file_name the name of the file.
745 \return CORBA file reference.
747 \exception raised if the file doesn't exist.
749 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
751 //! Return the state of the Salome_file.
752 Engines::SfState getSalome_fileState();
755 //! Set the container where files are.
758 \param container container CORBA's reference.
760 void setContainer(in Engines::Container container);
763 /*! \brief Interface of fileRef.
764 The fileTransfer and fileRef interfaces provide a file transfer service
765 between different computers.
767 A fileRef object is associated to an original file (origFileName) on a
768 machine (refMachine).
769 It is created by a container (factoryServer) on refMachine,
770 with createFileRef(in string origFileName) method.
771 The fileRef object maintains a list of (machine,filename) for copies.
772 If a copy exists on myMachine, getRef(myMachine) returns the file name
773 of the copy on myMachine, else returns empty string.
774 If there is no copy on myMachine, method getFileTransfer() from container
775 factoryServer on refMachine provides a fileTransfer object dedicated to
777 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
778 the file name of the copy on myMachine.
782 //! the original file
783 readonly attribute string origFileName;
784 //! the machine of the original file
785 readonly attribute string refMachine;
787 Container getContainer();
789 boolean addRef(in string machine,
792 string getRef(in string machine);