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