]> SALOME platform Git repositories - modules/kernel.git/blob - idl/SALOME_Component.idl
Salome HOME
[bos #29467] [EDF] (2022-T1) Logging of SALOME usage: specific log in SALOME
[modules/kernel.git] / idl / SALOME_Component.idl
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOME_Component.idl
24 //  Author : Paul RASCLE, EDF
25
26 #ifndef _SALOME_COMPONENT_IDL_
27 #define _SALOME_COMPONENT_IDL_
28
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
35 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
36 */
37
38 /*! \brief
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.
42 */
43 module Engines
44 {
45   /*!
46     A byte stream which is used for binary data transfer between different
47     components
48   */
49   typedef sequence<octet> TMPFile;
50
51   //!  General Key Value Structure to set or get properties, for component
52   struct KeyValuePair
53   {
54     string key;
55     any value;
56   };
57
58   //!  Structure data type to hold reference on data
59   struct dataref
60   {
61     string ref;
62   };
63
64   typedef sequence<KeyValuePair> FieldsDict;
65   typedef sequence<double> vectorOfDouble;
66   typedef sequence<string> vectorOfString;
67
68   interface EngineComponent ;
69   interface fileRef ;
70   interface fileTransfer ;
71   interface Salome_file;
72
73   /*! \brief Interface of the %Container.
74   This interface defines the process of loading and registration
75   of new components in %SALOME application
76   */
77
78   interface Container
79   {
80
81     void override_environment( in FieldsDict env );
82
83     void override_environment_python( in FieldsDict env );
84
85     FieldsDict get_os_environment();
86
87     /*! \brief Loads a new component class (dynamic library).
88
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
94     */
95     boolean load_component_Library(in string componentName, out string reason);
96
97     //! Create a new servant instance of a component.
98     /*!
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
104     */
105     Engines::EngineComponent create_component_instance(in string componentName);
106
107     //! Create a new Python servant instance of a generic service.
108         /*!
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.
116         */
117     string create_python_service_instance(in string serviceName,
118                                           out string reason);
119
120     //! Create a new servant instance of a component with environment variables specified.
121     /*!
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
129     */
130     Engines::EngineComponent create_component_instance_env(in string componentName,
131                                                            in FieldsDict env,
132                                                            out string reason);
133     //! Find a servant instance of a component
134     /*!
135       \param registeredName  Name of the component in Registry or Name Service,
136                              without instance suffix number
137       \return the first instance found
138     */
139     EngineComponent find_component_instance(in string registeredName);
140
141     //! Find a servant instance of a component, or create a new one.
142     /*!
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
150     */
151     EngineComponent load_impl(in string nameToRegister,
152                               in string componentName);
153
154     //! Remove the component servant, and deletes all related objects
155     /*!
156       \param component_i     Component to be removed
157     */
158     void remove_impl(in EngineComponent component_i);
159     
160     //! In case of SSL mode Returns entry to Embedded NS
161     EmbeddedNamingService get_embedded_NS_if_ssl();
162     
163     boolean is_SSL_mode();
164
165     //!  Unload component libraries from the container.
166     void finalize_removal() ;
167
168     //!  Determines whether the server has been loaded or not.
169     void ping();
170
171     //!  Name of the %container
172     readonly attribute string name ;
173
174     //!  working directory of the %container
175     readonly attribute string workingdir ;
176
177     //!  name of the %container log file (this has been set by the launcher)
178     attribute string logfilename ;
179
180     //!  Shutdown the Container process.
181     void Shutdown();
182
183     //!  Returns the hostname of the container
184     string getHostName();
185
186     //!  Returns the PID of the container
187     long getPID();
188
189     //! Kill the container
190     /*!
191       Returns True if the %container has been killed.
192       Kept for Superv compilation but can't work, unless oneway...
193       TO REMOVE !
194     */
195     boolean Kill_impl() ;
196
197     //! Create a fileRef
198     /*!
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
202       same object.
203     */
204     fileRef createFileRef(in string origFileName);
205
206     //! Create a Salome_file
207     /*!
208       returns a Salome_file object if origFileName exists and is readable
209       else returns null object.
210
211       \param origFileName name of the file to be managed (can contain the path).
212
213       \return Salome_file CORBA reference.
214     */
215     Salome_file createSalome_file(in string origFileName);
216
217     //! Create a fileTransfer
218     /*!
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.
222     */
223     fileTransfer getFileTransfer();
224
225     //! Copy a file from a remote host (container) to a local file
226     /*!
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
230      */
231     void copyFile(in Container contai, in string remoteFile, in string localFile);
232
233     //! Create a PyNode in the container
234     /*!
235       \param nodeName the name of the PyNode
236       \param code python code as text to load in the node
237      */
238     PyNode createPyNode(in string nodeName, in string code)  raises(SALOME::SALOME_Exception);
239
240     //! Retrieves the last created PyNode instance with createPyNode.
241     PyNode getDefaultPyNode(in string nodeName);
242
243     //! Create a PyScriptNode in the container
244     /*!
245       \param nodeName the name of the PyScriptNode
246       \param code python code as text to load in the node
247      */
248     PyScriptNode createPyScriptNode(in string nodeName, in string code)  raises(SALOME::SALOME_Exception);
249
250     void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
251
252     //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
253     PyScriptNode getDefaultPyScriptNode(in string nodeName);
254
255     //! This method remove all refs of PyScriptNode servant objects stored in server.
256     /*!
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.
258      */
259     void cleanAllPyScripts();
260
261     //! Return number of CPU cores in the calculation node.
262     long getNumberOfCPUCores();
263
264     //! Return a load of each CPU core.
265     vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
266
267     //! Set custom script to calculate a load of each CPU core.
268     /*!
269       \param script Python script to execute
270      */
271     void setPyScriptForCPULoad(in string script);
272
273     //! Nullify custom script to calculate each CPU core's load.
274     void resetScriptForCPULoad();
275
276     //! Get total physical memory of calculation node, in megabytes.
277     long getTotalPhysicalMemory();
278
279     //! Get used physical memory of calculation node, in megabytes.
280     long getTotalPhysicalMemoryInUse();
281
282     //! Obtain physical memory, used by the current process, in megabytes.
283     long getTotalPhysicalMemoryInUseByMe();
284   };
285
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.
289   */
290   interface EngineComponent
291   {
292     //!  The name of the instance of the %Component
293     readonly attribute string instanceName ;
294
295     //!  The name of the interface of the %Component
296     readonly attribute string interfaceName ;
297
298     //!  Determines whether the server has already been loaded or not.
299     void ping();
300
301     boolean isSSLMode() raises(SALOME::SALOME_Exception);
302     //! Remove component instance from container
303     /*!
304       Deactivates the %Component.
305       -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
306       use remove_impl from Container instead !
307     */
308     void destroy() ;
309
310     //!  Returns the container that the %Component refers to.
311     Container GetContainerRef() ;
312
313     //! Set component instance properties
314     /*!
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.
319     */
320     void setProperties(in FieldsDict dico);
321
322     //! Get component instance properties
323     /*!
324       returns a previously stored map (key=string,value=any) as a sequence.
325       See setProperties(in FieldsDict dico).
326     */
327     FieldsDict getProperties();
328
329     //! Set an option value
330     /*!
331       This method is to set an option specific to a certain EngineComponent.
332     */
333     void SetOption(in string optionName, in string value);
334
335     //! Return an option value
336     /*!
337       This method is to get value of an option specific to a certain EngineComponent.
338     */
339     string GetOption(in string optionName);
340
341     //! Set name of a node in a graph (for %SUPERVISOR use)
342     /*!
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
347     */
348     void Names( in string aGraphName , in string aNodeName ) ;
349
350     //! Kill the component (if you can)
351     /*!
352       Returns True if the %Component has been killed.
353     */
354     boolean Kill_impl() ;
355
356     //! Stop the component (if you can)
357     /*!
358       Returns True if the activity of the %Component has been stopped.
359       (It's action can't be resumed)
360     */
361     boolean Stop_impl() ;
362
363     //! Suspend the component
364     /*!
365       Returns True if the activity of the %Component has been suspended.
366       (It's action can be resumed)
367     */
368     boolean Suspend_impl() ;
369
370     //! Resume the component
371     /*!
372       Returns True if the activity of the %Component has been resumed.
373     */
374     boolean Resume_impl() ;
375
376     //! Get the cpu used
377     /*!
378       Returns the Cpu used
379     */
380     long CpuUsed_impl() ;
381
382     //! Get a python dump
383     /*!
384       Returns a python script, which is being played back reproduces
385       the data model of component
386     */
387     TMPFile DumpPython(in boolean isPublished,
388                        in boolean isMultiFile,
389                        out boolean isValidScript);
390
391
392     //! Returns a CORBA Ref of a input Salome_file managed by a service.
393     /*!
394
395       \param service_name service's name.
396       \param file_name name of the requested file.
397
398       \return CORBA Ref of the requested file.
399
400       \exception contains information of what if the component cannot
401       sends the file's reference.
402     */
403     Engines::Salome_file getInputFileToService(in string service_name,
404                                                in string Salome_file_name) raises(SALOME::SALOME_Exception);
405
406     //! Check service input files (transfer them if needed)
407     /*!
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.
410
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.
413
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.
417
418       \param service_name service's name.
419
420       \exception contains information about files that are not in a good state.
421     */
422     void checkInputFilesToService(in string service_name)           raises(SALOME::SALOME_Exception);
423
424     //!  This method adds a input Salome_file to a service of the component.
425     /*!
426
427       \param service_name service's name.
428       \param Salome_file_name name of the Salome_file
429
430       \return a reference of the Salome_file
431
432       \exception raises an exception if there is already
433       a Salome_file with this name for the service.
434     */
435     Engines::Salome_file setInputFileToService(in string service_name,
436                                                in string Salome_file_name)   raises(SALOME::SALOME_Exception);
437
438     //!  Returns a CORBA Ref of a output Salome_file managed by a service.
439     /*!
440
441       \param service_name service's name.
442       \param file_name name of the requested file.
443
444       \return CORBA Ref of the requested file.
445
446       \exception contains information of what if the component cannot
447       sends the file's reference.
448     */
449     Engines::Salome_file getOutputFileToService(in string service_name,
450                                                 in string Salome_file_name) raises(SALOME::SALOME_Exception);
451
452     //! Check service output files (transfer them if needed)
453     /*!
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.
456
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.
459
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.
463
464       \param service_name service's name.
465
466       \exception contains information about files that are not in a good state.
467     */
468     void checkOutputFilesToService(in string service_name)        raises(SALOME::SALOME_Exception);
469
470     //!  This method adds an output Salome_file to a service of the component.
471     /*!
472
473       \param service_name service's name.
474       \param Salome_file_name name of the Salome_file
475
476       \return a reference of the Salome_file
477
478       \exception raises an exception if there is already
479       a Salome_file with this name for the service.
480     */
481     Engines::Salome_file setOutputFileToService(in string service_name,
482                                                 in string Salome_file_name)  raises(SALOME::SALOME_Exception);
483
484     //! Indicate if the component instance provides custom information about its objects.
485     /*!
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.
489     */
490     boolean hasObjectInfo();
491
492     //! Get custom information about the given object.
493     /*!
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.
498
499       \param entry object's entry.
500
501       \return an information about the given object.
502     */
503     string getObjectInfo(in string entry);
504
505     //! Get version of the component
506     /*!
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.
511
512       \return string containing component's version, e.g. "1.0"
513     */
514     string getVersion();
515   };
516
517   /*!
518     \brief Base interface of the %component that supports exporting data.
519   */
520   interface ImportableComponent
521   {
522     /*! \brief Get a list of supported formats */
523     SALOME::StringSeq GetImportableFormats();
524     boolean           ImportDataAs(in string format, in SALOME::GenericObj exporter);
525   };
526
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;
529
530   /*! \brief Interface of fileTransfer.
531      The fileTransfer and fileRef interfaces provide a file transfer service
532      between different computers.
533   */
534   interface fileTransfer : SALOME::GenericObj
535   {
536     //! Open the file transfer
537     /*!
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
543       File.
544     */
545     long open(in string fileName);
546     //! Open the file transfer in write mode for file fileName
547     /*!
548       \param fileName the file to copy into with putBlock
549       \return the id to use with putBlock
550     */
551     long openW(in string fileName);
552
553     //! Close the file transfer
554     /*!
555     when the file transfer is finished, close method releases structures
556     created by open method, identified by fileId.
557     */
558     void close(in long fileId);
559
560     //! Get a file data block
561     /*!
562       Get successive blocks of octets from the original file.
563       The last block is empty, and identifies the end of file.
564     */
565     fileBlock getBlock(in long fileId);
566
567     //! Put a file data block
568     /*!
569        \param fileId identification of the file obtained by openW
570        \param block a data block to copy into the file identified by fileId
571     */
572     void putBlock(in long fileId, in fileBlock block);
573
574   };
575
576   //!  A file managed by a Salome_file.
577   struct file {
578     //! file name
579     string file_name;
580     //! path name
581     string path;
582     string type;
583     string source_file_name;
584     //! status ("present" or "notpresent")
585     string status;
586     long   node;
587     Engines::Container container;
588   };
589
590   //!  A sequence of Engines::file.
591   typedef sequence<Engines::file> files;
592
593
594   //!  The state of a Salome_file.
595   struct SfState {
596     //! file name
597     string  name;
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
603     boolean files_ok;
604
605   };
606
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.
611   */
612   interface Salome_file : Engines::fileTransfer
613   {
614     //!  Load a Salome_file from a hdf5 file.
615     /*!
616
617       \param hdf5_file name (with path) of the hdf5_file.
618
619       \exception contains information of errors if the loading doesn't succeed.
620      */
621     void load(in string hdf5_file)                            raises (SALOME::SALOME_Exception);
622
623     //!  Save a Salome_file into a hdf5_file.
624     /*!
625
626       \param  hdf5_file name (with path) of the hdf5_file.
627
628       \exception contains information of errors if the save doesn't succeed.
629
630     */
631     void save(in string hdf5_file)                            raises (SALOME::SALOME_Exception);
632
633     //!  Save a Salome_file into a hdf5_file.
634     /*!
635       All files that are managed are saved into the hdf5_file
636
637       \param  hdf5_file name (with path) of the hdf5_file.
638
639       \exception contains information of errors if the save doesn't succeed.
640
641     */
642     void save_all(in string hdf5_file)                            raises (SALOME::SALOME_Exception);
643
644 /**************/
645
646     //!  Add a Local file to the Salome_file.
647     /*!
648
649       \param file_name name of the file with the path.
650
651       \exception raised if the file is already added into the Salome_file.
652     */
653     void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
654
655     //!  Add a Distributed file to the Salome_file.
656     /*!
657
658       \param comp_file_name name of the file with the path.
659
660       \exception raised if the file is already added into the Salome_file.
661     */
662     void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
663
664     //!  Connect a Salome_file with another Salome_file.
665     /*!
666       It works only if the Salome_file managed only one file
667
668       \param source_Salome_file Salome_file that managed the distributed version of the file.
669
670       \exception raised if there is more or less than one file.
671     */
672     void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
673
674     //!  Connect the managed file file_name to a Salome_file.
675     /*!
676
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.
679
680       \exception raised if the file doesn't exist.
681     */
682     void connectDistributedFile(in string file_name,
683                                 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
684
685     //!  Connect the file_name with a Distributed file_name.
686     /*!
687
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.
690
691       \exception raised if the file doesn't exist.
692     */
693     void setDistributedSourceFile(in string file_name,
694                                   in string source_file_name) raises (SALOME::SALOME_Exception);
695
696 /**************/
697
698     //! Get all the distributed files managed by the Salome_file and check all the local files.
699     /*!
700
701       \exception raised if some of the files are not ok.
702     */
703     void recvFiles()                                            raises (SALOME::SALOME_Exception) ;
704
705 /**************/
706
707     //!  Remove a file of the Salome_file.
708     /*!
709
710       \param file_name name of the file.
711
712       \exception raised if the file doesn't exist.
713     */
714     void removeFile(in string file_name)                    raises (SALOME::SALOME_Exception);
715
716     //!  Remove all the files of the Salome_file.
717     void removeFiles();
718
719 /**************/
720
721     //! Get the list of the files managed by the Salome_file.
722     /*!
723       The list can be empty.
724     */
725     Engines::files getFilesInfos();
726
727     //! Get a file managed by the Salome_file.
728     /*!
729
730       \param file_name the name of the file.
731
732       \return CORBA file reference.
733
734       \exception raised if the file doesn't exist.
735     */
736     Engines::file  getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
737
738     //!  Return the state of the Salome_file.
739     Engines::SfState getSalome_fileState();
740
741
742     //! Set the container where files are.
743     /*!
744
745       \param container container CORBA's reference.
746     */
747     void setContainer(in Engines::Container container);
748   };
749
750   /*! \brief Interface of fileRef.
751      The fileTransfer and fileRef interfaces provide a file transfer service
752      between different computers.
753
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
763      CORBA file copy.
764      After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
765      the file name of the copy on myMachine.
766   */
767   interface fileRef
768   {
769     //! the original file
770     readonly attribute string origFileName;
771     //! the machine of the original file
772     readonly attribute string refMachine;
773
774     Container getContainer();
775
776     boolean addRef(in string machine,
777                    in string fileName);
778
779     string getRef(in string machine);
780   };
781 };
782
783 #endif