1 // Copyright (C) 2007-2022 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 boolean is_SSL_mode();
158 //! Unload component libraries from the container.
159 void finalize_removal() ;
161 //! Determines whether the server has been loaded or not.
164 //! Name of the %container
165 readonly attribute string name ;
167 //! working directory of the %container
168 readonly attribute string workingdir ;
170 //! name of the %container log file (this has been set by the launcher)
171 attribute string logfilename ;
173 //! Shutdown the Container process.
176 //! Returns the hostname of the container
177 string getHostName();
179 //! Returns the PID of the container
182 //! Kill the container
184 Returns True if the %container has been killed.
185 Kept for Superv compilation but can't work, unless oneway...
188 boolean Kill_impl() ;
192 returns a fileRef object if origFileName exists and is readable
193 else returns null object. Only one fileRef is created for a given
194 file name, so, several calls with the same file name returns the
197 fileRef createFileRef(in string origFileName);
199 //! Create a Salome_file
201 returns a Salome_file object if origFileName exists and is readable
202 else returns null object.
204 \param origFileName name of the file to be managed (can contain the path).
206 \return Salome_file CORBA reference.
208 Salome_file createSalome_file(in string origFileName);
210 //! Create a fileTransfer
212 returns a fileTransfer object used to copy files from the container
213 machine to the clients machines. Only one fileTransfer instance is
214 created in a container.
216 fileTransfer getFileTransfer();
218 //! Copy a file from a remote host (container) to a local file
220 \param contai the remote container
221 \param remoteFile the file on the remote host to copy
222 \param localFile the local file to create by copy
224 void copyFile(in Container contai, in string remoteFile, in string localFile);
226 //! Create a PyNode in the container
228 \param nodeName the name of the PyNode
229 \param code python code as text to load in the node
231 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
233 //! Retrieves the last created PyNode instance with createPyNode.
234 PyNode getDefaultPyNode(in string nodeName);
236 //! Create a PyScriptNode in the container
238 \param nodeName the name of the PyScriptNode
239 \param code python code as text to load in the node
241 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
243 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
245 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
246 PyScriptNode getDefaultPyScriptNode(in string nodeName);
248 //! This method remove all refs of PyScriptNode servant objects stored in server.
250 * 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.
252 void cleanAllPyScripts();
254 //! Return number of CPU cores in the calculation node.
255 long getNumberOfCPUCores();
257 //! Return a load of each CPU core.
258 vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
260 //! Set custom script to calculate a load of each CPU core.
262 \param script Python script to execute
264 void setPyScriptForCPULoad(in string script);
266 //! Nullify custom script to calculate each CPU core's load.
267 void resetScriptForCPULoad();
269 //! Get total physical memory of calculation node, in megabytes.
270 long getTotalPhysicalMemory();
272 //! Get used physical memory of calculation node, in megabytes.
273 long getTotalPhysicalMemoryInUse();
275 //! Obtain physical memory, used by the current process, in megabytes.
276 long getTotalPhysicalMemoryInUseByMe();
279 /*! \brief Interface of the %component.
280 This interface is used for interaction between the %container and the
281 %component and between the components inside the container.
283 interface EngineComponent
285 //! The name of the instance of the %Component
286 readonly attribute string instanceName ;
288 //! The name of the interface of the %Component
289 readonly attribute string interfaceName ;
291 //! Determines whether the server has already been loaded or not.
294 boolean isSSLMode() raises(SALOME::SALOME_Exception);
295 //! Remove component instance from container
297 Deactivates the %Component.
298 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
299 use remove_impl from Container instead !
303 //! Returns the container that the %Component refers to.
304 Container GetContainerRef() ;
306 //! Set component instance properties
308 Gives a sequence of (key=string,value=any) to the component.
309 Base class component stores the sequence in a map.
310 The map is cleared before.
311 This map is for use by derived classes.
313 void setProperties(in FieldsDict dico);
315 //! Get component instance properties
317 returns a previously stored map (key=string,value=any) as a sequence.
318 See setProperties(in FieldsDict dico).
320 FieldsDict getProperties();
322 //! Set an option value
324 This method is to set an option specific to a certain EngineComponent.
326 void SetOption(in string optionName, in string value);
328 //! Return an option value
330 This method is to get value of an option specific to a certain EngineComponent.
332 string GetOption(in string optionName);
334 //! Set name of a node in a graph (for %SUPERVISOR use)
336 This method is used by the %SUPERVISOR component. It sets the names of
337 the graph and of the node.
338 \param aGraphName Name of graph
339 \param aNodeName Name of node
341 void Names( in string aGraphName , in string aNodeName ) ;
343 //! Kill the component (if you can)
345 Returns True if the %Component has been killed.
347 boolean Kill_impl() ;
349 //! Stop the component (if you can)
351 Returns True if the activity of the %Component has been stopped.
352 (It's action can't be resumed)
354 boolean Stop_impl() ;
356 //! Suspend the component
358 Returns True if the activity of the %Component has been suspended.
359 (It's action can be resumed)
361 boolean Suspend_impl() ;
363 //! Resume the component
365 Returns True if the activity of the %Component has been resumed.
367 boolean Resume_impl() ;
373 long CpuUsed_impl() ;
375 //! Get a python dump
377 Returns a python script, which is being played back reproduces
378 the data model of component
380 TMPFile DumpPython(in boolean isPublished,
381 in boolean isMultiFile,
382 out boolean isValidScript);
385 //! Returns a CORBA Ref of a input Salome_file managed by a service.
388 \param service_name service's name.
389 \param file_name name of the requested file.
391 \return CORBA Ref of the requested file.
393 \exception contains information of what if the component cannot
394 sends the file's reference.
396 Engines::Salome_file getInputFileToService(in string service_name,
397 in string Salome_file_name) raises(SALOME::SALOME_Exception);
399 //! Check service input files (transfer them if needed)
401 This method is used before the activation of the service. It calls
402 recvFiles() on all the input Salome_file files of the service.
404 Before each recvFiles(), it uses the callback method named configureSalome_file.
405 This method allows the user to configure the files managed by the Salome_file.
407 By default, there is no files managed when a Salome_file is created,
408 but the supervisor set some files managed by the Salome_file from the information contained
409 into the schema file.
411 \param service_name service's name.
413 \exception contains information about files that are not in a good state.
415 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
417 //! This method adds a input Salome_file to a service of the component.
420 \param service_name service's name.
421 \param Salome_file_name name of the Salome_file
423 \return a reference of the Salome_file
425 \exception raises an exception if there is already
426 a Salome_file with this name for the service.
428 Engines::Salome_file setInputFileToService(in string service_name,
429 in string Salome_file_name) raises(SALOME::SALOME_Exception);
431 //! Returns a CORBA Ref of a output Salome_file managed by a service.
434 \param service_name service's name.
435 \param file_name name of the requested file.
437 \return CORBA Ref of the requested file.
439 \exception contains information of what if the component cannot
440 sends the file's reference.
442 Engines::Salome_file getOutputFileToService(in string service_name,
443 in string Salome_file_name) raises(SALOME::SALOME_Exception);
445 //! Check service output files (transfer them if needed)
447 This method is used at the end of the service. It calls
448 recvFiles() on all the output Salome_file files of the service.
450 Before each recvFiles(), it uses the callback method named configureSalome_file.
451 This method allows the user to configure the files managed by the Salome_file.
453 By default, there is no files managed when a Salome_file is created,
454 but the supervisor set some files managed by the Salome_file from the information contained
455 into the schema file.
457 \param service_name service's name.
459 \exception contains information about files that are not in a good state.
461 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
463 //! This method adds an output Salome_file to a service of the component.
466 \param service_name service's name.
467 \param Salome_file_name name of the Salome_file
469 \return a reference of the Salome_file
471 \exception raises an exception if there is already
472 a Salome_file with this name for the service.
474 Engines::Salome_file setOutputFileToService(in string service_name,
475 in string Salome_file_name) raises(SALOME::SALOME_Exception);
477 //! Indicate if the component instance provides custom information about its objects.
479 Returns true if the component provides custom information about its objects, false otherwise.
480 Should be redefined in the certain component to return true in case of this
481 component provides such information.
483 boolean hasObjectInfo();
485 //! Get custom information about the given object.
487 This method is used to get the custom information about the given object.
488 Should be redefined in the certain component in case of this
489 component provides such information.
490 It is worth using this method only if hasObjectInfo() method returns true.
492 \param entry object's entry.
494 \return an information about the given object.
496 string getObjectInfo(in string entry);
498 //! Get version of the component
500 This method is supposed to be implemented in all derived classes; default implementation
501 returns "unknown" string that means that no version information about the component is available.
502 \note The version of the component is stored to the study, as a part of general persistence
503 mechanism; once stored, version information in the study cannot be changed.
505 \return string containing component's version, e.g. "1.0"
511 \brief Base interface of the %component that supports exporting data.
513 interface ImportableComponent
515 /*! \brief Get a list of supported formats */
516 SALOME::StringSeq GetImportableFormats();
517 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
520 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
521 typedef sequence<octet> fileBlock;
523 /*! \brief Interface of fileTransfer.
524 The fileTransfer and fileRef interfaces provide a file transfer service
525 between different computers.
527 interface fileTransfer : SALOME::GenericObj
529 //! Open the file transfer
531 open method returns a key (fileId) that identifies the structure
532 (ex: C FILE), associated to the original file on the server.
533 The structure is created by a container for transfer of files availables
534 on the computer which runs the container.
535 Each open gives a unique fileId, to allow concurrent reads of the same
538 long open(in string fileName);
539 //! Open the file transfer in write mode for file fileName
541 \param fileName the file to copy into with putBlock
542 \return the id to use with putBlock
544 long openW(in string fileName);
546 //! Close the file transfer
548 when the file transfer is finished, close method releases structures
549 created by open method, identified by fileId.
551 void close(in long fileId);
553 //! Get a file data block
555 Get successive blocks of octets from the original file.
556 The last block is empty, and identifies the end of file.
558 fileBlock getBlock(in long fileId);
560 //! Put a file data block
562 \param fileId identification of the file obtained by openW
563 \param block a data block to copy into the file identified by fileId
565 void putBlock(in long fileId, in fileBlock block);
569 //! A file managed by a Salome_file.
576 string source_file_name;
577 //! status ("present" or "notpresent")
580 Engines::Container container;
583 //! A sequence of Engines::file.
584 typedef sequence<Engines::file> files;
587 //! The state of a Salome_file.
591 //! hdf5 file where the file can be saved
592 string hdf5_file_name;
593 //! number of files managed
594 long number_of_files;
595 //! information if all the files are received
600 /*! \brief Interface of a Salome_file managed
601 This file is independent of a Salome module. It can managed one or more
602 real files. It's useful for parallel files. Currently Salome_file cannot manage
603 two files that have the same name but not the same path.
605 interface Salome_file : Engines::fileTransfer
607 //! Load a Salome_file from a hdf5 file.
610 \param hdf5_file name (with path) of the hdf5_file.
612 \exception contains information of errors if the loading doesn't succeed.
614 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
616 //! Save a Salome_file into a hdf5_file.
619 \param hdf5_file name (with path) of the hdf5_file.
621 \exception contains information of errors if the save doesn't succeed.
624 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
626 //! Save a Salome_file into a hdf5_file.
628 All files that are managed are saved into the hdf5_file
630 \param hdf5_file name (with path) of the hdf5_file.
632 \exception contains information of errors if the save doesn't succeed.
635 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
639 //! Add a Local file to the Salome_file.
642 \param file_name name of the file with the path.
644 \exception raised if the file is already added into the Salome_file.
646 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
648 //! Add a Distributed file to the Salome_file.
651 \param comp_file_name name of the file with the path.
653 \exception raised if the file is already added into the Salome_file.
655 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
657 //! Connect a Salome_file with another Salome_file.
659 It works only if the Salome_file managed only one file
661 \param source_Salome_file Salome_file that managed the distributed version of the file.
663 \exception raised if there is more or less than one file.
665 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
667 //! Connect the managed file file_name to a Salome_file.
670 \param file_name name of the file without the path.
671 \param source_Salome_file Salome_file that managed the distributed version of the file.
673 \exception raised if the file doesn't exist.
675 void connectDistributedFile(in string file_name,
676 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
678 //! Connect the file_name with a Distributed file_name.
681 \param file_name name of the file without the path.
682 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
684 \exception raised if the file doesn't exist.
686 void setDistributedSourceFile(in string file_name,
687 in string source_file_name) raises (SALOME::SALOME_Exception);
691 //! Get all the distributed files managed by the Salome_file and check all the local files.
694 \exception raised if some of the files are not ok.
696 void recvFiles() raises (SALOME::SALOME_Exception) ;
700 //! Remove a file of the Salome_file.
703 \param file_name name of the file.
705 \exception raised if the file doesn't exist.
707 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
709 //! Remove all the files of the Salome_file.
714 //! Get the list of the files managed by the Salome_file.
716 The list can be empty.
718 Engines::files getFilesInfos();
720 //! Get a file managed by the Salome_file.
723 \param file_name the name of the file.
725 \return CORBA file reference.
727 \exception raised if the file doesn't exist.
729 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
731 //! Return the state of the Salome_file.
732 Engines::SfState getSalome_fileState();
735 //! Set the container where files are.
738 \param container container CORBA's reference.
740 void setContainer(in Engines::Container container);
743 /*! \brief Interface of fileRef.
744 The fileTransfer and fileRef interfaces provide a file transfer service
745 between different computers.
747 A fileRef object is associated to an original file (origFileName) on a
748 machine (refMachine).
749 It is created by a container (factoryServer) on refMachine,
750 with createFileRef(in string origFileName) method.
751 The fileRef object maintains a list of (machine,filename) for copies.
752 If a copy exists on myMachine, getRef(myMachine) returns the file name
753 of the copy on myMachine, else returns empty string.
754 If there is no copy on myMachine, method getFileTransfer() from container
755 factoryServer on refMachine provides a fileTransfer object dedicated to
757 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
758 the file name of the copy on myMachine.
762 //! the original file
763 readonly attribute string origFileName;
764 //! the machine of the original file
765 readonly attribute string refMachine;
767 Container getContainer();
769 boolean addRef(in string machine,
772 string getRef(in string machine);