1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, 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;
67 interface EngineComponent ;
69 interface fileTransfer ;
70 interface Salome_file;
72 /*! \brief Interface of the %Container.
73 This interface defines the process of loading and registration
74 of new components in %SALOME application
80 /*! \brief Loads a new component class (dynamic library).
82 \param componentName like COMPONENT, (Python or C++ implementation)
83 try to make a Python import of COMPONENT,
84 then a lib open of libCOMPONENTEngine.so
85 \param reason in case of error (return false) a string explaining the error
86 \return true if load successful or already done, false otherwise
88 boolean load_component_Library(in string componentName, out string reason);
90 //! Create a new servant instance of a component.
92 Component library must be loaded.
93 \param componentName Name of the component which will be registered
94 in Registry and Name Service,
95 (instance number suffix added to the registered name)
96 \return a loaded component
98 Engines::EngineComponent create_component_instance(in string componentName);
100 //! Create a new Python servant instance of a generic service.
102 This simply loads the service in the current container by importing the
103 corresponding Python module.
104 Warning: no internal registration is done, so it is up to the caller to
105 manage the various instantiation.
106 \param serviceName Name of the service
107 \param reason in case of error (return void string) a string explaining the error
108 \return the IOR of the loaded service.
110 string create_python_service_instance(in string serviceName,
113 //! Create a new servant instance of a component with environment variables specified.
115 Component library must be loaded.
116 \param componentName Name of the component which will be registered
117 in Registry and Name Service,
118 (instance number suffix added to the registered name)
119 \param env a dict of env variables
120 \param reason in case of error (return nil) a string explaining the error
121 \return a loaded component
123 Engines::EngineComponent create_component_instance_env(in string componentName,
126 //! Find a servant instance of a component
128 \param registeredName Name of the component in Registry or Name Service,
129 without instance suffix number
130 \return the first instance found
132 EngineComponent find_component_instance(in string registeredName);
134 //! Find a servant instance of a component, or create a new one.
136 Loads the component library if needed.
137 Only applicable to multiStudy components.
138 \param nameToRegister Name of the component which will be registered
139 in Registry (or Name Service)
140 \param componentName Name of the constructed library of the %component
141 (not used any more, give empty string)
142 \return a loaded component
144 EngineComponent load_impl(in string nameToRegister,
145 in string componentName);
147 //! Remove the component servant, and deletes all related objects
149 \param component_i Component to be removed
151 void remove_impl(in EngineComponent component_i);
153 //! In case of SSL mode Returns entry to Embedded NS
154 EmbeddedNamingService get_embedded_NS_if_ssl();
156 //! Unload component libraries from the container.
157 void finalize_removal() ;
159 //! Determines whether the server has been loaded or not.
162 //! Name of the %container
163 readonly attribute string name ;
165 //! working directory of the %container
166 readonly attribute string workingdir ;
168 //! name of the %container log file (this has been set by the launcher)
169 attribute string logfilename ;
171 //! Shutdown the Container process.
174 //! Returns the hostname of the container
175 string getHostName();
177 //! Returns the PID of the container
180 //! Kill the container
182 Returns True if the %container has been killed.
183 Kept for Superv compilation but can't work, unless oneway...
186 boolean Kill_impl() ;
190 returns a fileRef object if origFileName exists and is readable
191 else returns null object. Only one fileRef is created for a given
192 file name, so, several calls with the same file name returns the
195 fileRef createFileRef(in string origFileName);
197 //! Create a Salome_file
199 returns a Salome_file object if origFileName exists and is readable
200 else returns null object.
202 \param origFileName name of the file to be managed (can contain the path).
204 \return Salome_file CORBA reference.
206 Salome_file createSalome_file(in string origFileName);
208 //! Create a fileTransfer
210 returns a fileTransfer object used to copy files from the container
211 machine to the clients machines. Only one fileTransfer instance is
212 created in a container.
214 fileTransfer getFileTransfer();
216 //! Copy a file from a remote host (container) to a local file
218 \param contai the remote container
219 \param remoteFile the file on the remote host to copy
220 \param localFile the local file to create by copy
222 void copyFile(in Container contai, in string remoteFile, in string localFile);
224 //! Create a PyNode in the container
226 \param nodeName the name of the PyNode
227 \param code python code as text to load in the node
229 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
231 //! Retrieves the last created PyNode instance with createPyNode.
232 PyNode getDefaultPyNode(in string nodeName);
234 //! Create a PyScriptNode in the container
236 \param nodeName the name of the PyScriptNode
237 \param code python code as text to load in the node
239 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
241 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
243 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
244 PyScriptNode getDefaultPyScriptNode(in string nodeName);
246 //! This method remove all refs of PyScriptNode servant objects stored in server.
248 * 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.
250 void cleanAllPyScripts();
252 //! Return number of CPU cores in the calculation node.
253 long getNumberOfCPUCores();
255 //! Return a load of each CPU core.
256 vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
258 //! Set custom script to calculate a load of each CPU core.
260 \param script Python script to execute
262 void setPyScriptForCPULoad(in string script);
264 //! Nullify custom script to calculate each CPU core's load.
265 void resetScriptForCPULoad();
267 //! Get total physical memory of calculation node, in megabytes.
268 long getTotalPhysicalMemory();
270 //! Get used physical memory of calculation node, in megabytes.
271 long getTotalPhysicalMemoryInUse();
273 //! Obtain physical memory, used by the current process, in megabytes.
274 long getTotalPhysicalMemoryInUseByMe();
277 /*! \brief Interface of the %component.
278 This interface is used for interaction between the %container and the
279 %component and between the components inside the container.
281 interface EngineComponent
283 //! The name of the instance of the %Component
284 readonly attribute string instanceName ;
286 //! The name of the interface of the %Component
287 readonly attribute string interfaceName ;
289 //! Determines whether the server has already been loaded or not.
292 boolean isSSLMode() raises(SALOME::SALOME_Exception);
293 //! Remove component instance from container
295 Deactivates the %Component.
296 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
297 use remove_impl from Container instead !
301 //! Returns the container that the %Component refers to.
302 Container GetContainerRef() ;
304 //! Set component instance properties
306 Gives a sequence of (key=string,value=any) to the component.
307 Base class component stores the sequence in a map.
308 The map is cleared before.
309 This map is for use by derived classes.
311 void setProperties(in FieldsDict dico);
313 //! Get component instance properties
315 returns a previously stored map (key=string,value=any) as a sequence.
316 See setProperties(in FieldsDict dico).
318 FieldsDict getProperties();
320 //! Set an option value
322 This method is to set an option specific to a certain EngineComponent.
324 void SetOption(in string optionName, in string value);
326 //! Return an option value
328 This method is to get value of an option specific to a certain EngineComponent.
330 string GetOption(in string optionName);
332 //! Set name of a node in a graph (for %SUPERVISOR use)
334 This method is used by the %SUPERVISOR component. It sets the names of
335 the graph and of the node.
336 \param aGraphName Name of graph
337 \param aNodeName Name of node
339 void Names( in string aGraphName , in string aNodeName ) ;
341 //! Kill the component (if you can)
343 Returns True if the %Component has been killed.
345 boolean Kill_impl() ;
347 //! Stop the component (if you can)
349 Returns True if the activity of the %Component has been stopped.
350 (It's action can't be resumed)
352 boolean Stop_impl() ;
354 //! Suspend the component
356 Returns True if the activity of the %Component has been suspended.
357 (It's action can be resumed)
359 boolean Suspend_impl() ;
361 //! Resume the component
363 Returns True if the activity of the %Component has been resumed.
365 boolean Resume_impl() ;
371 long CpuUsed_impl() ;
373 //! Get a python dump
375 Returns a python script, which is being played back reproduces
376 the data model of component
378 TMPFile DumpPython(in boolean isPublished,
379 in boolean isMultiFile,
380 out boolean isValidScript);
383 //! Returns a CORBA Ref of a input Salome_file managed by a service.
386 \param service_name service's name.
387 \param file_name name of the requested file.
389 \return CORBA Ref of the requested file.
391 \exception contains information of what if the component cannot
392 sends the file's reference.
394 Engines::Salome_file getInputFileToService(in string service_name,
395 in string Salome_file_name) raises(SALOME::SALOME_Exception);
397 //! Check service input files (transfer them if needed)
399 This method is used before the activation of the service. It calls
400 recvFiles() on all the input Salome_file files of the service.
402 Before each recvFiles(), it uses the callback method named configureSalome_file.
403 This method allows the user to configure the files managed by the Salome_file.
405 By default, there is no files managed when a Salome_file is created,
406 but the supervisor set some files managed by the Salome_file from the information contained
407 into the schema file.
409 \param service_name service's name.
411 \exception contains information about files that are not in a good state.
413 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
415 //! This method adds a input Salome_file to a service of the component.
418 \param service_name service's name.
419 \param Salome_file_name name of the Salome_file
421 \return a reference of the Salome_file
423 \exception raises an exception if there is already
424 a Salome_file with this name for the service.
426 Engines::Salome_file setInputFileToService(in string service_name,
427 in string Salome_file_name) raises(SALOME::SALOME_Exception);
429 //! Returns a CORBA Ref of a output Salome_file managed by a service.
432 \param service_name service's name.
433 \param file_name name of the requested file.
435 \return CORBA Ref of the requested file.
437 \exception contains information of what if the component cannot
438 sends the file's reference.
440 Engines::Salome_file getOutputFileToService(in string service_name,
441 in string Salome_file_name) raises(SALOME::SALOME_Exception);
443 //! Check service output files (transfer them if needed)
445 This method is used at the end of the service. It calls
446 recvFiles() on all the output Salome_file files of the service.
448 Before each recvFiles(), it uses the callback method named configureSalome_file.
449 This method allows the user to configure the files managed by the Salome_file.
451 By default, there is no files managed when a Salome_file is created,
452 but the supervisor set some files managed by the Salome_file from the information contained
453 into the schema file.
455 \param service_name service's name.
457 \exception contains information about files that are not in a good state.
459 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
461 //! This method adds an output Salome_file to a service of the component.
464 \param service_name service's name.
465 \param Salome_file_name name of the Salome_file
467 \return a reference of the Salome_file
469 \exception raises an exception if there is already
470 a Salome_file with this name for the service.
472 Engines::Salome_file setOutputFileToService(in string service_name,
473 in string Salome_file_name) raises(SALOME::SALOME_Exception);
475 //! Indicate if the component instance provides custom information about its objects.
477 Returns true if the component provides custom information about its objects, false otherwise.
478 Should be redefined in the certain component to return true in case of this
479 component provides such information.
481 boolean hasObjectInfo();
483 //! Get custom information about the given object.
485 This method is used to get the custom information about the given object.
486 Should be redefined in the certain component in case of this
487 component provides such information.
488 It is worth using this method only if hasObjectInfo() method returns true.
490 \param entry object's entry.
492 \return an information about the given object.
494 string getObjectInfo(in string entry);
496 //! Get version of the component
498 This method is supposed to be implemented in all derived classes; default implementation
499 returns "unknown" string that means that no version information about the component is available.
500 \note The version of the component is stored to the study, as a part of general persistence
501 mechanism; once stored, version information in the study cannot be changed.
503 \return string containing component's version, e.g. "1.0"
509 \brief Base interface of the %component that supports exporting data.
511 interface ImportableComponent
513 /*! \brief Get a list of supported formats */
514 SALOME::StringSeq GetImportableFormats();
515 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
518 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
519 typedef sequence<octet> fileBlock;
521 /*! \brief Interface of fileTransfer.
522 The fileTransfer and fileRef interfaces provide a file transfer service
523 between different computers.
525 interface fileTransfer : SALOME::GenericObj
527 //! Open the file transfer
529 open method returns a key (fileId) that identifies the structure
530 (ex: C FILE), associated to the original file on the server.
531 The structure is created by a container for transfer of files availables
532 on the computer which runs the container.
533 Each open gives a unique fileId, to allow concurrent reads of the same
536 long open(in string fileName);
537 //! Open the file transfer in write mode for file fileName
539 \param fileName the file to copy into with putBlock
540 \return the id to use with putBlock
542 long openW(in string fileName);
544 //! Close the file transfer
546 when the file transfer is finished, close method releases structures
547 created by open method, identified by fileId.
549 void close(in long fileId);
551 //! Get a file data block
553 Get successive blocks of octets from the original file.
554 The last block is empty, and identifies the end of file.
556 fileBlock getBlock(in long fileId);
558 //! Put a file data block
560 \param fileId identification of the file obtained by openW
561 \param block a data block to copy into the file identified by fileId
563 void putBlock(in long fileId, in fileBlock block);
567 //! A file managed by a Salome_file.
574 string source_file_name;
575 //! status ("present" or "notpresent")
578 Engines::Container container;
581 //! A sequence of Engines::file.
582 typedef sequence<Engines::file> files;
585 //! The state of a Salome_file.
589 //! hdf5 file where the file can be saved
590 string hdf5_file_name;
591 //! number of files managed
592 long number_of_files;
593 //! information if all the files are received
598 /*! \brief Interface of a Salome_file managed
599 This file is independent of a Salome module. It can managed one or more
600 real files. It's useful for parallel files. Currently Salome_file cannot manage
601 two files that have the same name but not the same path.
603 interface Salome_file : Engines::fileTransfer
605 //! Load a Salome_file from a hdf5 file.
608 \param hdf5_file name (with path) of the hdf5_file.
610 \exception contains information of errors if the loading doesn't succeed.
612 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
614 //! Save a Salome_file into a hdf5_file.
617 \param hdf5_file name (with path) of the hdf5_file.
619 \exception contains information of errors if the save doesn't succeed.
622 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
624 //! Save a Salome_file into a hdf5_file.
626 All files that are managed are saved into the 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_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
637 //! Add a Local file to the Salome_file.
640 \param file_name name of the file with the path.
642 \exception raised if the file is already added into the Salome_file.
644 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
646 //! Add a Distributed file to the Salome_file.
649 \param comp_file_name name of the file with the path.
651 \exception raised if the file is already added into the Salome_file.
653 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
655 //! Connect a Salome_file with another Salome_file.
657 It works only if the Salome_file managed only one file
659 \param source_Salome_file Salome_file that managed the distributed version of the file.
661 \exception raised if there is more or less than one file.
663 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
665 //! Connect the managed file file_name to a Salome_file.
668 \param file_name name of the file without the path.
669 \param source_Salome_file Salome_file that managed the distributed version of the file.
671 \exception raised if the file doesn't exist.
673 void connectDistributedFile(in string file_name,
674 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
676 //! Connect the file_name with a Distributed file_name.
679 \param file_name name of the file without the path.
680 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
682 \exception raised if the file doesn't exist.
684 void setDistributedSourceFile(in string file_name,
685 in string source_file_name) raises (SALOME::SALOME_Exception);
689 //! Get all the distributed files managed by the Salome_file and check all the local files.
692 \exception raised if some of the files are not ok.
694 void recvFiles() raises (SALOME::SALOME_Exception) ;
698 //! Remove a file of the Salome_file.
701 \param file_name name of the file.
703 \exception raised if the file doesn't exist.
705 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
707 //! Remove all the files of the Salome_file.
712 //! Get the list of the files managed by the Salome_file.
714 The list can be empty.
716 Engines::files getFilesInfos();
718 //! Get a file managed by the Salome_file.
721 \param file_name the name of the file.
723 \return CORBA file reference.
725 \exception raised if the file doesn't exist.
727 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
729 //! Return the state of the Salome_file.
730 Engines::SfState getSalome_fileState();
733 //! Set the container where files are.
736 \param container container CORBA's reference.
738 void setContainer(in Engines::Container container);
741 /*! \brief Interface of fileRef.
742 The fileTransfer and fileRef interfaces provide a file transfer service
743 between different computers.
745 A fileRef object is associated to an original file (origFileName) on a
746 machine (refMachine).
747 It is created by a container (factoryServer) on refMachine,
748 with createFileRef(in string origFileName) method.
749 The fileRef object maintains a list of (machine,filename) for copies.
750 If a copy exists on myMachine, getRef(myMachine) returns the file name
751 of the copy on myMachine, else returns empty string.
752 If there is no copy on myMachine, method getFileTransfer() from container
753 factoryServer on refMachine provides a fileTransfer object dedicated to
755 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
756 the file name of the copy on myMachine.
760 //! the original file
761 readonly attribute string origFileName;
762 //! the machine of the original file
763 readonly attribute string refMachine;
765 Container getContainer();
767 boolean addRef(in string machine,
770 string getRef(in string machine);