1 // Copyright (C) 2007-2024 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;
68 typedef sequence<vectorOfString> vectorOfVectorOfString;
70 interface EngineComponent ;
72 interface fileTransfer ;
73 interface Salome_file;
75 /*! \brief Interface of the %Container.
76 This interface defines the process of loading and registration
77 of new components in %SALOME application
83 void override_environment( in FieldsDict env );
85 void override_environment_python( in FieldsDict env );
87 FieldsDict get_os_environment();
89 void set_big_obj_on_disk_threshold(in long thresholdInByte);
91 void set_big_obj_on_disk_directory(in string directory);
93 void set_directory_for_replay_files(in string directory);
95 void set_number_of_retry(in long nbRetry);
97 void set_startup_code(in string codeAtStartUp);
99 string get_startup_code();
101 void addLogFileNameGroup(in vectorOfString groupOfLogFileNames);
103 vectorOfVectorOfString getAllLogFileNameGroups();
105 void execute_python_code( in string code ) raises(SALOME::SALOME_Exception);
107 /*! \brief Loads a new component class (dynamic library).
109 \param componentName like COMPONENT, (Python or C++ implementation)
110 try to make a Python import of COMPONENT,
111 then a lib open of libCOMPONENTEngine.so
112 \param reason in case of error (return false) a string explaining the error
113 \return true if load successful or already done, false otherwise
115 boolean load_component_Library(in string componentName, out string reason);
117 //! Create a new servant instance of a component.
119 Component library must be loaded.
120 \param componentName Name of the component which will be registered
121 in Registry and Name Service,
122 (instance number suffix added to the registered name)
123 \return a loaded component
125 Engines::EngineComponent create_component_instance(in string componentName);
127 //! Create a new Python servant instance of a generic service.
129 This simply loads the service in the current container by importing the
130 corresponding Python module.
131 Warning: no internal registration is done, so it is up to the caller to
132 manage the various instantiation.
133 \param serviceName Name of the service
134 \param reason in case of error (return void string) a string explaining the error
135 \return the IOR of the loaded service.
137 string create_python_service_instance(in string serviceName,
140 //! Create a new servant instance of a component with environment variables specified.
142 Component library must be loaded.
143 \param componentName Name of the component which will be registered
144 in Registry and Name Service,
145 (instance number suffix added to the registered name)
146 \param env a dict of env variables
147 \param reason in case of error (return nil) a string explaining the error
148 \return a loaded component
150 Engines::EngineComponent create_component_instance_env(in string componentName,
153 //! Find a servant instance of a component
155 \param registeredName Name of the component in Registry or Name Service,
156 without instance suffix number
157 \return the first instance found
159 EngineComponent find_component_instance(in string registeredName);
161 //! Find a servant instance of a component, or create a new one.
163 Loads the component library if needed.
164 Only applicable to multiStudy components.
165 \param nameToRegister Name of the component which will be registered
166 in Registry (or Name Service)
167 \param componentName Name of the constructed library of the %component
168 (not used any more, give empty string)
169 \return a loaded component
171 EngineComponent load_impl(in string nameToRegister,
172 in string componentName);
174 //! Remove the component servant, and deletes all related objects
176 \param component_i Component to be removed
178 void remove_impl(in EngineComponent component_i);
180 //! In case of SSL mode Returns entry to Embedded NS
181 EmbeddedNamingService get_embedded_NS_if_ssl();
183 boolean is_SSL_mode();
185 //! Unload component libraries from the container.
186 void finalize_removal() ;
188 //! Determines whether the server has been loaded or not.
191 //! Name of the %container
192 readonly attribute string name ;
194 //! working directory of the %container
195 readonly attribute string workingdir ;
197 //! name of the %container log file (this has been set by the launcher)
198 attribute string logfilename ;
200 //! name of the %container log file
201 attribute string locallogfilename ;
203 //! interval of time between two measures of CPU/time process container
204 attribute long monitoringtimeresms;
206 void verbosity(out boolean activated, out string level);
208 void setVerbosity(in boolean activated, in string level);
210 //! Shutdown the Container process. Shutdown is not immediate. It waits for all remaining invokation completion.
213 //! Shutdown the Container process. Shutdown is immediate for this method.
216 //! Returns the hostname of the container
217 string getHostName();
219 //! Returns the PID of the container
222 //! Kill the container
224 Returns True if the %container has been killed.
225 Kept for Superv compilation but can't work, unless oneway...
228 boolean Kill_impl() ;
232 returns a fileRef object if origFileName exists and is readable
233 else returns null object. Only one fileRef is created for a given
234 file name, so, several calls with the same file name returns the
237 fileRef createFileRef(in string origFileName);
239 //! Create a Salome_file
241 returns a Salome_file object if origFileName exists and is readable
242 else returns null object.
244 \param origFileName name of the file to be managed (can contain the path).
246 \return Salome_file CORBA reference.
248 Salome_file createSalome_file(in string origFileName);
250 //! Create a fileTransfer
252 returns a fileTransfer object used to copy files from the container
253 machine to the clients machines. Only one fileTransfer instance is
254 created in a container.
256 fileTransfer getFileTransfer();
258 //! Copy a file from a remote host (container) to a local file
260 \param contai the remote container
261 \param remoteFile the file on the remote host to copy
262 \param localFile the local file to create by copy
264 void copyFile(in Container contai, in string remoteFile, in string localFile);
266 //! Create a PyNode in the container
268 \param nodeName the name of the PyNode
269 \param code python code as text to load in the node
271 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
273 //! Retrieves the last created PyNode instance with createPyNode.
274 PyNode getDefaultPyNode(in string nodeName);
276 //! Create a PyScriptNode in the container
278 \param nodeName the name of the PyScriptNode
279 \param code python code as text to load in the node
281 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
283 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
285 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
286 PyScriptNode getDefaultPyScriptNode(in string nodeName);
288 //! This method remove all refs of PyScriptNode servant objects stored in server.
290 * 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.
292 void cleanAllPyScripts();
294 //! Return number of CPU cores in the calculation node.
295 long getNumberOfCPUCores();
297 //! Return a load of each CPU core.
298 vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
300 //! Set custom script to calculate a load of each CPU core.
302 \param script Python script to execute
304 void setPyScriptForCPULoad(in string script);
306 //! Nullify custom script to calculate each CPU core's load.
307 void resetScriptForCPULoad();
309 //! Get total physical memory of calculation node, in megabytes.
310 long getTotalPhysicalMemory();
312 //! Get used physical memory of calculation node, in megabytes.
313 long getTotalPhysicalMemoryInUse();
315 //! Obtain physical memory, used by the current process, in megabytes.
316 long getTotalPhysicalMemoryInUseByMe();
319 /*! \brief Interface of the %component.
320 This interface is used for interaction between the %container and the
321 %component and between the components inside the container.
323 interface EngineComponent
325 //! The name of the instance of the %Component
326 readonly attribute string instanceName ;
328 //! The name of the interface of the %Component
329 readonly attribute string interfaceName ;
331 //! Determines whether the server has already been loaded or not.
334 boolean isSSLMode() raises(SALOME::SALOME_Exception);
335 //! Remove component instance from container
337 Deactivates the %Component.
338 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
339 use remove_impl from Container instead !
343 //! Returns the container that the %Component refers to.
344 Container GetContainerRef() ;
346 //! Set component instance properties
348 Gives a sequence of (key=string,value=any) to the component.
349 Base class component stores the sequence in a map.
350 The map is cleared before.
351 This map is for use by derived classes.
353 void setProperties(in FieldsDict dico);
355 //! Get component instance properties
357 returns a previously stored map (key=string,value=any) as a sequence.
358 See setProperties(in FieldsDict dico).
360 FieldsDict getProperties();
362 //! Set an option value
364 This method is to set an option specific to a certain EngineComponent.
366 void SetOption(in string optionName, in string value);
368 //! Return an option value
370 This method is to get value of an option specific to a certain EngineComponent.
372 string GetOption(in string optionName);
374 //! Set name of a node in a graph (for %SUPERVISOR use)
376 This method is used by the %SUPERVISOR component. It sets the names of
377 the graph and of the node.
378 \param aGraphName Name of graph
379 \param aNodeName Name of node
381 void Names( in string aGraphName , in string aNodeName ) ;
383 //! Kill the component (if you can)
385 Returns True if the %Component has been killed.
387 boolean Kill_impl() ;
389 //! Stop the component (if you can)
391 Returns True if the activity of the %Component has been stopped.
392 (It's action can't be resumed)
394 boolean Stop_impl() ;
396 //! Suspend the component
398 Returns True if the activity of the %Component has been suspended.
399 (It's action can be resumed)
401 boolean Suspend_impl() ;
403 //! Resume the component
405 Returns True if the activity of the %Component has been resumed.
407 boolean Resume_impl() ;
413 long CpuUsed_impl() ;
415 //! Get a python dump
417 Returns a python script, which is being played back reproduces
418 the data model of component
420 TMPFile DumpPython(in boolean isPublished,
421 in boolean isMultiFile,
422 out boolean isValidScript);
425 //! Returns a CORBA Ref of a input Salome_file managed by a service.
428 \param service_name service's name.
429 \param file_name name of the requested file.
431 \return CORBA Ref of the requested file.
433 \exception contains information of what if the component cannot
434 sends the file's reference.
436 Engines::Salome_file getInputFileToService(in string service_name,
437 in string Salome_file_name) raises(SALOME::SALOME_Exception);
439 //! Check service input files (transfer them if needed)
441 This method is used before the activation of the service. It calls
442 recvFiles() on all the input Salome_file files of the service.
444 Before each recvFiles(), it uses the callback method named configureSalome_file.
445 This method allows the user to configure the files managed by the Salome_file.
447 By default, there is no files managed when a Salome_file is created,
448 but the supervisor set some files managed by the Salome_file from the information contained
449 into the schema file.
451 \param service_name service's name.
453 \exception contains information about files that are not in a good state.
455 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
457 //! This method adds a input Salome_file to a service of the component.
460 \param service_name service's name.
461 \param Salome_file_name name of the Salome_file
463 \return a reference of the Salome_file
465 \exception raises an exception if there is already
466 a Salome_file with this name for the service.
468 Engines::Salome_file setInputFileToService(in string service_name,
469 in string Salome_file_name) raises(SALOME::SALOME_Exception);
471 //! Returns a CORBA Ref of a output Salome_file managed by a service.
474 \param service_name service's name.
475 \param file_name name of the requested file.
477 \return CORBA Ref of the requested file.
479 \exception contains information of what if the component cannot
480 sends the file's reference.
482 Engines::Salome_file getOutputFileToService(in string service_name,
483 in string Salome_file_name) raises(SALOME::SALOME_Exception);
485 //! Check service output files (transfer them if needed)
487 This method is used at the end of the service. It calls
488 recvFiles() on all the output Salome_file files of the service.
490 Before each recvFiles(), it uses the callback method named configureSalome_file.
491 This method allows the user to configure the files managed by the Salome_file.
493 By default, there is no files managed when a Salome_file is created,
494 but the supervisor set some files managed by the Salome_file from the information contained
495 into the schema file.
497 \param service_name service's name.
499 \exception contains information about files that are not in a good state.
501 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
503 //! This method adds an output Salome_file to a service of the component.
506 \param service_name service's name.
507 \param Salome_file_name name of the Salome_file
509 \return a reference of the Salome_file
511 \exception raises an exception if there is already
512 a Salome_file with this name for the service.
514 Engines::Salome_file setOutputFileToService(in string service_name,
515 in string Salome_file_name) raises(SALOME::SALOME_Exception);
517 //! Indicate if the component instance provides custom information about its objects.
519 Returns true if the component provides custom information about its objects, false otherwise.
520 Should be redefined in the certain component to return true in case of this
521 component provides such information.
523 boolean hasObjectInfo();
525 //! Get custom information about the given object.
527 This method is used to get the custom information about the given object.
528 Should be redefined in the certain component in case of this
529 component provides such information.
530 It is worth using this method only if hasObjectInfo() method returns true.
532 \param entry object's entry.
534 \return an information about the given object.
536 string getObjectInfo(in string entry);
538 //! Get version of the component
540 This method is supposed to be implemented in all derived classes; default implementation
541 returns "unknown" string that means that no version information about the component is available.
542 \note The version of the component is stored to the study, as a part of general persistence
543 mechanism; once stored, version information in the study cannot be changed.
545 \return string containing component's version, e.g. "1.0"
551 \brief Base interface of the %component that supports exporting data.
553 interface ImportableComponent
555 /*! \brief Get a list of supported formats */
556 SALOME::StringSeq GetImportableFormats();
557 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
560 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
561 typedef sequence<octet> fileBlock;
563 /*! \brief Interface of fileTransfer.
564 The fileTransfer and fileRef interfaces provide a file transfer service
565 between different computers.
567 interface fileTransfer : SALOME::GenericObj
569 //! Open the file transfer
571 open method returns a key (fileId) that identifies the structure
572 (ex: C FILE), associated to the original file on the server.
573 The structure is created by a container for transfer of files availables
574 on the computer which runs the container.
575 Each open gives a unique fileId, to allow concurrent reads of the same
578 long open(in string fileName);
579 //! Open the file transfer in write mode for file fileName
581 \param fileName the file to copy into with putBlock
582 \return the id to use with putBlock
584 long openW(in string fileName);
586 //! Close the file transfer
588 when the file transfer is finished, close method releases structures
589 created by open method, identified by fileId.
591 void close(in long fileId);
593 //! Get a file data block
595 Get successive blocks of octets from the original file.
596 The last block is empty, and identifies the end of file.
598 fileBlock getBlock(in long fileId);
600 //! Put a file data block
602 \param fileId identification of the file obtained by openW
603 \param block a data block to copy into the file identified by fileId
605 void putBlock(in long fileId, in fileBlock block);
609 //! A file managed by a Salome_file.
616 string source_file_name;
617 //! status ("present" or "notpresent")
620 Engines::Container container;
623 //! A sequence of Engines::file.
624 typedef sequence<Engines::file> files;
627 //! The state of a Salome_file.
631 //! hdf5 file where the file can be saved
632 string hdf5_file_name;
633 //! number of files managed
634 long number_of_files;
635 //! information if all the files are received
640 /*! \brief Interface of a Salome_file managed
641 This file is independent of a Salome module. It can managed one or more
642 real files. It's useful for parallel files. Currently Salome_file cannot manage
643 two files that have the same name but not the same path.
645 interface Salome_file : Engines::fileTransfer
647 //! Load a Salome_file from a hdf5 file.
650 \param hdf5_file name (with path) of the hdf5_file.
652 \exception contains information of errors if the loading doesn't succeed.
654 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
656 //! Save a Salome_file into a hdf5_file.
659 \param hdf5_file name (with path) of the hdf5_file.
661 \exception contains information of errors if the save doesn't succeed.
664 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
666 //! Save a Salome_file into a hdf5_file.
668 All files that are managed are saved into the hdf5_file
670 \param hdf5_file name (with path) of the hdf5_file.
672 \exception contains information of errors if the save doesn't succeed.
675 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
679 //! Add a Local file to the Salome_file.
682 \param file_name name of the file with the path.
684 \exception raised if the file is already added into the Salome_file.
686 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
688 //! Add a Distributed file to the Salome_file.
691 \param comp_file_name name of the file with the path.
693 \exception raised if the file is already added into the Salome_file.
695 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
697 //! Connect a Salome_file with another Salome_file.
699 It works only if the Salome_file managed only one file
701 \param source_Salome_file Salome_file that managed the distributed version of the file.
703 \exception raised if there is more or less than one file.
705 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
707 //! Connect the managed file file_name to a Salome_file.
710 \param file_name name of the file without the path.
711 \param source_Salome_file Salome_file that managed the distributed version of the file.
713 \exception raised if the file doesn't exist.
715 void connectDistributedFile(in string file_name,
716 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
718 //! Connect the file_name with a Distributed file_name.
721 \param file_name name of the file without the path.
722 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
724 \exception raised if the file doesn't exist.
726 void setDistributedSourceFile(in string file_name,
727 in string source_file_name) raises (SALOME::SALOME_Exception);
731 //! Get all the distributed files managed by the Salome_file and check all the local files.
734 \exception raised if some of the files are not ok.
736 void recvFiles() raises (SALOME::SALOME_Exception) ;
740 //! Remove a file of the Salome_file.
743 \param file_name name of the file.
745 \exception raised if the file doesn't exist.
747 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
749 //! Remove all the files of the Salome_file.
754 //! Get the list of the files managed by the Salome_file.
756 The list can be empty.
758 Engines::files getFilesInfos();
760 //! Get a file managed by the Salome_file.
763 \param file_name the name of the file.
765 \return CORBA file reference.
767 \exception raised if the file doesn't exist.
769 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
771 //! Return the state of the Salome_file.
772 Engines::SfState getSalome_fileState();
775 //! Set the container where files are.
778 \param container container CORBA's reference.
780 void setContainer(in Engines::Container container);
783 /*! \brief Interface of fileRef.
784 The fileTransfer and fileRef interfaces provide a file transfer service
785 between different computers.
787 A fileRef object is associated to an original file (origFileName) on a
788 machine (refMachine).
789 It is created by a container (factoryServer) on refMachine,
790 with createFileRef(in string origFileName) method.
791 The fileRef object maintains a list of (machine,filename) for copies.
792 If a copy exists on myMachine, getRef(myMachine) returns the file name
793 of the copy on myMachine, else returns empty string.
794 If there is no copy on myMachine, method getFileTransfer() from container
795 factoryServer on refMachine provides a fileTransfer object dedicated to
797 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
798 the file name of the copy on myMachine.
802 //! the original file
803 readonly attribute string origFileName;
804 //! the machine of the original file
805 readonly attribute string refMachine;
807 Container getContainer();
809 boolean addRef(in string machine,
812 string getRef(in string machine);