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"
35 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
39 This is a package of interfaces used for connecting new components to %SALOME
40 application. It also contains a set of interfaces used for management of %FIELDS
41 component in %SALOME application.
46 A byte stream which is used for binary data transfer between different
49 typedef sequence<octet> TMPFile;
51 //! General Key Value Structure to set or get properties, for component
58 //! Structure data type to hold reference on data
64 typedef sequence<KeyValuePair> FieldsDict;
65 typedef sequence<double> vectorOfDouble;
66 typedef sequence<string> vectorOfString;
68 interface EngineComponent ;
70 interface fileTransfer ;
71 interface Salome_file;
73 /*! \brief Interface of the %Container.
74 This interface defines the process of loading and registration
75 of new components in %SALOME application
81 void override_environment( in FieldsDict env );
83 void override_environment_python( in FieldsDict env );
85 FieldsDict get_os_environment();
87 void execute_python_code( in string code ) raises(SALOME::SALOME_Exception);
89 /*! \brief Loads a new component class (dynamic library).
91 \param componentName like COMPONENT, (Python or C++ implementation)
92 try to make a Python import of COMPONENT,
93 then a lib open of libCOMPONENTEngine.so
94 \param reason in case of error (return false) a string explaining the error
95 \return true if load successful or already done, false otherwise
97 boolean load_component_Library(in string componentName, out string reason);
99 //! Create a new servant instance of a component.
101 Component library must be loaded.
102 \param componentName Name of the component which will be registered
103 in Registry and Name Service,
104 (instance number suffix added to the registered name)
105 \return a loaded component
107 Engines::EngineComponent create_component_instance(in string componentName);
109 //! Create a new Python servant instance of a generic service.
111 This simply loads the service in the current container by importing the
112 corresponding Python module.
113 Warning: no internal registration is done, so it is up to the caller to
114 manage the various instantiation.
115 \param serviceName Name of the service
116 \param reason in case of error (return void string) a string explaining the error
117 \return the IOR of the loaded service.
119 string create_python_service_instance(in string serviceName,
122 //! Create a new servant instance of a component with environment variables specified.
124 Component library must be loaded.
125 \param componentName Name of the component which will be registered
126 in Registry and Name Service,
127 (instance number suffix added to the registered name)
128 \param env a dict of env variables
129 \param reason in case of error (return nil) a string explaining the error
130 \return a loaded component
132 Engines::EngineComponent create_component_instance_env(in string componentName,
135 //! Find a servant instance of a component
137 \param registeredName Name of the component in Registry or Name Service,
138 without instance suffix number
139 \return the first instance found
141 EngineComponent find_component_instance(in string registeredName);
143 //! Find a servant instance of a component, or create a new one.
145 Loads the component library if needed.
146 Only applicable to multiStudy components.
147 \param nameToRegister Name of the component which will be registered
148 in Registry (or Name Service)
149 \param componentName Name of the constructed library of the %component
150 (not used any more, give empty string)
151 \return a loaded component
153 EngineComponent load_impl(in string nameToRegister,
154 in string componentName);
156 //! Remove the component servant, and deletes all related objects
158 \param component_i Component to be removed
160 void remove_impl(in EngineComponent component_i);
162 //! In case of SSL mode Returns entry to Embedded NS
163 EmbeddedNamingService get_embedded_NS_if_ssl();
165 boolean is_SSL_mode();
167 //! Unload component libraries from the container.
168 void finalize_removal() ;
170 //! Determines whether the server has been loaded or not.
173 //! Name of the %container
174 readonly attribute string name ;
176 //! working directory of the %container
177 readonly attribute string workingdir ;
179 //! name of the %container log file (this has been set by the launcher)
180 attribute string logfilename ;
182 //! Shutdown the Container process.
185 //! Returns the hostname of the container
186 string getHostName();
188 //! Returns the PID of the container
191 //! Kill the container
193 Returns True if the %container has been killed.
194 Kept for Superv compilation but can't work, unless oneway...
197 boolean Kill_impl() ;
201 returns a fileRef object if origFileName exists and is readable
202 else returns null object. Only one fileRef is created for a given
203 file name, so, several calls with the same file name returns the
206 fileRef createFileRef(in string origFileName);
208 //! Create a Salome_file
210 returns a Salome_file object if origFileName exists and is readable
211 else returns null object.
213 \param origFileName name of the file to be managed (can contain the path).
215 \return Salome_file CORBA reference.
217 Salome_file createSalome_file(in string origFileName);
219 //! Create a fileTransfer
221 returns a fileTransfer object used to copy files from the container
222 machine to the clients machines. Only one fileTransfer instance is
223 created in a container.
225 fileTransfer getFileTransfer();
227 //! Copy a file from a remote host (container) to a local file
229 \param contai the remote container
230 \param remoteFile the file on the remote host to copy
231 \param localFile the local file to create by copy
233 void copyFile(in Container contai, in string remoteFile, in string localFile);
235 //! Create a PyNode in the container
237 \param nodeName the name of the PyNode
238 \param code python code as text to load in the node
240 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
242 //! Retrieves the last created PyNode instance with createPyNode.
243 PyNode getDefaultPyNode(in string nodeName);
245 //! Create a PyScriptNode in the container
247 \param nodeName the name of the PyScriptNode
248 \param code python code as text to load in the node
250 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
252 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
254 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
255 PyScriptNode getDefaultPyScriptNode(in string nodeName);
257 //! This method remove all refs of PyScriptNode servant objects stored in server.
259 * 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.
261 void cleanAllPyScripts();
263 //! Return number of CPU cores in the calculation node.
264 long getNumberOfCPUCores();
266 //! Return a load of each CPU core.
267 vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
269 //! Set custom script to calculate a load of each CPU core.
271 \param script Python script to execute
273 void setPyScriptForCPULoad(in string script);
275 //! Nullify custom script to calculate each CPU core's load.
276 void resetScriptForCPULoad();
278 //! Get total physical memory of calculation node, in megabytes.
279 long getTotalPhysicalMemory();
281 //! Get used physical memory of calculation node, in megabytes.
282 long getTotalPhysicalMemoryInUse();
284 //! Obtain physical memory, used by the current process, in megabytes.
285 long getTotalPhysicalMemoryInUseByMe();
288 /*! \brief Interface of the %component.
289 This interface is used for interaction between the %container and the
290 %component and between the components inside the container.
292 interface EngineComponent
294 //! The name of the instance of the %Component
295 readonly attribute string instanceName ;
297 //! The name of the interface of the %Component
298 readonly attribute string interfaceName ;
300 //! Determines whether the server has already been loaded or not.
303 boolean isSSLMode() raises(SALOME::SALOME_Exception);
304 //! Remove component instance from container
306 Deactivates the %Component.
307 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
308 use remove_impl from Container instead !
312 //! Returns the container that the %Component refers to.
313 Container GetContainerRef() ;
315 //! Set component instance properties
317 Gives a sequence of (key=string,value=any) to the component.
318 Base class component stores the sequence in a map.
319 The map is cleared before.
320 This map is for use by derived classes.
322 void setProperties(in FieldsDict dico);
324 //! Get component instance properties
326 returns a previously stored map (key=string,value=any) as a sequence.
327 See setProperties(in FieldsDict dico).
329 FieldsDict getProperties();
331 //! Set an option value
333 This method is to set an option specific to a certain EngineComponent.
335 void SetOption(in string optionName, in string value);
337 //! Return an option value
339 This method is to get value of an option specific to a certain EngineComponent.
341 string GetOption(in string optionName);
343 //! Set name of a node in a graph (for %SUPERVISOR use)
345 This method is used by the %SUPERVISOR component. It sets the names of
346 the graph and of the node.
347 \param aGraphName Name of graph
348 \param aNodeName Name of node
350 void Names( in string aGraphName , in string aNodeName ) ;
352 //! Kill the component (if you can)
354 Returns True if the %Component has been killed.
356 boolean Kill_impl() ;
358 //! Stop the component (if you can)
360 Returns True if the activity of the %Component has been stopped.
361 (It's action can't be resumed)
363 boolean Stop_impl() ;
365 //! Suspend the component
367 Returns True if the activity of the %Component has been suspended.
368 (It's action can be resumed)
370 boolean Suspend_impl() ;
372 //! Resume the component
374 Returns True if the activity of the %Component has been resumed.
376 boolean Resume_impl() ;
382 long CpuUsed_impl() ;
384 //! Get a python dump
386 Returns a python script, which is being played back reproduces
387 the data model of component
389 TMPFile DumpPython(in boolean isPublished,
390 in boolean isMultiFile,
391 out boolean isValidScript);
394 //! Returns a CORBA Ref of a input Salome_file managed by a service.
397 \param service_name service's name.
398 \param file_name name of the requested file.
400 \return CORBA Ref of the requested file.
402 \exception contains information of what if the component cannot
403 sends the file's reference.
405 Engines::Salome_file getInputFileToService(in string service_name,
406 in string Salome_file_name) raises(SALOME::SALOME_Exception);
408 //! Check service input files (transfer them if needed)
410 This method is used before the activation of the service. It calls
411 recvFiles() on all the input Salome_file files of the service.
413 Before each recvFiles(), it uses the callback method named configureSalome_file.
414 This method allows the user to configure the files managed by the Salome_file.
416 By default, there is no files managed when a Salome_file is created,
417 but the supervisor set some files managed by the Salome_file from the information contained
418 into the schema file.
420 \param service_name service's name.
422 \exception contains information about files that are not in a good state.
424 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
426 //! This method adds a input Salome_file to a service of the component.
429 \param service_name service's name.
430 \param Salome_file_name name of the Salome_file
432 \return a reference of the Salome_file
434 \exception raises an exception if there is already
435 a Salome_file with this name for the service.
437 Engines::Salome_file setInputFileToService(in string service_name,
438 in string Salome_file_name) raises(SALOME::SALOME_Exception);
440 //! Returns a CORBA Ref of a output Salome_file managed by a service.
443 \param service_name service's name.
444 \param file_name name of the requested file.
446 \return CORBA Ref of the requested file.
448 \exception contains information of what if the component cannot
449 sends the file's reference.
451 Engines::Salome_file getOutputFileToService(in string service_name,
452 in string Salome_file_name) raises(SALOME::SALOME_Exception);
454 //! Check service output files (transfer them if needed)
456 This method is used at the end of the service. It calls
457 recvFiles() on all the output Salome_file files of the service.
459 Before each recvFiles(), it uses the callback method named configureSalome_file.
460 This method allows the user to configure the files managed by the Salome_file.
462 By default, there is no files managed when a Salome_file is created,
463 but the supervisor set some files managed by the Salome_file from the information contained
464 into the schema file.
466 \param service_name service's name.
468 \exception contains information about files that are not in a good state.
470 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
472 //! This method adds an output Salome_file to a service of the component.
475 \param service_name service's name.
476 \param Salome_file_name name of the Salome_file
478 \return a reference of the Salome_file
480 \exception raises an exception if there is already
481 a Salome_file with this name for the service.
483 Engines::Salome_file setOutputFileToService(in string service_name,
484 in string Salome_file_name) raises(SALOME::SALOME_Exception);
486 //! Indicate if the component instance provides custom information about its objects.
488 Returns true if the component provides custom information about its objects, false otherwise.
489 Should be redefined in the certain component to return true in case of this
490 component provides such information.
492 boolean hasObjectInfo();
494 //! Get custom information about the given object.
496 This method is used to get the custom information about the given object.
497 Should be redefined in the certain component in case of this
498 component provides such information.
499 It is worth using this method only if hasObjectInfo() method returns true.
501 \param entry object's entry.
503 \return an information about the given object.
505 string getObjectInfo(in string entry);
507 //! Get version of the component
509 This method is supposed to be implemented in all derived classes; default implementation
510 returns "unknown" string that means that no version information about the component is available.
511 \note The version of the component is stored to the study, as a part of general persistence
512 mechanism; once stored, version information in the study cannot be changed.
514 \return string containing component's version, e.g. "1.0"
520 \brief Base interface of the %component that supports exporting data.
522 interface ImportableComponent
524 /*! \brief Get a list of supported formats */
525 SALOME::StringSeq GetImportableFormats();
526 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
529 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
530 typedef sequence<octet> fileBlock;
532 /*! \brief Interface of fileTransfer.
533 The fileTransfer and fileRef interfaces provide a file transfer service
534 between different computers.
536 interface fileTransfer : SALOME::GenericObj
538 //! Open the file transfer
540 open method returns a key (fileId) that identifies the structure
541 (ex: C FILE), associated to the original file on the server.
542 The structure is created by a container for transfer of files availables
543 on the computer which runs the container.
544 Each open gives a unique fileId, to allow concurrent reads of the same
547 long open(in string fileName);
548 //! Open the file transfer in write mode for file fileName
550 \param fileName the file to copy into with putBlock
551 \return the id to use with putBlock
553 long openW(in string fileName);
555 //! Close the file transfer
557 when the file transfer is finished, close method releases structures
558 created by open method, identified by fileId.
560 void close(in long fileId);
562 //! Get a file data block
564 Get successive blocks of octets from the original file.
565 The last block is empty, and identifies the end of file.
567 fileBlock getBlock(in long fileId);
569 //! Put a file data block
571 \param fileId identification of the file obtained by openW
572 \param block a data block to copy into the file identified by fileId
574 void putBlock(in long fileId, in fileBlock block);
578 //! A file managed by a Salome_file.
585 string source_file_name;
586 //! status ("present" or "notpresent")
589 Engines::Container container;
592 //! A sequence of Engines::file.
593 typedef sequence<Engines::file> files;
596 //! The state of a Salome_file.
600 //! hdf5 file where the file can be saved
601 string hdf5_file_name;
602 //! number of files managed
603 long number_of_files;
604 //! information if all the files are received
609 /*! \brief Interface of a Salome_file managed
610 This file is independent of a Salome module. It can managed one or more
611 real files. It's useful for parallel files. Currently Salome_file cannot manage
612 two files that have the same name but not the same path.
614 interface Salome_file : Engines::fileTransfer
616 //! Load a Salome_file from a hdf5 file.
619 \param hdf5_file name (with path) of the hdf5_file.
621 \exception contains information of errors if the loading doesn't succeed.
623 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
625 //! Save a Salome_file into a hdf5_file.
628 \param hdf5_file name (with path) of the hdf5_file.
630 \exception contains information of errors if the save doesn't succeed.
633 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
635 //! Save a Salome_file into a hdf5_file.
637 All files that are managed are saved into the 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_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
648 //! Add a Local file to the Salome_file.
651 \param file_name name of the file with the path.
653 \exception raised if the file is already added into the Salome_file.
655 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
657 //! Add a Distributed file to the Salome_file.
660 \param comp_file_name name of the file with the path.
662 \exception raised if the file is already added into the Salome_file.
664 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
666 //! Connect a Salome_file with another Salome_file.
668 It works only if the Salome_file managed only one file
670 \param source_Salome_file Salome_file that managed the distributed version of the file.
672 \exception raised if there is more or less than one file.
674 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
676 //! Connect the managed file file_name to a Salome_file.
679 \param file_name name of the file without the path.
680 \param source_Salome_file Salome_file that managed the distributed version of the file.
682 \exception raised if the file doesn't exist.
684 void connectDistributedFile(in string file_name,
685 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
687 //! Connect the file_name with a Distributed file_name.
690 \param file_name name of the file without the path.
691 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
693 \exception raised if the file doesn't exist.
695 void setDistributedSourceFile(in string file_name,
696 in string source_file_name) raises (SALOME::SALOME_Exception);
700 //! Get all the distributed files managed by the Salome_file and check all the local files.
703 \exception raised if some of the files are not ok.
705 void recvFiles() raises (SALOME::SALOME_Exception) ;
709 //! Remove a file of the Salome_file.
712 \param file_name name of the file.
714 \exception raised if the file doesn't exist.
716 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
718 //! Remove all the files of the Salome_file.
723 //! Get the list of the files managed by the Salome_file.
725 The list can be empty.
727 Engines::files getFilesInfos();
729 //! Get a file managed by the Salome_file.
732 \param file_name the name of the file.
734 \return CORBA file reference.
736 \exception raised if the file doesn't exist.
738 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
740 //! Return the state of the Salome_file.
741 Engines::SfState getSalome_fileState();
744 //! Set the container where files are.
747 \param container container CORBA's reference.
749 void setContainer(in Engines::Container container);
752 /*! \brief Interface of fileRef.
753 The fileTransfer and fileRef interfaces provide a file transfer service
754 between different computers.
756 A fileRef object is associated to an original file (origFileName) on a
757 machine (refMachine).
758 It is created by a container (factoryServer) on refMachine,
759 with createFileRef(in string origFileName) method.
760 The fileRef object maintains a list of (machine,filename) for copies.
761 If a copy exists on myMachine, getRef(myMachine) returns the file name
762 of the copy on myMachine, else returns empty string.
763 If there is no copy on myMachine, method getFileTransfer() from container
764 factoryServer on refMachine provides a fileTransfer object dedicated to
766 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
767 the file name of the copy on myMachine.
771 //! the original file
772 readonly attribute string origFileName;
773 //! the machine of the original file
774 readonly attribute string refMachine;
776 Container getContainer();
778 boolean addRef(in string machine,
781 string getRef(in string machine);