Salome HOME
[EDF29576] : log cleaning
[modules/kernel.git] / idl / SALOME_Component.idl
1 // Copyright (C) 2007-2024  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 #include "SALOME_Comm.idl"
35
36 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
37 */
38
39 /*! \brief
40 This is a package of interfaces used for connecting new components to %SALOME
41 application. It also contains a set of interfaces used for management of %FIELDS
42 component in %SALOME application.
43 */
44 module Engines
45 {
46   /*!
47     A byte stream which is used for binary data transfer between different
48     components
49   */
50   typedef sequence<octet> TMPFile;
51
52   //!  General Key Value Structure to set or get properties, for component
53   struct KeyValuePair
54   {
55     string key;
56     any value;
57   };
58
59   //!  Structure data type to hold reference on data
60   struct dataref
61   {
62     string ref;
63   };
64
65   typedef sequence<KeyValuePair> FieldsDict;
66   typedef sequence<double> vectorOfDouble;
67   typedef sequence<string> vectorOfString;
68
69   interface EngineComponent ;
70   interface fileRef ;
71   interface fileTransfer ;
72   interface Salome_file;
73
74   /*! \brief Interface of the %Container.
75   This interface defines the process of loading and registration
76   of new components in %SALOME application
77   */
78
79   interface Container
80   {
81
82     void override_environment( in FieldsDict env );
83
84     void override_environment_python( in FieldsDict env );
85
86     FieldsDict get_os_environment();
87
88     void execute_python_code( in string code ) raises(SALOME::SALOME_Exception);
89
90     /*! \brief Loads a new component class (dynamic library).
91
92       \param componentName like COMPONENT, (Python or C++ implementation)
93                            try to make a Python import of COMPONENT,
94                            then a lib open of libCOMPONENTEngine.so
95       \param reason      in case of error (return false) a string explaining the error
96       \return true if load successful or already done, false otherwise
97     */
98     boolean load_component_Library(in string componentName, out string reason);
99
100     //! Create a new servant instance of a component.
101     /*!
102       Component library must be loaded.
103       \param componentName Name of the component which will be registered
104                            in Registry and Name Service,
105                          (instance number suffix added to the registered name)
106       \return a loaded component
107     */
108     Engines::EngineComponent create_component_instance(in string componentName);
109
110     //! Create a new Python servant instance of a generic service.
111         /*!
112           This simply loads the service in the current container by importing the
113           corresponding Python module.
114           Warning: no internal registration is done, so it is up to the caller to
115           manage the various instantiation.
116           \param serviceName Name of the service
117           \param reason  in case of error (return void string) a string explaining the error
118           \return the IOR of the loaded service.
119         */
120     string create_python_service_instance(in string serviceName,
121                                           out string reason);
122
123     //! Create a new servant instance of a component with environment variables specified.
124     /*!
125       Component library must be loaded.
126       \param componentName Name of the component which will be registered
127                            in Registry and Name Service,
128                          (instance number suffix added to the registered name)
129       \param env         a dict of env variables
130       \param reason      in case of error (return nil) a string explaining the error
131       \return a loaded component
132     */
133     Engines::EngineComponent create_component_instance_env(in string componentName,
134                                                            in FieldsDict env,
135                                                            out string reason);
136     //! Find a servant instance of a component
137     /*!
138       \param registeredName  Name of the component in Registry or Name Service,
139                              without instance suffix number
140       \return the first instance found
141     */
142     EngineComponent find_component_instance(in string registeredName);
143
144     //! Find a servant instance of a component, or create a new one.
145     /*!
146       Loads the component library if needed.
147       Only applicable to multiStudy components.
148       \param nameToRegister Name of the component which will be registered
149                             in Registry (or Name Service)
150       \param componentName  Name of the constructed library of the %component
151                             (not used any more, give empty string)
152       \return a loaded component
153     */
154     EngineComponent load_impl(in string nameToRegister,
155                               in string componentName);
156
157     //! Remove the component servant, and deletes all related objects
158     /*!
159       \param component_i     Component to be removed
160     */
161     void remove_impl(in EngineComponent component_i);
162     
163     //! In case of SSL mode Returns entry to Embedded NS
164     EmbeddedNamingService get_embedded_NS_if_ssl();
165     
166     boolean is_SSL_mode();
167
168     //!  Unload component libraries from the container.
169     void finalize_removal() ;
170
171     //!  Determines whether the server has been loaded or not.
172     void ping();
173
174     //!  Name of the %container
175     readonly attribute string name ;
176
177     //!  working directory of the %container
178     readonly attribute string workingdir ;
179
180     //!  name of the %container log file (this has been set by the launcher)
181     attribute string logfilename ;
182     
183     //!  name of the %container log file
184     attribute string locallogfilename ;
185
186     //! interval of time between two measures of CPU/time process container
187     attribute long monitoringtimeresms;
188     
189     void verbosity(out boolean activated, out string level);
190
191     void setVerbosity(in boolean activated, in string level);
192
193     //!  Shutdown the Container process.
194     void Shutdown();
195
196     //!  Returns the hostname of the container
197     string getHostName();
198
199     //!  Returns the PID of the container
200     long getPID();
201
202     //! Kill the container
203     /*!
204       Returns True if the %container has been killed.
205       Kept for Superv compilation but can't work, unless oneway...
206       TO REMOVE !
207     */
208     boolean Kill_impl() ;
209
210     //! Create a fileRef
211     /*!
212       returns a fileRef object if origFileName exists and is readable
213       else returns null object. Only one fileRef is created for a given
214       file name, so, several calls with the same file name returns the
215       same object.
216     */
217     fileRef createFileRef(in string origFileName);
218
219     //! Create a Salome_file
220     /*!
221       returns a Salome_file object if origFileName exists and is readable
222       else returns null object.
223
224       \param origFileName name of the file to be managed (can contain the path).
225
226       \return Salome_file CORBA reference.
227     */
228     Salome_file createSalome_file(in string origFileName);
229
230     //! Create a fileTransfer
231     /*!
232       returns a fileTransfer object used to copy files from the container
233       machine to the clients machines. Only one fileTransfer instance is
234       created in a container.
235     */
236     fileTransfer getFileTransfer();
237
238     //! Copy a file from a remote host (container) to a local file
239     /*!
240       \param contai the remote container
241       \param remoteFile the file on the remote host to copy
242       \param localFile the local file to create by copy
243      */
244     void copyFile(in Container contai, in string remoteFile, in string localFile);
245
246     //! Create a PyNode in the container
247     /*!
248       \param nodeName the name of the PyNode
249       \param code python code as text to load in the node
250      */
251     PyNode createPyNode(in string nodeName, in string code)  raises(SALOME::SALOME_Exception);
252
253     //! Retrieves the last created PyNode instance with createPyNode.
254     PyNode getDefaultPyNode(in string nodeName);
255
256     //! Create a PyScriptNode in the container
257     /*!
258       \param nodeName the name of the PyScriptNode
259       \param code python code as text to load in the node
260      */
261     PyScriptNode createPyScriptNode(in string nodeName, in string code)  raises(SALOME::SALOME_Exception);
262
263     void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
264
265     //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
266     PyScriptNode getDefaultPyScriptNode(in string nodeName);
267
268     //! This method remove all refs of PyScriptNode servant objects stored in server.
269     /*!
270      * 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.
271      */
272     void cleanAllPyScripts();
273
274     //! Return number of CPU cores in the calculation node.
275     long getNumberOfCPUCores();
276
277     //! Return a load of each CPU core.
278     vectorOfDouble loadOfCPUCores() raises(SALOME::SALOME_Exception);
279
280     //! Set custom script to calculate a load of each CPU core.
281     /*!
282       \param script Python script to execute
283      */
284     void setPyScriptForCPULoad(in string script);
285
286     //! Nullify custom script to calculate each CPU core's load.
287     void resetScriptForCPULoad();
288
289     //! Get total physical memory of calculation node, in megabytes.
290     long getTotalPhysicalMemory();
291
292     //! Get used physical memory of calculation node, in megabytes.
293     long getTotalPhysicalMemoryInUse();
294
295     //! Obtain physical memory, used by the current process, in megabytes.
296     long getTotalPhysicalMemoryInUseByMe();
297   };
298
299   /*! \brief Interface of the %component.
300   This interface is used for interaction between the %container and the
301   %component and between the components inside the container.
302   */
303   interface EngineComponent
304   {
305     //!  The name of the instance of the %Component
306     readonly attribute string instanceName ;
307
308     //!  The name of the interface of the %Component
309     readonly attribute string interfaceName ;
310
311     //!  Determines whether the server has already been loaded or not.
312     void ping();
313
314     boolean isSSLMode() raises(SALOME::SALOME_Exception);
315     //! Remove component instance from container
316     /*!
317       Deactivates the %Component.
318       -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
319       use remove_impl from Container instead !
320     */
321     void destroy() ;
322
323     //!  Returns the container that the %Component refers to.
324     Container GetContainerRef() ;
325
326     //! Set component instance properties
327     /*!
328       Gives a sequence of (key=string,value=any) to the component.
329       Base class component stores the sequence in a map.
330       The map is cleared before.
331       This map is for use by derived classes.
332     */
333     void setProperties(in FieldsDict dico);
334
335     //! Get component instance properties
336     /*!
337       returns a previously stored map (key=string,value=any) as a sequence.
338       See setProperties(in FieldsDict dico).
339     */
340     FieldsDict getProperties();
341
342     //! Set an option value
343     /*!
344       This method is to set an option specific to a certain EngineComponent.
345     */
346     void SetOption(in string optionName, in string value);
347
348     //! Return an option value
349     /*!
350       This method is to get value of an option specific to a certain EngineComponent.
351     */
352     string GetOption(in string optionName);
353
354     //! Set name of a node in a graph (for %SUPERVISOR use)
355     /*!
356       This method is used by the %SUPERVISOR component. It sets the names of
357       the graph and of the node.
358       \param aGraphName Name of graph
359       \param aNodeName  Name of node
360     */
361     void Names( in string aGraphName , in string aNodeName ) ;
362
363     //! Kill the component (if you can)
364     /*!
365       Returns True if the %Component has been killed.
366     */
367     boolean Kill_impl() ;
368
369     //! Stop the component (if you can)
370     /*!
371       Returns True if the activity of the %Component has been stopped.
372       (It's action can't be resumed)
373     */
374     boolean Stop_impl() ;
375
376     //! Suspend the component
377     /*!
378       Returns True if the activity of the %Component has been suspended.
379       (It's action can be resumed)
380     */
381     boolean Suspend_impl() ;
382
383     //! Resume the component
384     /*!
385       Returns True if the activity of the %Component has been resumed.
386     */
387     boolean Resume_impl() ;
388
389     //! Get the cpu used
390     /*!
391       Returns the Cpu used
392     */
393     long CpuUsed_impl() ;
394
395     //! Get a python dump
396     /*!
397       Returns a python script, which is being played back reproduces
398       the data model of component
399     */
400     TMPFile DumpPython(in boolean isPublished,
401                        in boolean isMultiFile,
402                        out boolean isValidScript);
403
404
405     //! Returns a CORBA Ref of a input Salome_file managed by a service.
406     /*!
407
408       \param service_name service's name.
409       \param file_name name of the requested file.
410
411       \return CORBA Ref of the requested file.
412
413       \exception contains information of what if the component cannot
414       sends the file's reference.
415     */
416     Engines::Salome_file getInputFileToService(in string service_name,
417                                                in string Salome_file_name) raises(SALOME::SALOME_Exception);
418
419     //! Check service input files (transfer them if needed)
420     /*!
421       This method is used before the activation of the service. It calls
422       recvFiles() on all the input Salome_file files of the service.
423
424       Before each recvFiles(), it uses the callback method named configureSalome_file.
425       This method allows the user to configure the files managed by the Salome_file.
426
427       By default, there is no files managed when a Salome_file is created,
428       but the supervisor set some files managed by the Salome_file from the information contained
429       into the schema file.
430
431       \param service_name service's name.
432
433       \exception contains information about files that are not in a good state.
434     */
435     void checkInputFilesToService(in string service_name)           raises(SALOME::SALOME_Exception);
436
437     //!  This method adds a input Salome_file to a service of the component.
438     /*!
439
440       \param service_name service's name.
441       \param Salome_file_name name of the Salome_file
442
443       \return a reference of the Salome_file
444
445       \exception raises an exception if there is already
446       a Salome_file with this name for the service.
447     */
448     Engines::Salome_file setInputFileToService(in string service_name,
449                                                in string Salome_file_name)   raises(SALOME::SALOME_Exception);
450
451     //!  Returns a CORBA Ref of a output Salome_file managed by a service.
452     /*!
453
454       \param service_name service's name.
455       \param file_name name of the requested file.
456
457       \return CORBA Ref of the requested file.
458
459       \exception contains information of what if the component cannot
460       sends the file's reference.
461     */
462     Engines::Salome_file getOutputFileToService(in string service_name,
463                                                 in string Salome_file_name) raises(SALOME::SALOME_Exception);
464
465     //! Check service output files (transfer them if needed)
466     /*!
467       This method is used at the end of the service. It calls
468       recvFiles() on all the output Salome_file files of the service.
469
470       Before each recvFiles(), it uses the callback method named configureSalome_file.
471       This method allows the user to configure the files managed by the Salome_file.
472
473       By default, there is no files managed when a Salome_file is created,
474       but the supervisor set some files managed by the Salome_file from the information contained
475       into the schema file.
476
477       \param service_name service's name.
478
479       \exception contains information about files that are not in a good state.
480     */
481     void checkOutputFilesToService(in string service_name)        raises(SALOME::SALOME_Exception);
482
483     //!  This method adds an output Salome_file to a service of the component.
484     /*!
485
486       \param service_name service's name.
487       \param Salome_file_name name of the Salome_file
488
489       \return a reference of the Salome_file
490
491       \exception raises an exception if there is already
492       a Salome_file with this name for the service.
493     */
494     Engines::Salome_file setOutputFileToService(in string service_name,
495                                                 in string Salome_file_name)  raises(SALOME::SALOME_Exception);
496
497     //! Indicate if the component instance provides custom information about its objects.
498     /*!
499       Returns true if the component provides custom information about its objects, false otherwise.
500       Should be redefined in the certain component to return true in case of this
501       component provides such information.
502     */
503     boolean hasObjectInfo();
504
505     //! Get custom information about the given object.
506     /*!
507       This method is used to get the custom information about the given object.
508       Should be redefined in the certain component in case of this
509       component provides such information.
510       It is worth using this method only if hasObjectInfo() method returns true.
511
512       \param entry object's entry.
513
514       \return an information about the given object.
515     */
516     string getObjectInfo(in string entry);
517
518     //! Get version of the component
519     /*!
520       This method is supposed to be implemented in all derived classes; default implementation
521       returns "unknown" string that means that no version information about the component is available.
522       \note The version of the component is stored to the study, as a part of general persistence
523       mechanism; once stored, version information in the study cannot be changed.
524
525       \return string containing component's version, e.g. "1.0"
526     */
527     string getVersion();
528   };
529
530   /*!
531     \brief Base interface of the %component that supports exporting data.
532   */
533   interface ImportableComponent
534   {
535     /*! \brief Get a list of supported formats */
536     SALOME::StringSeq GetImportableFormats();
537     boolean           ImportDataAs(in string format, in SALOME::GenericObj exporter);
538   };
539
540   //!  A block of binary data used for file transfer. The maximum size of the block is defined on server side.
541   typedef sequence<octet> fileBlock;
542
543   /*! \brief Interface of fileTransfer.
544      The fileTransfer and fileRef interfaces provide a file transfer service
545      between different computers.
546   */
547   interface fileTransfer : SALOME::GenericObj
548   {
549     //! Open the file transfer
550     /*!
551       open method returns a key (fileId) that identifies the structure
552       (ex: C FILE), associated to the original file on the server.
553       The structure is created by a container for transfer of files availables
554       on the computer which runs the container.
555       Each open gives a unique fileId, to allow concurrent reads of the same
556       File.
557     */
558     long open(in string fileName);
559     //! Open the file transfer in write mode for file fileName
560     /*!
561       \param fileName the file to copy into with putBlock
562       \return the id to use with putBlock
563     */
564     long openW(in string fileName);
565
566     //! Close the file transfer
567     /*!
568     when the file transfer is finished, close method releases structures
569     created by open method, identified by fileId.
570     */
571     void close(in long fileId);
572
573     //! Get a file data block
574     /*!
575       Get successive blocks of octets from the original file.
576       The last block is empty, and identifies the end of file.
577     */
578     fileBlock getBlock(in long fileId);
579
580     //! Put a file data block
581     /*!
582        \param fileId identification of the file obtained by openW
583        \param block a data block to copy into the file identified by fileId
584     */
585     void putBlock(in long fileId, in fileBlock block);
586
587   };
588
589   //!  A file managed by a Salome_file.
590   struct file {
591     //! file name
592     string file_name;
593     //! path name
594     string path;
595     string type;
596     string source_file_name;
597     //! status ("present" or "notpresent")
598     string status;
599     long   node;
600     Engines::Container container;
601   };
602
603   //!  A sequence of Engines::file.
604   typedef sequence<Engines::file> files;
605
606
607   //!  The state of a Salome_file.
608   struct SfState {
609     //! file name
610     string  name;
611     //! hdf5 file where the file can be saved
612     string  hdf5_file_name;
613     //! number of files managed
614     long    number_of_files;
615     //! information if all the files are received
616     boolean files_ok;
617
618   };
619
620   /*! \brief Interface of a Salome_file managed
621     This file is independent of a Salome module. It can managed one or more
622     real files. It's useful for parallel files. Currently Salome_file cannot manage
623     two files that have the same name but not the same path.
624   */
625   interface Salome_file : Engines::fileTransfer
626   {
627     //!  Load a Salome_file from a hdf5 file.
628     /*!
629
630       \param hdf5_file name (with path) of the hdf5_file.
631
632       \exception contains information of errors if the loading doesn't succeed.
633      */
634     void load(in string hdf5_file)                            raises (SALOME::SALOME_Exception);
635
636     //!  Save a Salome_file into a hdf5_file.
637     /*!
638
639       \param  hdf5_file name (with path) of the hdf5_file.
640
641       \exception contains information of errors if the save doesn't succeed.
642
643     */
644     void save(in string hdf5_file)                            raises (SALOME::SALOME_Exception);
645
646     //!  Save a Salome_file into a hdf5_file.
647     /*!
648       All files that are managed are saved into the hdf5_file
649
650       \param  hdf5_file name (with path) of the hdf5_file.
651
652       \exception contains information of errors if the save doesn't succeed.
653
654     */
655     void save_all(in string hdf5_file)                            raises (SALOME::SALOME_Exception);
656
657 /**************/
658
659     //!  Add a Local file to the Salome_file.
660     /*!
661
662       \param file_name name of the file with the path.
663
664       \exception raised if the file is already added into the Salome_file.
665     */
666     void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
667
668     //!  Add a Distributed file to the Salome_file.
669     /*!
670
671       \param comp_file_name name of the file with the path.
672
673       \exception raised if the file is already added into the Salome_file.
674     */
675     void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
676
677     //!  Connect a Salome_file with another Salome_file.
678     /*!
679       It works only if the Salome_file managed only one file
680
681       \param source_Salome_file Salome_file that managed the distributed version of the file.
682
683       \exception raised if there is more or less than one file.
684     */
685     void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
686
687     //!  Connect the managed file file_name to a Salome_file.
688     /*!
689
690       \param file_name name of the file without the path.
691       \param source_Salome_file Salome_file that managed the distributed version of the file.
692
693       \exception raised if the file doesn't exist.
694     */
695     void connectDistributedFile(in string file_name,
696                                 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
697
698     //!  Connect the file_name with a Distributed file_name.
699     /*!
700
701       \param file_name name of the file without the path.
702       \param source_file_name It's the name of the file managed by the distributed source Salome_file.
703
704       \exception raised if the file doesn't exist.
705     */
706     void setDistributedSourceFile(in string file_name,
707                                   in string source_file_name) raises (SALOME::SALOME_Exception);
708
709 /**************/
710
711     //! Get all the distributed files managed by the Salome_file and check all the local files.
712     /*!
713
714       \exception raised if some of the files are not ok.
715     */
716     void recvFiles()                                            raises (SALOME::SALOME_Exception) ;
717
718 /**************/
719
720     //!  Remove a file of the Salome_file.
721     /*!
722
723       \param file_name name of the file.
724
725       \exception raised if the file doesn't exist.
726     */
727     void removeFile(in string file_name)                    raises (SALOME::SALOME_Exception);
728
729     //!  Remove all the files of the Salome_file.
730     void removeFiles();
731
732 /**************/
733
734     //! Get the list of the files managed by the Salome_file.
735     /*!
736       The list can be empty.
737     */
738     Engines::files getFilesInfos();
739
740     //! Get a file managed by the Salome_file.
741     /*!
742
743       \param file_name the name of the file.
744
745       \return CORBA file reference.
746
747       \exception raised if the file doesn't exist.
748     */
749     Engines::file  getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
750
751     //!  Return the state of the Salome_file.
752     Engines::SfState getSalome_fileState();
753
754
755     //! Set the container where files are.
756     /*!
757
758       \param container container CORBA's reference.
759     */
760     void setContainer(in Engines::Container container);
761   };
762
763   /*! \brief Interface of fileRef.
764      The fileTransfer and fileRef interfaces provide a file transfer service
765      between different computers.
766
767      A fileRef object is associated to an original file (origFileName) on a
768      machine (refMachine).
769      It is created by a container (factoryServer) on refMachine,
770      with createFileRef(in string origFileName) method.
771      The fileRef object maintains a list of (machine,filename) for copies.
772      If a copy exists on myMachine, getRef(myMachine) returns the file name
773      of the copy on myMachine, else returns empty string.
774      If there is no copy on myMachine, method getFileTransfer() from container
775      factoryServer on refMachine provides a fileTransfer object dedicated to
776      CORBA file copy.
777      After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
778      the file name of the copy on myMachine.
779   */
780   interface fileRef
781   {
782     //! the original file
783     readonly attribute string origFileName;
784     //! the machine of the original file
785     readonly attribute string refMachine;
786
787     Container getContainer();
788
789     boolean addRef(in string machine,
790                    in string fileName);
791
792     string getRef(in string machine);
793   };
794 };
795
796 #endif