1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOME_Component.idl
23 // Author : Paul RASCLE, EDF
26 #ifndef _SALOME_COMPONENT_IDL_
27 #define _SALOME_COMPONENT_IDL_
29 #include "SALOMEDS.idl"
30 #include "SALOME_Exception.idl"
32 /*! \file SALOME_Component.idl \brief interfaces for Component and Container
36 This is a package of interfaces used for connecting new components to %SALOME
37 application. It also contains a set of interfaces used for management of %MED
38 component in %SALOME application.
43 A byte stream which is used for binary data transfer between different
46 typedef sequence<octet> TMPFile;
48 //! General Key Value Structure to set or get properties, for component
55 typedef sequence<KeyValuePair> FieldsDict;
59 interface fileTransfer ;
60 interface Salome_file;
62 /*! \brief Interface of the %Container.
63 This interface defines the process of loading and registration
64 of new components in %SALOME application
70 /*! \brief Loads a new component class (dynamic library).
72 \param componentName like COMPONENT, (Python or C++ implementation)
73 try to make a Python import of COMPONENT,
74 then a lib open of libCOMPONENTEngine.so
75 \return true if load successfull or already done, false otherwise
77 boolean load_component_Library(in string componentName);
79 //! Create a new servant instance of a component.
81 Component library must be loaded.
82 \param componentName Name of the component which will be registered
83 in Registry and Name Service,
84 (instance number suffix added to the registered name)
85 \param studyId 0 if instance is not associated to a study,
86 >0 otherwise (== study id)
87 \return a loaded component
89 Engines::Component create_component_instance(in string componentName,
92 //! Find a servant instance of a component
94 \param registeredName Name of the component in Registry or Name Service,
95 without instance suffix number
96 \param studyId 0 if instance is not associated to a study,
97 >0 otherwise (== study id)
98 \return the first instance found with same studyId
100 Component find_component_instance(in string registeredName,
103 //! Find a servant instance of a component, or create a new one.
105 Loads the component library if needed.
106 Only applicable to multiStudy components.
107 \param nameToRegister Name of the component which will be registered
108 in Registry (or Name Service)
109 \param componentName Name of the constructed library of the %component
110 (not used any more, give empty string)
111 \return a loaded component
113 Component load_impl(in string nameToRegister,
114 in string componentName);
116 //! Remove the component servant, and deletes all related objects
118 \param component_i Component to be removed
120 void remove_impl(in Component component_i);
122 //! Unload component libraries from the container.
123 void finalize_removal() ;
125 //! Determines whether the server has been loaded or not.
128 //! Name of the %container
129 readonly attribute string name ;
131 //! working directory of the %container
132 readonly attribute string workingdir ;
134 //! name of the %container log file (this has been set by the launcher)
135 attribute string logfilename ;
137 //! Shutdown the Container process.
140 //! Returns the hostname of the container
141 string getHostName();
143 //! Returns the PID of the container
146 //! Kill the container
148 Returns True if the %container has been killed.
149 Kept for Superv compilation but can't work, unless oneway...
152 boolean Kill_impl() ;
156 returns a fileRef object if origFileName exists and is readable
157 else returns null object. Only one fileRef is created for a given
158 file name, so, several calls with the same file name returns the
161 fileRef createFileRef(in string origFileName);
163 //! Create a Salome_file
165 returns a Salome_file object if origFileName exists and is readable
166 else returns null object.
168 \param origFileName name of the file to be managed (can contain the path).
170 \return Salome_file CORBA reference.
172 Salome_file createSalome_file(in string origFileName);
174 //! Create a fileTransfer
176 returns a fileTransfer object used to copy files from the container
177 machine to the clients machines. Only one fileTransfer instance is
178 created in a container.
180 fileTransfer getFileTransfer();
182 //! Copy a file from a remote host (container) to a local file
184 \param contai the remote container
185 \param remoteFile the file on the remote host to copy
186 \param localFile the local file to create by copy
188 void copyFile(in Container contai, in string remoteFile, in string localFile);
191 /*! \brief Interface of the %component.
192 This interface is used for interaction between the %container and the
193 %component and between the components inside the container.
197 //! The name of the instance of the %Component
198 readonly attribute string instanceName ;
200 //! The name of the interface of the %Component
201 readonly attribute string interfaceName ;
203 //! Determines whether the server has already been loaded or not.
206 //! Get study associated to component instance
208 get study associated to component instance
209 \return -1: not initialised (Internal Error)
210 0: multistudy component instance
211 >0: study id associated to this instance
215 //! Remove component instance from container
217 Deactivates the %Component.
218 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
219 use remove_impl from Container instead !
223 //! Returns the container that the %Component refers to.
224 Container GetContainerRef() ;
226 //! Set component instance properties
228 Gives a sequence of (key=string,value=any) to the component.
229 Base class component stores the sequence in a map.
230 The map is cleared before.
231 This map is for use by derived classes.
233 void setProperties(in FieldsDict dico);
235 //! Get component instance properties
237 returns a previously stored map (key=string,value=any) as a sequence.
238 See setProperties(in FieldsDict dico).
240 FieldsDict getProperties();
242 //! Set name of a node in a graph (for %SUPERVISOR use)
244 This method is used by the %SUPERVISOR component. It sets the names of
245 the graph and of the node.
246 \param aGraphName Name of graph
247 \param aNodeName Name of node
249 void Names( in string aGraphName , in string aNodeName ) ;
251 //! Kill the component (if you can)
253 Returns True if the %Component has been killed.
255 boolean Kill_impl() ;
257 //! Stop the component (if you can)
259 Returns True if the activity of the %Component has been stopped.
260 (It's action can't be resumed)
262 boolean Stop_impl() ;
264 //! Suspend the component
266 Returns True if the activity of the %Component has been suspended.
267 (It's action can be resumed)
269 boolean Suspend_impl() ;
271 //! Resume the component
273 Returns True if the activity of the %Component has been resumed.
275 boolean Resume_impl() ;
281 long CpuUsed_impl() ;
283 //! Get a python dump
285 Returns a python script, which is being played back reproduces
286 the data model of component
288 TMPFile DumpPython(in Object theStudy,
289 in boolean isPublished,
290 out boolean isValidScript);
293 //! Returns a CORBA Ref of a input Salome_file managed by a service.
296 \param service_name service's name.
297 \param file_name name of the requested file.
299 \return CORBA Ref of the requested file.
301 \exception contains informations of what if the component cannot
302 sends the file's reference.
304 Engines::Salome_file getInputFileToService(in string service_name,
305 in string Salome_file_name) raises(SALOME::SALOME_Exception);
307 //! Check service input files (transfer them if needed)
309 This method is used before the activation of the service. It calls
310 recvFiles() on all the input Salome_file files of the service.
312 Before each recvFiles(), it uses the callback method named configureSalome_file.
313 This method allows the user to configure the files managed by the Salome_file.
315 By default, there is no files managed when a Salome_file is created,
316 but the supervisor set some files managed by the Salome_file from the information contained
317 into the schema file.
319 \param service_name service's name.
321 \exception contains informations about files that are not in a good state.
323 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
325 //! This method adds a input Salome_file to a service of the component.
328 \param service_name service's name.
329 \param Salome_file_name name of the Salome_file
331 \return a reference of the Salome_file
333 \exception raises an exception if there is already
334 a Salome_file with this name for the service.
336 Engines::Salome_file setInputFileToService(in string service_name,
337 in string Salome_file_name) raises(SALOME::SALOME_Exception);
339 //! Returns a CORBA Ref of a output Salome_file managed by a service.
342 \param service_name service's name.
343 \param file_name name of the requested file.
345 \return CORBA Ref of the requested file.
347 \exception contains informations of what if the component cannot
348 sends the file's reference.
350 Engines::Salome_file getOutputFileToService(in string service_name,
351 in string Salome_file_name) raises(SALOME::SALOME_Exception);
353 //! Check service output files (transfer them if needed)
355 This method is used at the end of the service. It calls
356 recvFiles() on all the output Salome_file files of the service.
358 Before each recvFiles(), it uses the callback method named configureSalome_file.
359 This method allows the user to configure the files managed by the Salome_file.
361 By default, there is no files managed when a Salome_file is created,
362 but the supervisor set some files managed by the Salome_file from the information contained
363 into the schema file.
365 \param service_name service's name.
367 \exception contains informations about files that are not in a good state.
369 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
371 //! This method adds an output Salome_file to a service of the component.
374 \param service_name service's name.
375 \param Salome_file_name name of the Salome_file
377 \return a reference of the Salome_file
379 \exception raises an exception if there is already
380 a Salome_file with this name for the service.
382 Engines::Salome_file setOutputFileToService(in string service_name,
383 in string Salome_file_name) raises(SALOME::SALOME_Exception);
385 //! Indicate if the component instance provides custom information about its objects.
387 Returns true if the component provides custom information about its objects, false otherwise.
388 Should be redefined in the certain component to return true in case of this
389 component provides such information.
391 boolean hasObjectInfo();
393 //! Get custom information about the given object.
395 This method is used to get the custom information about the given object.
396 Should be redefined in the certain component in case of this
397 component provides such information.
398 It is worth using this method only if hasObjectInfo() method returns true.
400 \param entry object's entry.
401 \param studyId study id
403 \return an information about the given object.
405 string getObjectInfo(in long studyId, in string entry);
408 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
409 typedef sequence<octet> fileBlock;
411 /*! \brief Interface of fileTransfer.
412 The fileTransfer and fileRef interfaces provide a file transfer service
413 between different computers.
415 interface fileTransfer
417 //! Open the file transfer
419 open method returns a key (fileId) that identifies the structure
420 (ex: C FILE), associated to the original file on the server.
421 The structure is created by a container for transfer of files availables
422 on the computer which runs the container.
423 Each open gives a unique fileId, to allow concurrent reads of the same
426 long open(in string fileName);
427 //! Open the file transfer in write mode for file fileName
429 \param fileName the file to copy into with putBlock
430 \return the id to use with putBlock
432 long openW(in string fileName);
434 //! Close the file transfer
436 when the file transfer is finished, close method releases structures
437 created by open method, identified by fileId.
439 void close(in long fileId);
441 //! Get a file data block
443 Get successive blocks of octets from the original file.
444 The last block is empty, and identifies the end of file.
446 fileBlock getBlock(in long fileId);
448 //! Put a file data block
450 \param fileId identification of the file obtained by openW
451 \param block a data block to copy into the file identified by fileId
453 void putBlock(in long fileId, in fileBlock block);
457 //! A file managed by a Salome_file.
464 string source_file_name;
465 //! status ("present" or "notpresent")
468 Engines::Container container;
471 //! A sequence of Engines::file.
472 typedef sequence<Engines::file> files;
475 //! The state of a Salome_file.
479 //! hdf5 file where the file can be saved
480 string hdf5_file_name;
481 //! number of files managed
482 long number_of_files;
483 //! information if all the files are received
488 /*! \brief Interface of a Salome_file managed
489 This file is independent of a Salome module. It can managed one or more
490 real files. It's useful for parallel files. Currently Salome_file cannot manage
491 two files that have the same name but not the same path.
493 interface Salome_file : Engines::fileTransfer
495 //! Load a Salome_file from a hdf5 file.
498 \param hdf5_file name (with path) of the hdf5_file.
500 \exception contains informations of errors if the loading doesn't succeed.
502 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
504 //! Save a Salome_file into a hdf5_file.
507 \param hdf5_file name (with path) of the hdf5_file.
509 \exception contains informations of errors if the save doesn't succeed.
512 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
514 //! Save a Salome_file into a hdf5_file.
516 All files that are managed are saved into the hdf5_file
518 \param hdf5_file name (with path) of the hdf5_file.
520 \exception contains informations of errors if the save doesn't succeed.
523 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
527 //! Add a Local file to the Salome_file.
530 \param file_name name of the file with the path.
532 \exception raised if the file is already added into the Salome_file.
534 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
536 //! Add a Distributed file to the Salome_file.
539 \param comp_file_name name of the file with the path.
541 \exception raised if the file is already added into the Salome_file.
543 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
545 //! Connect a Salome_file with another Salome_file.
547 It works only if the Salome_file managed only one file
549 \param source_Salome_file Salome_file that managed the distributed version of the file.
551 \exception raised if there is more or less than one file.
553 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
555 //! Connect the managed file file_name to a Salome_file.
558 \param file_name name of the file without the path.
559 \param source_Salome_file Salome_file that managed the distributed version of the file.
561 \exception raised if the file doesn't exist.
563 void connectDistributedFile(in string file_name,
564 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
566 //! Connect the file_name with a Distributed file_name.
569 \param file_name name of the file without the path.
570 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
572 \exception raised if the file doesn't exist.
574 void setDistributedSourceFile(in string file_name,
575 in string source_file_name) raises (SALOME::SALOME_Exception);
579 //! Get all the distributed files managed by the Salome_file and check all the local files.
582 \exception raised if some of the files are not ok.
584 void recvFiles() raises (SALOME::SALOME_Exception) ;
588 //! Remove a file of the Salome_file.
591 \param file_name name of the file.
593 \exception raised if the file doesn't exist.
595 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
597 //! Remove all the files of the Salome_file.
602 //! Get the list of the files managed by the Salome_file.
604 The list can be empty.
606 Engines::files getFilesInfos();
608 //! Get a file managed by the Salome_file.
611 \param file_name the name of the file.
613 \return CORBA file reference.
615 \exception raised if the file doesn't exist.
617 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
619 //! Return the state of the Salome_file.
620 Engines::SfState getSalome_fileState();
623 //! Set the container where files are.
626 \param container container CORBA's reference.
628 void setContainer(in Engines::Container container);
631 /*! \brief Interface of fileRef.
632 The fileTransfer and fileRef interfaces provide a file transfer service
633 between different computers.
635 A fileRef object is associated to an original file (origFileName) on a
636 machine (refMachine).
637 It is created by a container (factoryServer) on refMachine,
638 with createFileRef(in string origFileName) method.
639 The fileRef object maintains a list of (machine,filename) for copies.
640 If a copy exists on myMachine, getRef(myMachine) returns the file name
641 of the copy on myMachine, else returns empy string.
642 If there is no copy on myMachine, method getFileTransfer() from container
643 factoryServer on refMachine provides a fileTransfer object dedicated to
645 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
646 the file name of the copy on myMachine.
650 //! the original file
651 readonly attribute string origFileName;
652 //! the machine of the original file
653 readonly attribute string refMachine;
655 Container getContainer();
657 boolean addRef(in string machine,
660 string getRef(in string machine);