1 // Copyright (C) 2007-2014 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;
63 typedef sequence<string> ListOfOptions;
64 typedef sequence<string> ListOfIdentifiers;
66 interface EngineComponent ;
68 interface fileTransfer ;
69 interface Salome_file;
70 interface DataContainer;
72 typedef sequence<DataContainer> ListOfData;
74 /*! \brief Interface of the %Container.
75 This interface defines the process of loading and registration
76 of new components in %SALOME application
82 /*! \brief Loads a new component class (dynamic library).
84 \param componentName like COMPONENT, (Python or C++ implementation)
85 try to make a Python import of COMPONENT,
86 then a lib open of libCOMPONENTEngine.so
87 \param reason in case of error (return false) a string explaining the error
88 \return true if load successfull or already done, false otherwise
90 boolean load_component_Library(in string componentName, out string reason);
92 //! Create a new servant instance of a component.
94 Component library must be loaded.
95 \param componentName Name of the component which will be registered
96 in Registry and Name Service,
97 (instance number suffix added to the registered name)
98 \param studyId 0 if instance is not associated to a study,
99 >0 otherwise (== study id)
100 \return a loaded component
102 Engines::EngineComponent create_component_instance(in string componentName,
105 //! Create a new servant instance of a component with environment variables specified.
107 Component library must be loaded.
108 \param componentName Name of the component which will be registered
109 in Registry and Name Service,
110 (instance number suffix added to the registered name)
111 \param studyId 0 if instance is not associated to a study,
112 >0 otherwise (== study id)
113 \param env a dict of env variables
114 \param reason in case of error (return nil) a string explaining the error
115 \return a loaded component
117 Engines::EngineComponent create_component_instance_env(in string componentName,
118 in long studyId, in FieldsDict env,
120 //! Find a servant instance of a component
122 \param registeredName Name of the component in Registry or Name Service,
123 without instance suffix number
124 \param studyId 0 if instance is not associated to a study,
125 >0 otherwise (== study id)
126 \return the first instance found with same studyId
128 EngineComponent find_component_instance(in string registeredName,
131 //! Find a servant instance of a component, or create a new one.
133 Loads the component library if needed.
134 Only applicable to multiStudy components.
135 \param nameToRegister Name of the component which will be registered
136 in Registry (or Name Service)
137 \param componentName Name of the constructed library of the %component
138 (not used any more, give empty string)
139 \return a loaded component
141 EngineComponent load_impl(in string nameToRegister,
142 in string componentName);
144 //! Remove the component servant, and deletes all related objects
146 \param component_i Component to be removed
148 void remove_impl(in EngineComponent component_i);
150 //! Unload component libraries from the container.
151 void finalize_removal() ;
153 //! Determines whether the server has been loaded or not.
156 //! Name of the %container
157 readonly attribute string name ;
159 //! working directory of the %container
160 readonly attribute string workingdir ;
162 //! name of the %container log file (this has been set by the launcher)
163 attribute string logfilename ;
165 //! Shutdown the Container process.
168 //! Returns the hostname of the container
169 string getHostName();
171 //! Returns the PID of the container
174 //! Kill the container
176 Returns True if the %container has been killed.
177 Kept for Superv compilation but can't work, unless oneway...
180 boolean Kill_impl() ;
184 returns a fileRef object if origFileName exists and is readable
185 else returns null object. Only one fileRef is created for a given
186 file name, so, several calls with the same file name returns the
189 fileRef createFileRef(in string origFileName);
191 //! Create a Salome_file
193 returns a Salome_file object if origFileName exists and is readable
194 else returns null object.
196 \param origFileName name of the file to be managed (can contain the path).
198 \return Salome_file CORBA reference.
200 Salome_file createSalome_file(in string origFileName);
202 //! Create a fileTransfer
204 returns a fileTransfer object used to copy files from the container
205 machine to the clients machines. Only one fileTransfer instance is
206 created in a container.
208 fileTransfer getFileTransfer();
210 //! Copy a file from a remote host (container) to a local file
212 \param contai the remote container
213 \param remoteFile the file on the remote host to copy
214 \param localFile the local file to create by copy
216 void copyFile(in Container contai, in string remoteFile, in string localFile);
218 //! Create a PyNode in the container
220 \param nodeName the name of the PyNode
221 \param code python code as text to load in the node
223 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
225 //! Create a PyScriptNode in the container
227 \param nodeName the name of the PyScriptNode
228 \param code python code as text to load in the node
230 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
233 /*! \brief Interface to pass data files from the client side to the SALOME Container.
234 Passes data from client side to the SALOME container (where component engine is running)
235 size via the CORBA bus as a stream of bytes.
238 interface DataContainer
240 //! This operation returns the stream with the data file content.
243 //! Returns the name of the document corresponding to this data container.
246 //! Returns the identifier of the document corresponding to this data container.
249 //! Returns the extension (type) of the document corresponding to this data container.
250 //! It is taked from the SIMAN URL.
253 //! Defines the extension. It is required is extension of the file is not
254 //! matched with a read extension: archived file, for example.
255 void setExtension(in string extension);
259 /*! \brief Interface of the %component.
260 This interface is used for interaction between the %container and the
261 %component and between the components inside the container.
263 interface EngineComponent
265 //! The name of the instance of the %Component
266 readonly attribute string instanceName ;
268 //! The name of the interface of the %Component
269 readonly attribute string interfaceName ;
271 //! Determines whether the server has already been loaded or not.
274 //! Get study associated to component instance
276 get study associated to component instance
277 \return -1: not initialised (Internal Error)
278 0: multistudy component instance
279 >0: study id associated to this instance
283 //! Remove component instance from container
285 Deactivates the %Component.
286 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
287 use remove_impl from Container instead !
291 //! Returns the container that the %Component refers to.
292 Container GetContainerRef() ;
294 //! Set component instance properties
296 Gives a sequence of (key=string,value=any) to the component.
297 Base class component stores the sequence in a map.
298 The map is cleared before.
299 This map is for use by derived classes.
301 void setProperties(in FieldsDict dico);
303 //! Get component instance properties
305 returns a previously stored map (key=string,value=any) as a sequence.
306 See setProperties(in FieldsDict dico).
308 FieldsDict getProperties();
310 //! Set an option value
312 This method is to set an option specific to a certain EngineComponent.
314 void SetOption(in string optionName, in string value);
316 //! Return an option value
318 This method is to get value of an option specific to a certain EngineComponent.
320 string GetOption(in string optionName);
322 //! Set name of a node in a graph (for %SUPERVISOR use)
324 This method is used by the %SUPERVISOR component. It sets the names of
325 the graph and of the node.
326 \param aGraphName Name of graph
327 \param aNodeName Name of node
329 void Names( in string aGraphName , in string aNodeName ) ;
331 //! Kill the component (if you can)
333 Returns True if the %Component has been killed.
335 boolean Kill_impl() ;
337 //! Stop the component (if you can)
339 Returns True if the activity of the %Component has been stopped.
340 (It's action can't be resumed)
342 boolean Stop_impl() ;
344 //! Suspend the component
346 Returns True if the activity of the %Component has been suspended.
347 (It's action can be resumed)
349 boolean Suspend_impl() ;
351 //! Resume the component
353 Returns True if the activity of the %Component has been resumed.
355 boolean Resume_impl() ;
361 long CpuUsed_impl() ;
363 //! Get a python dump
365 Returns a python script, which is being played back reproduces
366 the data model of component
368 TMPFile DumpPython(in Object theStudy,
369 in boolean isPublished,
370 in boolean isMultiFile,
371 out boolean isValidScript);
374 //! Returns a CORBA Ref of a input Salome_file managed by a service.
377 \param service_name service's name.
378 \param file_name name of the requested file.
380 \return CORBA Ref of the requested file.
382 \exception contains informations of what if the component cannot
383 sends the file's reference.
385 Engines::Salome_file getInputFileToService(in string service_name,
386 in string Salome_file_name) raises(SALOME::SALOME_Exception);
388 //! Check service input files (transfer them if needed)
390 This method is used before the activation of the service. It calls
391 recvFiles() on all the input Salome_file files of the service.
393 Before each recvFiles(), it uses the callback method named configureSalome_file.
394 This method allows the user to configure the files managed by the Salome_file.
396 By default, there is no files managed when a Salome_file is created,
397 but the supervisor set some files managed by the Salome_file from the information contained
398 into the schema file.
400 \param service_name service's name.
402 \exception contains informations about files that are not in a good state.
404 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
406 //! This method adds a input Salome_file to a service of the component.
409 \param service_name service's name.
410 \param Salome_file_name name of the Salome_file
412 \return a reference of the Salome_file
414 \exception raises an exception if there is already
415 a Salome_file with this name for the service.
417 Engines::Salome_file setInputFileToService(in string service_name,
418 in string Salome_file_name) raises(SALOME::SALOME_Exception);
420 //! Returns a CORBA Ref of a output Salome_file managed by a service.
423 \param service_name service's name.
424 \param file_name name of the requested file.
426 \return CORBA Ref of the requested file.
428 \exception contains informations of what if the component cannot
429 sends the file's reference.
431 Engines::Salome_file getOutputFileToService(in string service_name,
432 in string Salome_file_name) raises(SALOME::SALOME_Exception);
434 //! Check service output files (transfer them if needed)
436 This method is used at the end of the service. It calls
437 recvFiles() on all the output Salome_file files of the service.
439 Before each recvFiles(), it uses the callback method named configureSalome_file.
440 This method allows the user to configure the files managed by the Salome_file.
442 By default, there is no files managed when a Salome_file is created,
443 but the supervisor set some files managed by the Salome_file from the information contained
444 into the schema file.
446 \param service_name service's name.
448 \exception contains informations about files that are not in a good state.
450 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
452 //! This method adds an output Salome_file to a service of the component.
455 \param service_name service's name.
456 \param Salome_file_name name of the Salome_file
458 \return a reference of the Salome_file
460 \exception raises an exception if there is already
461 a Salome_file with this name for the service.
463 Engines::Salome_file setOutputFileToService(in string service_name,
464 in string Salome_file_name) raises(SALOME::SALOME_Exception);
466 //! Indicate if the component instance provides custom information about its objects.
468 Returns true if the component provides custom information about its objects, false otherwise.
469 Should be redefined in the certain component to return true in case of this
470 component provides such information.
472 boolean hasObjectInfo();
474 //! Get custom information about the given object.
476 This method is used to get the custom information about the given object.
477 Should be redefined in the certain component in case of this
478 component provides such information.
479 It is worth using this method only if hasObjectInfo() method returns true.
481 \param entry object's entry.
482 \param studyId study id
484 \return an information about the given object.
486 string getObjectInfo(in long studyId, in string entry);
488 //! Get version of the component
490 This method is supposed to be implemented in all derived classes; default implementation
491 returns "unknown" string that means that no version information about the component is available.
492 \note The version of the component is stored to the study, as a part of general persistence
493 mechanism; once stored, version information in the study cannot be changed.
495 \return string containing component's version, e.g. "1.0"
499 //! Generic Import operation to let the component to import data, corresponding to it.
501 \param studyId indentifier of the study where the data must be placed
502 \param data data for import: usually this is just imported file content
503 \param options additional options for Importat operation
504 \return the sequence of identifiers of the importedData in the component (to use later in the export function)
506 ListOfIdentifiers importData(in long studyId, in DataContainer data, in ListOfOptions options);
508 //! Generic Export operation to ket the component export all modified data corresponding to it.
510 \param studyId identifier of the study that contains the exported data
512 ListOfData getModifiedData(in long studyId);
516 \brief Base interface of the %component that supports exporting data.
518 interface ImportableComponent
520 /*! \brief Get a list of supported formats */
521 SALOME::StringSeq GetImportableFormats();
522 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
525 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
526 typedef sequence<octet> fileBlock;
528 /*! \brief Interface of fileTransfer.
529 The fileTransfer and fileRef interfaces provide a file transfer service
530 between different computers.
532 interface fileTransfer : SALOME::GenericObj
534 //! Open the file transfer
536 open method returns a key (fileId) that identifies the structure
537 (ex: C FILE), associated to the original file on the server.
538 The structure is created by a container for transfer of files availables
539 on the computer which runs the container.
540 Each open gives a unique fileId, to allow concurrent reads of the same
543 long open(in string fileName);
544 //! Open the file transfer in write mode for file fileName
546 \param fileName the file to copy into with putBlock
547 \return the id to use with putBlock
549 long openW(in string fileName);
551 //! Close the file transfer
553 when the file transfer is finished, close method releases structures
554 created by open method, identified by fileId.
556 void close(in long fileId);
558 //! Get a file data block
560 Get successive blocks of octets from the original file.
561 The last block is empty, and identifies the end of file.
563 fileBlock getBlock(in long fileId);
565 //! Put a file data block
567 \param fileId identification of the file obtained by openW
568 \param block a data block to copy into the file identified by fileId
570 void putBlock(in long fileId, in fileBlock block);
574 //! A file managed by a Salome_file.
581 string source_file_name;
582 //! status ("present" or "notpresent")
585 Engines::Container container;
588 //! A sequence of Engines::file.
589 typedef sequence<Engines::file> files;
592 //! The state of a Salome_file.
596 //! hdf5 file where the file can be saved
597 string hdf5_file_name;
598 //! number of files managed
599 long number_of_files;
600 //! information if all the files are received
605 /*! \brief Interface of a Salome_file managed
606 This file is independent of a Salome module. It can managed one or more
607 real files. It's useful for parallel files. Currently Salome_file cannot manage
608 two files that have the same name but not the same path.
610 interface Salome_file : Engines::fileTransfer
612 //! Load a Salome_file from a hdf5 file.
615 \param hdf5_file name (with path) of the hdf5_file.
617 \exception contains informations of errors if the loading doesn't succeed.
619 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
621 //! Save a Salome_file into a hdf5_file.
624 \param hdf5_file name (with path) of the hdf5_file.
626 \exception contains informations of errors if the save doesn't succeed.
629 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
631 //! Save a Salome_file into a hdf5_file.
633 All files that are managed are saved into the hdf5_file
635 \param hdf5_file name (with path) of the hdf5_file.
637 \exception contains informations of errors if the save doesn't succeed.
640 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
644 //! Add a Local file to the Salome_file.
647 \param file_name name of the file with the path.
649 \exception raised if the file is already added into the Salome_file.
651 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
653 //! Add a Distributed file to the Salome_file.
656 \param comp_file_name name of the file with the path.
658 \exception raised if the file is already added into the Salome_file.
660 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
662 //! Connect a Salome_file with another Salome_file.
664 It works only if the Salome_file managed only one file
666 \param source_Salome_file Salome_file that managed the distributed version of the file.
668 \exception raised if there is more or less than one file.
670 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
672 //! Connect the managed file file_name to a Salome_file.
675 \param file_name name of the file without the path.
676 \param source_Salome_file Salome_file that managed the distributed version of the file.
678 \exception raised if the file doesn't exist.
680 void connectDistributedFile(in string file_name,
681 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
683 //! Connect the file_name with a Distributed file_name.
686 \param file_name name of the file without the path.
687 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
689 \exception raised if the file doesn't exist.
691 void setDistributedSourceFile(in string file_name,
692 in string source_file_name) raises (SALOME::SALOME_Exception);
696 //! Get all the distributed files managed by the Salome_file and check all the local files.
699 \exception raised if some of the files are not ok.
701 void recvFiles() raises (SALOME::SALOME_Exception) ;
705 //! Remove a file of the Salome_file.
708 \param file_name name of the file.
710 \exception raised if the file doesn't exist.
712 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
714 //! Remove all the files of the Salome_file.
719 //! Get the list of the files managed by the Salome_file.
721 The list can be empty.
723 Engines::files getFilesInfos();
725 //! Get a file managed by the Salome_file.
728 \param file_name the name of the file.
730 \return CORBA file reference.
732 \exception raised if the file doesn't exist.
734 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
736 //! Return the state of the Salome_file.
737 Engines::SfState getSalome_fileState();
740 //! Set the container where files are.
743 \param container container CORBA's reference.
745 void setContainer(in Engines::Container container);
748 /*! \brief Interface of fileRef.
749 The fileTransfer and fileRef interfaces provide a file transfer service
750 between different computers.
752 A fileRef object is associated to an original file (origFileName) on a
753 machine (refMachine).
754 It is created by a container (factoryServer) on refMachine,
755 with createFileRef(in string origFileName) method.
756 The fileRef object maintains a list of (machine,filename) for copies.
757 If a copy exists on myMachine, getRef(myMachine) returns the file name
758 of the copy on myMachine, else returns empy string.
759 If there is no copy on myMachine, method getFileTransfer() from container
760 factoryServer on refMachine provides a fileTransfer object dedicated to
762 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
763 the file name of the copy on myMachine.
767 //! the original file
768 readonly attribute string origFileName;
769 //! the machine of the original file
770 readonly attribute string refMachine;
772 Container getContainer();
774 boolean addRef(in string machine,
777 string getRef(in string machine);