1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
25 #ifndef _SALOME_COMPONENT_IDL_
26 #define _SALOME_COMPONENT_IDL_
28 #include "SALOME_GenericObj.idl"
29 #include "SALOMEDS.idl"
30 #include "SALOME_Exception.idl"
31 #include "SALOME_PyNode.idl"
33 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
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.
44 A byte stream which is used for binary data transfer between different
47 typedef sequence<octet> TMPFile;
49 //! General Key Value Structure to set or get properties, for component
56 //! Structure data type to hold reference on data
62 typedef sequence<KeyValuePair> FieldsDict;
64 interface EngineComponent ;
66 interface fileTransfer ;
67 interface Salome_file;
69 /*! \brief Interface of the %Container.
70 This interface defines the process of loading and registration
71 of new components in %SALOME application
77 /*! \brief Loads a new component class (dynamic library).
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
85 boolean load_component_Library(in string componentName, out string reason);
87 //! Create a new servant instance of a component.
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
97 Engines::EngineComponent create_component_instance(in string componentName,
100 //! Create a new Python servant instance of a generic service.
102 This simply loads the service in the current container by importing the
103 corresponding Python module.
104 Warning: no internal registration is done, so it is up to the caller to
105 manage the various instanciation.
106 \param serviceName Name of the service
108 >0 otherwise (== study id)
109 \param reason in case of error (return void string) a string explaining the error
110 \return the IOR of the loaded service.
112 string create_python_service_instance(in string serviceName,
115 //! Create a new servant instance of a component with environment variables specified.
117 Component library must be loaded.
118 \param componentName Name of the component which will be registered
119 in Registry and Name Service,
120 (instance number suffix added to the registered name)
121 \param studyId 0 if instance is not associated to a study,
122 >0 otherwise (== study id)
123 \param env a dict of env variables
124 \param reason in case of error (return nil) a string explaining the error
125 \return a loaded component
127 Engines::EngineComponent create_component_instance_env(in string componentName,
128 in long studyId, in FieldsDict env,
130 //! Find a servant instance of a component
132 \param registeredName Name of the component in Registry or Name Service,
133 without instance suffix number
134 \param studyId 0 if instance is not associated to a study,
135 >0 otherwise (== study id)
136 \return the first instance found with same studyId
138 EngineComponent find_component_instance(in string registeredName,
141 //! Find a servant instance of a component, or create a new one.
143 Loads the component library if needed.
144 Only applicable to multiStudy components.
145 \param nameToRegister Name of the component which will be registered
146 in Registry (or Name Service)
147 \param componentName Name of the constructed library of the %component
148 (not used any more, give empty string)
149 \return a loaded component
151 EngineComponent load_impl(in string nameToRegister,
152 in string componentName);
154 //! Remove the component servant, and deletes all related objects
156 \param component_i Component to be removed
158 void remove_impl(in EngineComponent component_i);
160 //! Unload component libraries from the container.
161 void finalize_removal() ;
163 //! Determines whether the server has been loaded or not.
166 //! Name of the %container
167 readonly attribute string name ;
169 //! working directory of the %container
170 readonly attribute string workingdir ;
172 //! name of the %container log file (this has been set by the launcher)
173 attribute string logfilename ;
175 //! Shutdown the Container process.
178 //! Returns the hostname of the container
179 string getHostName();
181 //! Returns the PID of the container
184 //! Kill the container
186 Returns True if the %container has been killed.
187 Kept for Superv compilation but can't work, unless oneway...
190 boolean Kill_impl() ;
194 returns a fileRef object if origFileName exists and is readable
195 else returns null object. Only one fileRef is created for a given
196 file name, so, several calls with the same file name returns the
199 fileRef createFileRef(in string origFileName);
201 //! Create a Salome_file
203 returns a Salome_file object if origFileName exists and is readable
204 else returns null object.
206 \param origFileName name of the file to be managed (can contain the path).
208 \return Salome_file CORBA reference.
210 Salome_file createSalome_file(in string origFileName);
212 //! Create a fileTransfer
214 returns a fileTransfer object used to copy files from the container
215 machine to the clients machines. Only one fileTransfer instance is
216 created in a container.
218 fileTransfer getFileTransfer();
220 //! Copy a file from a remote host (container) to a local file
222 \param contai the remote container
223 \param remoteFile the file on the remote host to copy
224 \param localFile the local file to create by copy
226 void copyFile(in Container contai, in string remoteFile, in string localFile);
228 //! Create a PyNode in the container
230 \param nodeName the name of the PyNode
231 \param code python code as text to load in the node
233 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
235 //! Retrieves the last created PyNode instance with createPyNode.
236 PyNode getDefaultPyNode(in string nodeName);
238 //! Create a PyScriptNode in the container
240 \param nodeName the name of the PyScriptNode
241 \param code python code as text to load in the node
243 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
245 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
246 PyScriptNode getDefaultPyScriptNode(in string nodeName);
249 /*! \brief Interface of the %component.
250 This interface is used for interaction between the %container and the
251 %component and between the components inside the container.
253 interface EngineComponent
255 //! The name of the instance of the %Component
256 readonly attribute string instanceName ;
258 //! The name of the interface of the %Component
259 readonly attribute string interfaceName ;
261 //! Determines whether the server has already been loaded or not.
264 //! Get study associated to component instance
266 get study associated to component instance
267 \return -1: not initialised (Internal Error)
268 0: multistudy component instance
269 >0: study id associated to this instance
273 //! Remove component instance from container
275 Deactivates the %Component.
276 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
277 use remove_impl from Container instead !
281 //! Returns the container that the %Component refers to.
282 Container GetContainerRef() ;
284 //! Set component instance properties
286 Gives a sequence of (key=string,value=any) to the component.
287 Base class component stores the sequence in a map.
288 The map is cleared before.
289 This map is for use by derived classes.
291 void setProperties(in FieldsDict dico);
293 //! Get component instance properties
295 returns a previously stored map (key=string,value=any) as a sequence.
296 See setProperties(in FieldsDict dico).
298 FieldsDict getProperties();
300 //! Set an option value
302 This method is to set an option specific to a certain EngineComponent.
304 void SetOption(in string optionName, in string value);
306 //! Return an option value
308 This method is to get value of an option specific to a certain EngineComponent.
310 string GetOption(in string optionName);
312 //! Set name of a node in a graph (for %SUPERVISOR use)
314 This method is used by the %SUPERVISOR component. It sets the names of
315 the graph and of the node.
316 \param aGraphName Name of graph
317 \param aNodeName Name of node
319 void Names( in string aGraphName , in string aNodeName ) ;
321 //! Kill the component (if you can)
323 Returns True if the %Component has been killed.
325 boolean Kill_impl() ;
327 //! Stop the component (if you can)
329 Returns True if the activity of the %Component has been stopped.
330 (It's action can't be resumed)
332 boolean Stop_impl() ;
334 //! Suspend the component
336 Returns True if the activity of the %Component has been suspended.
337 (It's action can be resumed)
339 boolean Suspend_impl() ;
341 //! Resume the component
343 Returns True if the activity of the %Component has been resumed.
345 boolean Resume_impl() ;
351 long CpuUsed_impl() ;
353 //! Get a python dump
355 Returns a python script, which is being played back reproduces
356 the data model of component
358 TMPFile DumpPython(in Object theStudy,
359 in boolean isPublished,
360 in boolean isMultiFile,
361 out boolean isValidScript);
364 //! Returns a CORBA Ref of a input Salome_file managed by a service.
367 \param service_name service's name.
368 \param file_name name of the requested file.
370 \return CORBA Ref of the requested file.
372 \exception contains informations of what if the component cannot
373 sends the file's reference.
375 Engines::Salome_file getInputFileToService(in string service_name,
376 in string Salome_file_name) raises(SALOME::SALOME_Exception);
378 //! Check service input files (transfer them if needed)
380 This method is used before the activation of the service. It calls
381 recvFiles() on all the input Salome_file files of the service.
383 Before each recvFiles(), it uses the callback method named configureSalome_file.
384 This method allows the user to configure the files managed by the Salome_file.
386 By default, there is no files managed when a Salome_file is created,
387 but the supervisor set some files managed by the Salome_file from the information contained
388 into the schema file.
390 \param service_name service's name.
392 \exception contains informations about files that are not in a good state.
394 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
396 //! This method adds a input Salome_file to a service of the component.
399 \param service_name service's name.
400 \param Salome_file_name name of the Salome_file
402 \return a reference of the Salome_file
404 \exception raises an exception if there is already
405 a Salome_file with this name for the service.
407 Engines::Salome_file setInputFileToService(in string service_name,
408 in string Salome_file_name) raises(SALOME::SALOME_Exception);
410 //! Returns a CORBA Ref of a output Salome_file managed by a service.
413 \param service_name service's name.
414 \param file_name name of the requested file.
416 \return CORBA Ref of the requested file.
418 \exception contains informations of what if the component cannot
419 sends the file's reference.
421 Engines::Salome_file getOutputFileToService(in string service_name,
422 in string Salome_file_name) raises(SALOME::SALOME_Exception);
424 //! Check service output files (transfer them if needed)
426 This method is used at the end of the service. It calls
427 recvFiles() on all the output Salome_file files of the service.
429 Before each recvFiles(), it uses the callback method named configureSalome_file.
430 This method allows the user to configure the files managed by the Salome_file.
432 By default, there is no files managed when a Salome_file is created,
433 but the supervisor set some files managed by the Salome_file from the information contained
434 into the schema file.
436 \param service_name service's name.
438 \exception contains informations about files that are not in a good state.
440 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
442 //! This method adds an output Salome_file to a service of the component.
445 \param service_name service's name.
446 \param Salome_file_name name of the Salome_file
448 \return a reference of the Salome_file
450 \exception raises an exception if there is already
451 a Salome_file with this name for the service.
453 Engines::Salome_file setOutputFileToService(in string service_name,
454 in string Salome_file_name) raises(SALOME::SALOME_Exception);
456 //! Indicate if the component instance provides custom information about its objects.
458 Returns true if the component provides custom information about its objects, false otherwise.
459 Should be redefined in the certain component to return true in case of this
460 component provides such information.
462 boolean hasObjectInfo();
464 //! Get custom information about the given object.
466 This method is used to get the custom information about the given object.
467 Should be redefined in the certain component in case of this
468 component provides such information.
469 It is worth using this method only if hasObjectInfo() method returns true.
471 \param entry object's entry.
472 \param studyId study id
474 \return an information about the given object.
476 string getObjectInfo(in long studyId, in string entry);
478 //! Get version of the component
480 This method is supposed to be implemented in all derived classes; default implementation
481 returns "unknown" string that means that no version information about the component is available.
482 \note The version of the component is stored to the study, as a part of general persistence
483 mechanism; once stored, version information in the study cannot be changed.
485 \return string containing component's version, e.g. "1.0"
491 \brief Base interface of the %component that supports exporting data.
493 interface ImportableComponent
495 /*! \brief Get a list of supported formats */
496 SALOME::StringSeq GetImportableFormats();
497 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
500 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
501 typedef sequence<octet> fileBlock;
503 /*! \brief Interface of fileTransfer.
504 The fileTransfer and fileRef interfaces provide a file transfer service
505 between different computers.
507 interface fileTransfer : SALOME::GenericObj
509 //! Open the file transfer
511 open method returns a key (fileId) that identifies the structure
512 (ex: C FILE), associated to the original file on the server.
513 The structure is created by a container for transfer of files availables
514 on the computer which runs the container.
515 Each open gives a unique fileId, to allow concurrent reads of the same
518 long open(in string fileName);
519 //! Open the file transfer in write mode for file fileName
521 \param fileName the file to copy into with putBlock
522 \return the id to use with putBlock
524 long openW(in string fileName);
526 //! Close the file transfer
528 when the file transfer is finished, close method releases structures
529 created by open method, identified by fileId.
531 void close(in long fileId);
533 //! Get a file data block
535 Get successive blocks of octets from the original file.
536 The last block is empty, and identifies the end of file.
538 fileBlock getBlock(in long fileId);
540 //! Put a file data block
542 \param fileId identification of the file obtained by openW
543 \param block a data block to copy into the file identified by fileId
545 void putBlock(in long fileId, in fileBlock block);
549 //! A file managed by a Salome_file.
556 string source_file_name;
557 //! status ("present" or "notpresent")
560 Engines::Container container;
563 //! A sequence of Engines::file.
564 typedef sequence<Engines::file> files;
567 //! The state of a Salome_file.
571 //! hdf5 file where the file can be saved
572 string hdf5_file_name;
573 //! number of files managed
574 long number_of_files;
575 //! information if all the files are received
580 /*! \brief Interface of a Salome_file managed
581 This file is independent of a Salome module. It can managed one or more
582 real files. It's useful for parallel files. Currently Salome_file cannot manage
583 two files that have the same name but not the same path.
585 interface Salome_file : Engines::fileTransfer
587 //! Load a Salome_file from a hdf5 file.
590 \param hdf5_file name (with path) of the hdf5_file.
592 \exception contains informations of errors if the loading doesn't succeed.
594 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
596 //! Save a Salome_file into a hdf5_file.
599 \param hdf5_file name (with path) of the hdf5_file.
601 \exception contains informations of errors if the save doesn't succeed.
604 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
606 //! Save a Salome_file into a hdf5_file.
608 All files that are managed are saved into the hdf5_file
610 \param hdf5_file name (with path) of the hdf5_file.
612 \exception contains informations of errors if the save doesn't succeed.
615 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
619 //! Add a Local file to the Salome_file.
622 \param file_name name of the file with the path.
624 \exception raised if the file is already added into the Salome_file.
626 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
628 //! Add a Distributed file to the Salome_file.
631 \param comp_file_name name of the file with the path.
633 \exception raised if the file is already added into the Salome_file.
635 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
637 //! Connect a Salome_file with another Salome_file.
639 It works only if the Salome_file managed only one file
641 \param source_Salome_file Salome_file that managed the distributed version of the file.
643 \exception raised if there is more or less than one file.
645 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
647 //! Connect the managed file file_name to a Salome_file.
650 \param file_name name of the file without the path.
651 \param source_Salome_file Salome_file that managed the distributed version of the file.
653 \exception raised if the file doesn't exist.
655 void connectDistributedFile(in string file_name,
656 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
658 //! Connect the file_name with a Distributed file_name.
661 \param file_name name of the file without the path.
662 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
664 \exception raised if the file doesn't exist.
666 void setDistributedSourceFile(in string file_name,
667 in string source_file_name) raises (SALOME::SALOME_Exception);
671 //! Get all the distributed files managed by the Salome_file and check all the local files.
674 \exception raised if some of the files are not ok.
676 void recvFiles() raises (SALOME::SALOME_Exception) ;
680 //! Remove a file of the Salome_file.
683 \param file_name name of the file.
685 \exception raised if the file doesn't exist.
687 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
689 //! Remove all the files of the Salome_file.
694 //! Get the list of the files managed by the Salome_file.
696 The list can be empty.
698 Engines::files getFilesInfos();
700 //! Get a file managed by the Salome_file.
703 \param file_name the name of the file.
705 \return CORBA file reference.
707 \exception raised if the file doesn't exist.
709 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
711 //! Return the state of the Salome_file.
712 Engines::SfState getSalome_fileState();
715 //! Set the container where files are.
718 \param container container CORBA's reference.
720 void setContainer(in Engines::Container container);
723 /*! \brief Interface of fileRef.
724 The fileTransfer and fileRef interfaces provide a file transfer service
725 between different computers.
727 A fileRef object is associated to an original file (origFileName) on a
728 machine (refMachine).
729 It is created by a container (factoryServer) on refMachine,
730 with createFileRef(in string origFileName) method.
731 The fileRef object maintains a list of (machine,filename) for copies.
732 If a copy exists on myMachine, getRef(myMachine) returns the file name
733 of the copy on myMachine, else returns empy string.
734 If there is no copy on myMachine, method getFileTransfer() from container
735 factoryServer on refMachine provides a fileTransfer object dedicated to
737 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
738 the file name of the copy on myMachine.
742 //! the original file
743 readonly attribute string origFileName;
744 //! the machine of the original file
745 readonly attribute string refMachine;
747 Container getContainer();
749 boolean addRef(in string machine,
752 string getRef(in string machine);