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