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