Version: 9.12.0

This page introduces the Salome_file feature.

Salome_file is based on the SALOME_FileTransfer. It extends it to enable a higher model for managing files into SALOME applications.


Salome_file is a CORBA object. It's role is to managed many system files. When a Salome_file is created, no files are managed. Then, files are added using Salome_file_i interface. A file is represented by a name and a path.

There is two different cases when a file is added :

  • Local file : the file added exists or it will be created by the user with the path and the name used in its registration.
  • Distributed file : the file added exists into a distributed localization.

To be able to get a distributed file, the Salome_file has to be connected with an another Salome_file that managed this file. This distributed Salome_file could be located into a distributed resource.

Simple example

This section shows a simple example of the use of Salome_file. The objective is to create two Salome_file; one is managing a local file, the other is managing a distributed file. Then, these Salome_files are connected to enable the copy of the real file gbetween the two Salome_files.

Firstly, two Salome_files are created :

int main (int argc, char * argv[])
Salome_file_i file_source;
Salome_file_i file_dest;
int main()
Definition: BasicMainTest.hxx:27
A class to manage file transfer in SALOME.
Definition: Salome_file_i.hxx:42

Secondly, the real files are registered into the Salome_files.

virtual void setLocalFile(const char *comp_file_name)
CORBA method.
Definition: Salome_file_i.cxx:494
virtual void setDistributedFile(const char *comp_file_name)
CORBA method.
Definition: Salome_file_i.cxx:556

Thirdly, we connect the destination file with the source file :

virtual void connect(Engines::Salome_file_ptr source_Salome_file)
CORBA method.
Definition: Salome_file_i.cxx:619

Finally, the file is sended using Salome_file interface.

// Status check
state = file_dest.getSalome_fileState();
print_state(state); // You have to implement this function.
void print_state(Engines::SfState *)
Definition: TestSalome_file.cxx:42
virtual Engines::SfState * getSalome_fileState()
CORBA method.
Definition: Salome_file_i.cxx:956
virtual void recvFiles()
CORBA method.
Definition: Salome_file_i.cxx:725

Advanced example

This advanced example illustrates a part of the Salome_file API dedicated for situations where multiple files are managed.

This is the situation :

int main (int argc, char * argv[])
Salome_file_i file_source_a;
Salome_file_i file_source_b;
Salome_file_i file_dest;

There is two problems in this case.

The first problem is in the file_dest Salome_file, there is two files. If the method connect is used, the Salome_file cannot know if the reference is for cat_copy or echo_copy. Indeed echo_copy could be provided by another Salome_file that for cat_copy.

The second problem comes from the two files of file_source_a Salome_file. Indeed when connect is used, there is no information about the choice of the source file into the source Salome_file. For cat_copy, did the used want cat or echo ?

To avoid these cases, Salome_file API provides advanced methods :

file_dest.connectDistributedFile("cat_copy", file_source_a);
file_dest.setDistributedSourceFile("cat_copy", "cat");
file_dest.connectDistributedFile("cat_echo", file_source_b);
file_dest.setDistributedSourceFile("cat_echo", "echo");
// Status check
state = file_dest.getSalome_fileState();
print_state(state); // You have to implement this function.
virtual void setDistributedSourceFile(const char *file_name, const char *source_file_name)
CORBA method.
Definition: Salome_file_i.cxx:697
virtual void connectDistributedFile(const char *file_name, Engines::Salome_file_ptr source_Salome_file)
CORBA method.
Definition: Salome_file_i.cxx:671