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 /*! \brief Loads a new component class (dynamic library).
89 \param componentName like COMPONENT, (Python or C++ implementation)
90 try to make a Python import of COMPONENT,
91 then a lib open of libCOMPONENTEngine.so
92 \param reason in case of error (return false) a string explaining the error
93 \return true if load successful or already done, false otherwise
95 boolean load_component_Library(in string componentName, out string reason);
97 //! Create a new servant instance of a component.
99 Component library must be loaded.
100 \param componentName Name of the component which will be registered
101 in Registry and Name Service,
102 (instance number suffix added to the registered name)
103 \return a loaded component
105 Engines::EngineComponent create_component_instance(in string componentName);
107 //! Create a new Python servant instance of a generic service.
109 This simply loads the service in the current container by importing the
110 corresponding Python module.
111 Warning: no internal registration is done, so it is up to the caller to
112 manage the various instantiation.
113 \param serviceName Name of the service
114 \param reason in case of error (return void string) a string explaining the error
115 \return the IOR of the loaded service.
117 string create_python_service_instance(in string serviceName,
120 //! Create a new servant instance of a component with environment variables specified.
122 Component library must be loaded.
123 \param componentName Name of the component which will be registered
124 in Registry and Name Service,
125 (instance number suffix added to the registered name)
126 \param env a dict of env variables
127 \param reason in case of error (return nil) a string explaining the error
128 \return a loaded component
130 Engines::EngineComponent create_component_instance_env(in string componentName,
133 //! Find a servant instance of a component
135 \param registeredName Name of the component in Registry or Name Service,
136 without instance suffix number
137 \return the first instance found
139 EngineComponent find_component_instance(in string registeredName);
141 //! Find a servant instance of a component, or create a new one.
143 Loads the component library if needed.
144 Only applicable to multiStudy components.
145 \param nameToRegister Name of the component which will be registered
146 in Registry (or Name Service)
147 \param componentName Name of the constructed library of the %component
148 (not used any more, give empty string)
149 \return a loaded component
151 EngineComponent load_impl(in string nameToRegister,
152 in string componentName);
154 //! Remove the component servant, and deletes all related objects
156 \param component_i Component to be removed
158 void remove_impl(in EngineComponent component_i);
160 //! In case of SSL mode Returns entry to Embedded NS
161 EmbeddedNamingService get_embedded_NS_if_ssl();
163 boolean is_SSL_mode();
165 //! Unload component libraries from the container.
166 void finalize_removal() ;
168 //! Determines whether the server has been loaded or not.
171 //! Name of the %container
172 readonly attribute string name ;
174 //! working directory of the %container
175 readonly attribute string workingdir ;
177 //! name of the %container log file (this has been set by the launcher)
178 attribute string logfilename ;
180 //! Shutdown the Container process.
183 //! Returns the hostname of the container
184 string getHostName();
186 //! Returns the PID of the container
189 //! Kill the container
191 Returns True if the %container has been killed.
192 Kept for Superv compilation but can't work, unless oneway...
195 boolean Kill_impl() ;
199 returns a fileRef object if origFileName exists and is readable
200 else returns null object. Only one fileRef is created for a given
201 file name, so, several calls with the same file name returns the
204 fileRef createFileRef(in string origFileName);
206 //! Create a Salome_file
208 returns a Salome_file object if origFileName exists and is readable
209 else returns null object.
211 \param origFileName name of the file to be managed (can contain the path).
213 \return Salome_file CORBA reference.
215 Salome_file createSalome_file(in string origFileName);
217 //! Create a fileTransfer
219 returns a fileTransfer object used to copy files from the container
220 machine to the clients machines. Only one fileTransfer instance is
221 created in a container.
223 fileTransfer getFileTransfer();
225 //! Copy a file from a remote host (container) to a local file
227 \param contai the remote container
228 \param remoteFile the file on the remote host to copy
229 \param localFile the local file to create by copy
231 void copyFile(in Container contai, in string remoteFile, in string localFile);
233 //! Create a PyNode in the container
235 \param nodeName the name of the PyNode
236 \param code python code as text to load in the node
238 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
240 //! Retrieves the last created PyNode instance with createPyNode.
241 PyNode getDefaultPyNode(in string nodeName);
243 //! Create a PyScriptNode in the container
245 \param nodeName the name of the PyScriptNode
246 \param code python code as text to load in the node
248 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
250 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
252 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
253 PyScriptNode getDefaultPyScriptNode(in string nodeName);
255 //! This method remove all refs of PyScriptNode servant objects stored in server.
257 * 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.
259 void cleanAllPyScripts();
261 //! Return number of CPU cores in the calculation node.
262 long getNumberOfCPUCores();
264 //! Return a load of each CPU core.
265 vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
267 //! Set custom script to calculate a load of each CPU core.
269 \param script Python script to execute
271 void setPyScriptForCPULoad(in string script);
273 //! Nullify custom script to calculate each CPU core's load.
274 void resetScriptForCPULoad();
276 //! Get total physical memory of calculation node, in megabytes.
277 long getTotalPhysicalMemory();
279 //! Get used physical memory of calculation node, in megabytes.
280 long getTotalPhysicalMemoryInUse();
282 //! Obtain physical memory, used by the current process, in megabytes.
283 long getTotalPhysicalMemoryInUseByMe();
286 /*! \brief Interface of the %component.
287 This interface is used for interaction between the %container and the
288 %component and between the components inside the container.
290 interface EngineComponent
292 //! The name of the instance of the %Component
293 readonly attribute string instanceName ;
295 //! The name of the interface of the %Component
296 readonly attribute string interfaceName ;
298 //! Determines whether the server has already been loaded or not.
301 boolean isSSLMode() raises(SALOME::SALOME_Exception);
302 //! Remove component instance from container
304 Deactivates the %Component.
305 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
306 use remove_impl from Container instead !
310 //! Returns the container that the %Component refers to.
311 Container GetContainerRef() ;
313 //! Set component instance properties
315 Gives a sequence of (key=string,value=any) to the component.
316 Base class component stores the sequence in a map.
317 The map is cleared before.
318 This map is for use by derived classes.
320 void setProperties(in FieldsDict dico);
322 //! Get component instance properties
324 returns a previously stored map (key=string,value=any) as a sequence.
325 See setProperties(in FieldsDict dico).
327 FieldsDict getProperties();
329 //! Set an option value
331 This method is to set an option specific to a certain EngineComponent.
333 void SetOption(in string optionName, in string value);
335 //! Return an option value
337 This method is to get value of an option specific to a certain EngineComponent.
339 string GetOption(in string optionName);
341 //! Set name of a node in a graph (for %SUPERVISOR use)
343 This method is used by the %SUPERVISOR component. It sets the names of
344 the graph and of the node.
345 \param aGraphName Name of graph
346 \param aNodeName Name of node
348 void Names( in string aGraphName , in string aNodeName ) ;
350 //! Kill the component (if you can)
352 Returns True if the %Component has been killed.
354 boolean Kill_impl() ;
356 //! Stop the component (if you can)
358 Returns True if the activity of the %Component has been stopped.
359 (It's action can't be resumed)
361 boolean Stop_impl() ;
363 //! Suspend the component
365 Returns True if the activity of the %Component has been suspended.
366 (It's action can be resumed)
368 boolean Suspend_impl() ;
370 //! Resume the component
372 Returns True if the activity of the %Component has been resumed.
374 boolean Resume_impl() ;
380 long CpuUsed_impl() ;
382 //! Get a python dump
384 Returns a python script, which is being played back reproduces
385 the data model of component
387 TMPFile DumpPython(in boolean isPublished,
388 in boolean isMultiFile,
389 out boolean isValidScript);
392 //! Returns a CORBA Ref of a input Salome_file managed by a service.
395 \param service_name service's name.
396 \param file_name name of the requested file.
398 \return CORBA Ref of the requested file.
400 \exception contains information of what if the component cannot
401 sends the file's reference.
403 Engines::Salome_file getInputFileToService(in string service_name,
404 in string Salome_file_name) raises(SALOME::SALOME_Exception);
406 //! Check service input files (transfer them if needed)
408 This method is used before the activation of the service. It calls
409 recvFiles() on all the input Salome_file files of the service.
411 Before each recvFiles(), it uses the callback method named configureSalome_file.
412 This method allows the user to configure the files managed by the Salome_file.
414 By default, there is no files managed when a Salome_file is created,
415 but the supervisor set some files managed by the Salome_file from the information contained
416 into the schema file.
418 \param service_name service's name.
420 \exception contains information about files that are not in a good state.
422 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
424 //! This method adds a input Salome_file to a service of the component.
427 \param service_name service's name.
428 \param Salome_file_name name of the Salome_file
430 \return a reference of the Salome_file
432 \exception raises an exception if there is already
433 a Salome_file with this name for the service.
435 Engines::Salome_file setInputFileToService(in string service_name,
436 in string Salome_file_name) raises(SALOME::SALOME_Exception);
438 //! Returns a CORBA Ref of a output Salome_file managed by a service.
441 \param service_name service's name.
442 \param file_name name of the requested file.
444 \return CORBA Ref of the requested file.
446 \exception contains information of what if the component cannot
447 sends the file's reference.
449 Engines::Salome_file getOutputFileToService(in string service_name,
450 in string Salome_file_name) raises(SALOME::SALOME_Exception);
452 //! Check service output files (transfer them if needed)
454 This method is used at the end of the service. It calls
455 recvFiles() on all the output Salome_file files of the service.
457 Before each recvFiles(), it uses the callback method named configureSalome_file.
458 This method allows the user to configure the files managed by the Salome_file.
460 By default, there is no files managed when a Salome_file is created,
461 but the supervisor set some files managed by the Salome_file from the information contained
462 into the schema file.
464 \param service_name service's name.
466 \exception contains information about files that are not in a good state.
468 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
470 //! This method adds an output Salome_file to a service of the component.
473 \param service_name service's name.
474 \param Salome_file_name name of the Salome_file
476 \return a reference of the Salome_file
478 \exception raises an exception if there is already
479 a Salome_file with this name for the service.
481 Engines::Salome_file setOutputFileToService(in string service_name,
482 in string Salome_file_name) raises(SALOME::SALOME_Exception);
484 //! Indicate if the component instance provides custom information about its objects.
486 Returns true if the component provides custom information about its objects, false otherwise.
487 Should be redefined in the certain component to return true in case of this
488 component provides such information.
490 boolean hasObjectInfo();
492 //! Get custom information about the given object.
494 This method is used to get the custom information about the given object.
495 Should be redefined in the certain component in case of this
496 component provides such information.
497 It is worth using this method only if hasObjectInfo() method returns true.
499 \param entry object's entry.
501 \return an information about the given object.
503 string getObjectInfo(in string entry);
505 //! Get version of the component
507 This method is supposed to be implemented in all derived classes; default implementation
508 returns "unknown" string that means that no version information about the component is available.
509 \note The version of the component is stored to the study, as a part of general persistence
510 mechanism; once stored, version information in the study cannot be changed.
512 \return string containing component's version, e.g. "1.0"
518 \brief Base interface of the %component that supports exporting data.
520 interface ImportableComponent
522 /*! \brief Get a list of supported formats */
523 SALOME::StringSeq GetImportableFormats();
524 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
527 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
528 typedef sequence<octet> fileBlock;
530 /*! \brief Interface of fileTransfer.
531 The fileTransfer and fileRef interfaces provide a file transfer service
532 between different computers.
534 interface fileTransfer : SALOME::GenericObj
536 //! Open the file transfer
538 open method returns a key (fileId) that identifies the structure
539 (ex: C FILE), associated to the original file on the server.
540 The structure is created by a container for transfer of files availables
541 on the computer which runs the container.
542 Each open gives a unique fileId, to allow concurrent reads of the same
545 long open(in string fileName);
546 //! Open the file transfer in write mode for file fileName
548 \param fileName the file to copy into with putBlock
549 \return the id to use with putBlock
551 long openW(in string fileName);
553 //! Close the file transfer
555 when the file transfer is finished, close method releases structures
556 created by open method, identified by fileId.
558 void close(in long fileId);
560 //! Get a file data block
562 Get successive blocks of octets from the original file.
563 The last block is empty, and identifies the end of file.
565 fileBlock getBlock(in long fileId);
567 //! Put a file data block
569 \param fileId identification of the file obtained by openW
570 \param block a data block to copy into the file identified by fileId
572 void putBlock(in long fileId, in fileBlock block);
576 //! A file managed by a Salome_file.
583 string source_file_name;
584 //! status ("present" or "notpresent")
587 Engines::Container container;
590 //! A sequence of Engines::file.
591 typedef sequence<Engines::file> files;
594 //! The state of a Salome_file.
598 //! hdf5 file where the file can be saved
599 string hdf5_file_name;
600 //! number of files managed
601 long number_of_files;
602 //! information if all the files are received
607 /*! \brief Interface of a Salome_file managed
608 This file is independent of a Salome module. It can managed one or more
609 real files. It's useful for parallel files. Currently Salome_file cannot manage
610 two files that have the same name but not the same path.
612 interface Salome_file : Engines::fileTransfer
614 //! Load a Salome_file from a hdf5 file.
617 \param hdf5_file name (with path) of the hdf5_file.
619 \exception contains information of errors if the loading doesn't succeed.
621 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
623 //! Save a Salome_file into a hdf5_file.
626 \param hdf5_file name (with path) of the hdf5_file.
628 \exception contains information of errors if the save doesn't succeed.
631 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
633 //! Save a Salome_file into a hdf5_file.
635 All files that are managed are saved into the hdf5_file
637 \param hdf5_file name (with path) of the hdf5_file.
639 \exception contains information of errors if the save doesn't succeed.
642 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
646 //! Add a Local file to the Salome_file.
649 \param file_name name of the file with the path.
651 \exception raised if the file is already added into the Salome_file.
653 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
655 //! Add a Distributed file to the Salome_file.
658 \param comp_file_name name of the file with the path.
660 \exception raised if the file is already added into the Salome_file.
662 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
664 //! Connect a Salome_file with another Salome_file.
666 It works only if the Salome_file managed only one file
668 \param source_Salome_file Salome_file that managed the distributed version of the file.
670 \exception raised if there is more or less than one file.
672 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
674 //! Connect the managed file file_name to a Salome_file.
677 \param file_name name of the file without the path.
678 \param source_Salome_file Salome_file that managed the distributed version of the file.
680 \exception raised if the file doesn't exist.
682 void connectDistributedFile(in string file_name,
683 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
685 //! Connect the file_name with a Distributed file_name.
688 \param file_name name of the file without the path.
689 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
691 \exception raised if the file doesn't exist.
693 void setDistributedSourceFile(in string file_name,
694 in string source_file_name) raises (SALOME::SALOME_Exception);
698 //! Get all the distributed files managed by the Salome_file and check all the local files.
701 \exception raised if some of the files are not ok.
703 void recvFiles() raises (SALOME::SALOME_Exception) ;
707 //! Remove a file of the Salome_file.
710 \param file_name name of the file.
712 \exception raised if the file doesn't exist.
714 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
716 //! Remove all the files of the Salome_file.
721 //! Get the list of the files managed by the Salome_file.
723 The list can be empty.
725 Engines::files getFilesInfos();
727 //! Get a file managed by the Salome_file.
730 \param file_name the name of the file.
732 \return CORBA file reference.
734 \exception raised if the file doesn't exist.
736 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
738 //! Return the state of the Salome_file.
739 Engines::SfState getSalome_fileState();
742 //! Set the container where files are.
745 \param container container CORBA's reference.
747 void setContainer(in Engines::Container container);
750 /*! \brief Interface of fileRef.
751 The fileTransfer and fileRef interfaces provide a file transfer service
752 between different computers.
754 A fileRef object is associated to an original file (origFileName) on a
755 machine (refMachine).
756 It is created by a container (factoryServer) on refMachine,
757 with createFileRef(in string origFileName) method.
758 The fileRef object maintains a list of (machine,filename) for copies.
759 If a copy exists on myMachine, getRef(myMachine) returns the file name
760 of the copy on myMachine, else returns empty string.
761 If there is no copy on myMachine, method getFileTransfer() from container
762 factoryServer on refMachine provides a fileTransfer object dedicated to
764 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
765 the file name of the copy on myMachine.
769 //! the original file
770 readonly attribute string origFileName;
771 //! the machine of the original file
772 readonly attribute string refMachine;
774 Container getContainer();
776 boolean addRef(in string machine,
779 string getRef(in string machine);