1 // Copyright (C) 2007-2021 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
23 // File : SALOME_Component.idl
24 // Author : Paul RASCLE, EDF
26 #ifndef _SALOME_COMPONENT_IDL_
27 #define _SALOME_COMPONENT_IDL_
29 #include "SALOME_GenericObj.idl"
30 #include "SALOMEDS.idl"
31 #include "SALOME_Exception.idl"
32 #include "SALOME_PyNode.idl"
33 #include "SALOME_Embedded_NamingService.idl"
35 /*! \file SALOME_Component.idl \brief interfaces for EngineComponent and Container
39 This is a package of interfaces used for connecting new components to %SALOME
40 application. It also contains a set of interfaces used for management of %FIELDS
41 component in %SALOME application.
46 A byte stream which is used for binary data transfer between different
49 typedef sequence<octet> TMPFile;
51 //! General Key Value Structure to set or get properties, for component
58 //! Structure data type to hold reference on data
64 typedef sequence<KeyValuePair> FieldsDict;
66 interface EngineComponent ;
68 interface fileTransfer ;
69 interface Salome_file;
71 /*! \brief Interface of the %Container.
72 This interface defines the process of loading and registration
73 of new components in %SALOME application
79 /*! \brief Loads a new component class (dynamic library).
81 \param componentName like COMPONENT, (Python or C++ implementation)
82 try to make a Python import of COMPONENT,
83 then a lib open of libCOMPONENTEngine.so
84 \param reason in case of error (return false) a string explaining the error
85 \return true if load successful or already done, false otherwise
87 boolean load_component_Library(in string componentName, out string reason);
89 //! Create a new servant instance of a component.
91 Component library must be loaded.
92 \param componentName Name of the component which will be registered
93 in Registry and Name Service,
94 (instance number suffix added to the registered name)
95 \return a loaded component
97 Engines::EngineComponent create_component_instance(in string componentName);
99 //! Create a new Python servant instance of a generic service.
101 This simply loads the service in the current container by importing the
102 corresponding Python module.
103 Warning: no internal registration is done, so it is up to the caller to
104 manage the various instantiation.
105 \param serviceName Name of the service
106 \param reason in case of error (return void string) a string explaining the error
107 \return the IOR of the loaded service.
109 string create_python_service_instance(in string serviceName,
112 //! Create a new servant instance of a component with environment variables specified.
114 Component library must be loaded.
115 \param componentName Name of the component which will be registered
116 in Registry and Name Service,
117 (instance number suffix added to the registered name)
118 \param env a dict of env variables
119 \param reason in case of error (return nil) a string explaining the error
120 \return a loaded component
122 Engines::EngineComponent create_component_instance_env(in string componentName,
125 //! Find a servant instance of a component
127 \param registeredName Name of the component in Registry or Name Service,
128 without instance suffix number
129 \return the first instance found
131 EngineComponent find_component_instance(in string registeredName);
133 //! Find a servant instance of a component, or create a new one.
135 Loads the component library if needed.
136 Only applicable to multiStudy components.
137 \param nameToRegister Name of the component which will be registered
138 in Registry (or Name Service)
139 \param componentName Name of the constructed library of the %component
140 (not used any more, give empty string)
141 \return a loaded component
143 EngineComponent load_impl(in string nameToRegister,
144 in string componentName);
146 //! Remove the component servant, and deletes all related objects
148 \param component_i Component to be removed
150 void remove_impl(in EngineComponent component_i);
152 //! In case of SSL mode Returns entry to Embedded NS
153 EmbeddedNamingService get_embedded_NS_if_ssl();
155 //! Unload component libraries from the container.
156 void finalize_removal() ;
158 //! Determines whether the server has been loaded or not.
161 //! Name of the %container
162 readonly attribute string name ;
164 //! working directory of the %container
165 readonly attribute string workingdir ;
167 //! name of the %container log file (this has been set by the launcher)
168 attribute string logfilename ;
170 //! Shutdown the Container process.
173 //! Returns the hostname of the container
174 string getHostName();
176 //! Returns the PID of the container
179 //! Kill the container
181 Returns True if the %container has been killed.
182 Kept for Superv compilation but can't work, unless oneway...
185 boolean Kill_impl() ;
189 returns a fileRef object if origFileName exists and is readable
190 else returns null object. Only one fileRef is created for a given
191 file name, so, several calls with the same file name returns the
194 fileRef createFileRef(in string origFileName);
196 //! Create a Salome_file
198 returns a Salome_file object if origFileName exists and is readable
199 else returns null object.
201 \param origFileName name of the file to be managed (can contain the path).
203 \return Salome_file CORBA reference.
205 Salome_file createSalome_file(in string origFileName);
207 //! Create a fileTransfer
209 returns a fileTransfer object used to copy files from the container
210 machine to the clients machines. Only one fileTransfer instance is
211 created in a container.
213 fileTransfer getFileTransfer();
215 //! Copy a file from a remote host (container) to a local file
217 \param contai the remote container
218 \param remoteFile the file on the remote host to copy
219 \param localFile the local file to create by copy
221 void copyFile(in Container contai, in string remoteFile, in string localFile);
223 //! Create a PyNode in the container
225 \param nodeName the name of the PyNode
226 \param code python code as text to load in the node
228 PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
230 //! Retrieves the last created PyNode instance with createPyNode.
231 PyNode getDefaultPyNode(in string nodeName);
233 //! Create a PyScriptNode in the container
235 \param nodeName the name of the PyScriptNode
236 \param code python code as text to load in the node
238 PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
240 void removePyScriptNode(in string nodeName) raises(SALOME::SALOME_Exception);
242 //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
243 PyScriptNode getDefaultPyScriptNode(in string nodeName);
245 //! This method remove all refs of PyScriptNode servant objects stored in server.
247 * Previous scripts created on container may have been stored in a map. This method removes them. It then clean all the contexts dict attached to them.
249 void cleanAllPyScripts();
252 /*! \brief Interface of the %component.
253 This interface is used for interaction between the %container and the
254 %component and between the components inside the container.
256 interface EngineComponent
258 //! The name of the instance of the %Component
259 readonly attribute string instanceName ;
261 //! The name of the interface of the %Component
262 readonly attribute string interfaceName ;
264 //! Determines whether the server has already been loaded or not.
267 //! Remove component instance from container
269 Deactivates the %Component.
270 -- TO BE USED BY CONTAINER ONLY (Container housekeeping) --
271 use remove_impl from Container instead !
275 //! Returns the container that the %Component refers to.
276 Container GetContainerRef() ;
278 //! Set component instance properties
280 Gives a sequence of (key=string,value=any) to the component.
281 Base class component stores the sequence in a map.
282 The map is cleared before.
283 This map is for use by derived classes.
285 void setProperties(in FieldsDict dico);
287 //! Get component instance properties
289 returns a previously stored map (key=string,value=any) as a sequence.
290 See setProperties(in FieldsDict dico).
292 FieldsDict getProperties();
294 //! Set an option value
296 This method is to set an option specific to a certain EngineComponent.
298 void SetOption(in string optionName, in string value);
300 //! Return an option value
302 This method is to get value of an option specific to a certain EngineComponent.
304 string GetOption(in string optionName);
306 //! Set name of a node in a graph (for %SUPERVISOR use)
308 This method is used by the %SUPERVISOR component. It sets the names of
309 the graph and of the node.
310 \param aGraphName Name of graph
311 \param aNodeName Name of node
313 void Names( in string aGraphName , in string aNodeName ) ;
315 //! Kill the component (if you can)
317 Returns True if the %Component has been killed.
319 boolean Kill_impl() ;
321 //! Stop the component (if you can)
323 Returns True if the activity of the %Component has been stopped.
324 (It's action can't be resumed)
326 boolean Stop_impl() ;
328 //! Suspend the component
330 Returns True if the activity of the %Component has been suspended.
331 (It's action can be resumed)
333 boolean Suspend_impl() ;
335 //! Resume the component
337 Returns True if the activity of the %Component has been resumed.
339 boolean Resume_impl() ;
345 long CpuUsed_impl() ;
347 //! Get a python dump
349 Returns a python script, which is being played back reproduces
350 the data model of component
352 TMPFile DumpPython(in boolean isPublished,
353 in boolean isMultiFile,
354 out boolean isValidScript);
357 //! Returns a CORBA Ref of a input Salome_file managed by a service.
360 \param service_name service's name.
361 \param file_name name of the requested file.
363 \return CORBA Ref of the requested file.
365 \exception contains information of what if the component cannot
366 sends the file's reference.
368 Engines::Salome_file getInputFileToService(in string service_name,
369 in string Salome_file_name) raises(SALOME::SALOME_Exception);
371 //! Check service input files (transfer them if needed)
373 This method is used before the activation of the service. It calls
374 recvFiles() on all the input Salome_file files of the service.
376 Before each recvFiles(), it uses the callback method named configureSalome_file.
377 This method allows the user to configure the files managed by the Salome_file.
379 By default, there is no files managed when a Salome_file is created,
380 but the supervisor set some files managed by the Salome_file from the information contained
381 into the schema file.
383 \param service_name service's name.
385 \exception contains information about files that are not in a good state.
387 void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
389 //! This method adds a input Salome_file to a service of the component.
392 \param service_name service's name.
393 \param Salome_file_name name of the Salome_file
395 \return a reference of the Salome_file
397 \exception raises an exception if there is already
398 a Salome_file with this name for the service.
400 Engines::Salome_file setInputFileToService(in string service_name,
401 in string Salome_file_name) raises(SALOME::SALOME_Exception);
403 //! Returns a CORBA Ref of a output Salome_file managed by a service.
406 \param service_name service's name.
407 \param file_name name of the requested file.
409 \return CORBA Ref of the requested file.
411 \exception contains information of what if the component cannot
412 sends the file's reference.
414 Engines::Salome_file getOutputFileToService(in string service_name,
415 in string Salome_file_name) raises(SALOME::SALOME_Exception);
417 //! Check service output files (transfer them if needed)
419 This method is used at the end of the service. It calls
420 recvFiles() on all the output Salome_file files of the service.
422 Before each recvFiles(), it uses the callback method named configureSalome_file.
423 This method allows the user to configure the files managed by the Salome_file.
425 By default, there is no files managed when a Salome_file is created,
426 but the supervisor set some files managed by the Salome_file from the information contained
427 into the schema file.
429 \param service_name service's name.
431 \exception contains information about files that are not in a good state.
433 void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
435 //! This method adds an output Salome_file to a service of the component.
438 \param service_name service's name.
439 \param Salome_file_name name of the Salome_file
441 \return a reference of the Salome_file
443 \exception raises an exception if there is already
444 a Salome_file with this name for the service.
446 Engines::Salome_file setOutputFileToService(in string service_name,
447 in string Salome_file_name) raises(SALOME::SALOME_Exception);
449 //! Indicate if the component instance provides custom information about its objects.
451 Returns true if the component provides custom information about its objects, false otherwise.
452 Should be redefined in the certain component to return true in case of this
453 component provides such information.
455 boolean hasObjectInfo();
457 //! Get custom information about the given object.
459 This method is used to get the custom information about the given object.
460 Should be redefined in the certain component in case of this
461 component provides such information.
462 It is worth using this method only if hasObjectInfo() method returns true.
464 \param entry object's entry.
466 \return an information about the given object.
468 string getObjectInfo(in string entry);
470 //! Get version of the component
472 This method is supposed to be implemented in all derived classes; default implementation
473 returns "unknown" string that means that no version information about the component is available.
474 \note The version of the component is stored to the study, as a part of general persistence
475 mechanism; once stored, version information in the study cannot be changed.
477 \return string containing component's version, e.g. "1.0"
483 \brief Base interface of the %component that supports exporting data.
485 interface ImportableComponent
487 /*! \brief Get a list of supported formats */
488 SALOME::StringSeq GetImportableFormats();
489 boolean ImportDataAs(in string format, in SALOME::GenericObj exporter);
492 //! A block of binary data used for file transfer. The maximum size of the block is defined on server side.
493 typedef sequence<octet> fileBlock;
495 /*! \brief Interface of fileTransfer.
496 The fileTransfer and fileRef interfaces provide a file transfer service
497 between different computers.
499 interface fileTransfer : SALOME::GenericObj
501 //! Open the file transfer
503 open method returns a key (fileId) that identifies the structure
504 (ex: C FILE), associated to the original file on the server.
505 The structure is created by a container for transfer of files availables
506 on the computer which runs the container.
507 Each open gives a unique fileId, to allow concurrent reads of the same
510 long open(in string fileName);
511 //! Open the file transfer in write mode for file fileName
513 \param fileName the file to copy into with putBlock
514 \return the id to use with putBlock
516 long openW(in string fileName);
518 //! Close the file transfer
520 when the file transfer is finished, close method releases structures
521 created by open method, identified by fileId.
523 void close(in long fileId);
525 //! Get a file data block
527 Get successive blocks of octets from the original file.
528 The last block is empty, and identifies the end of file.
530 fileBlock getBlock(in long fileId);
532 //! Put a file data block
534 \param fileId identification of the file obtained by openW
535 \param block a data block to copy into the file identified by fileId
537 void putBlock(in long fileId, in fileBlock block);
541 //! A file managed by a Salome_file.
548 string source_file_name;
549 //! status ("present" or "notpresent")
552 Engines::Container container;
555 //! A sequence of Engines::file.
556 typedef sequence<Engines::file> files;
559 //! The state of a Salome_file.
563 //! hdf5 file where the file can be saved
564 string hdf5_file_name;
565 //! number of files managed
566 long number_of_files;
567 //! information if all the files are received
572 /*! \brief Interface of a Salome_file managed
573 This file is independent of a Salome module. It can managed one or more
574 real files. It's useful for parallel files. Currently Salome_file cannot manage
575 two files that have the same name but not the same path.
577 interface Salome_file : Engines::fileTransfer
579 //! Load a Salome_file from a hdf5 file.
582 \param hdf5_file name (with path) of the hdf5_file.
584 \exception contains information of errors if the loading doesn't succeed.
586 void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
588 //! Save a Salome_file into a hdf5_file.
591 \param hdf5_file name (with path) of the hdf5_file.
593 \exception contains information of errors if the save doesn't succeed.
596 void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
598 //! Save a Salome_file into a hdf5_file.
600 All files that are managed are saved into the hdf5_file
602 \param hdf5_file name (with path) of the hdf5_file.
604 \exception contains information of errors if the save doesn't succeed.
607 void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
611 //! Add a Local file to the Salome_file.
614 \param file_name name of the file with the path.
616 \exception raised if the file is already added into the Salome_file.
618 void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
620 //! Add a Distributed file to the Salome_file.
623 \param comp_file_name name of the file with the path.
625 \exception raised if the file is already added into the Salome_file.
627 void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
629 //! Connect a Salome_file with another Salome_file.
631 It works only if the Salome_file managed only one file
633 \param source_Salome_file Salome_file that managed the distributed version of the file.
635 \exception raised if there is more or less than one file.
637 void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
639 //! Connect the managed file file_name to a Salome_file.
642 \param file_name name of the file without the path.
643 \param source_Salome_file Salome_file that managed the distributed version of the file.
645 \exception raised if the file doesn't exist.
647 void connectDistributedFile(in string file_name,
648 in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
650 //! Connect the file_name with a Distributed file_name.
653 \param file_name name of the file without the path.
654 \param source_file_name It's the name of the file managed by the distributed source Salome_file.
656 \exception raised if the file doesn't exist.
658 void setDistributedSourceFile(in string file_name,
659 in string source_file_name) raises (SALOME::SALOME_Exception);
663 //! Get all the distributed files managed by the Salome_file and check all the local files.
666 \exception raised if some of the files are not ok.
668 void recvFiles() raises (SALOME::SALOME_Exception) ;
672 //! Remove a file of the Salome_file.
675 \param file_name name of the file.
677 \exception raised if the file doesn't exist.
679 void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
681 //! Remove all the files of the Salome_file.
686 //! Get the list of the files managed by the Salome_file.
688 The list can be empty.
690 Engines::files getFilesInfos();
692 //! Get a file managed by the Salome_file.
695 \param file_name the name of the file.
697 \return CORBA file reference.
699 \exception raised if the file doesn't exist.
701 Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
703 //! Return the state of the Salome_file.
704 Engines::SfState getSalome_fileState();
707 //! Set the container where files are.
710 \param container container CORBA's reference.
712 void setContainer(in Engines::Container container);
715 /*! \brief Interface of fileRef.
716 The fileTransfer and fileRef interfaces provide a file transfer service
717 between different computers.
719 A fileRef object is associated to an original file (origFileName) on a
720 machine (refMachine).
721 It is created by a container (factoryServer) on refMachine,
722 with createFileRef(in string origFileName) method.
723 The fileRef object maintains a list of (machine,filename) for copies.
724 If a copy exists on myMachine, getRef(myMachine) returns the file name
725 of the copy on myMachine, else returns empty string.
726 If there is no copy on myMachine, method getFileTransfer() from container
727 factoryServer on refMachine provides a fileTransfer object dedicated to
729 After the copy, addRef(myMachine, localFileNameOnMyMachine) registers
730 the file name of the copy on myMachine.
734 //! the original file
735 readonly attribute string origFileName;
736 //! the machine of the original file
737 readonly attribute string refMachine;
739 Container getContainer();
741 boolean addRef(in string machine,
744 string getRef(in string machine);