1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "Salome_file_i.hxx"
21 #include "ArgvKeeper.hxx"
26 #include "HDFascii.hxx"
29 void print_infos(Engines::file*);
30 void print_state(Engines::SfState*);
32 void print_infos(Engines::file * infos)
34 std::cerr << "-------------------------------------------------------------------" << std::endl;
35 std::cerr << "file_name = " << infos->file_name << std::endl;
36 std::cerr << "path = " << infos->path << std::endl;
37 std::cerr << "type = " << infos->type << std::endl;
38 std::cerr << "source_file_name = " << infos->source_file_name << std::endl;
39 std::cerr << "status = " << infos->status << std::endl;
42 void print_state(Engines::SfState * state)
44 std::cerr << "-------------------------------------------------------------------" << std::endl;
45 std::cerr << "name = " << state->name << std::endl;
46 std::cerr << "hdf5_file_name = " << state->hdf5_file_name << std::endl;
47 std::cerr << "number_of_files = " << state->number_of_files << std::endl;
48 std::cerr << "files_ok = " << state->files_ok << std::endl;
52 int main (int argc, char * argv[])
54 system("rm toto cat test.hdf test2.hdf");
61 Engines::file * infos;
62 Engines::SfState * state;
63 Engines::files * all_infos;
64 PortableServer::POA_var root_poa;
65 PortableServer::POAManager_var pman;
66 CORBA::Object_var obj;
68 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
69 std::cerr << "Test of setLocalFile()" << std::endl;
70 file.setLocalFile("/tmp/toto");
71 infos = file.getFileInfos("toto");
75 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
76 std::cerr << "Test of getFilesInfos()" << std::endl;
77 all_infos = file.getFilesInfos();
78 for (int i = 0; i < (int)all_infos->length(); i++)
80 print_infos(&((*all_infos)[i]));
83 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
84 std::cerr << "Test of getSalome_fileState()" << std::endl;
85 state = file.getSalome_fileState();
89 SetArgcArgv(argc, argv);
90 CORBA::ORB_ptr orb = KERNEL::GetRefToORB();
91 obj = orb->resolve_initial_references("RootPOA");
92 root_poa = PortableServer::POA::_narrow(obj);
93 pman = root_poa->the_POAManager();
96 file2.setLocalFile("/tmp/toto_distributed_source");
97 Engines::Salome_file_ptr file2_ref = file2._this();
99 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
100 std::cerr << "Test of setDistributedFile()" << std::endl;
101 file.setDistributedFile("/tmp/toto_distributed");
102 file.connectDistributedFile("toto_distributed", file2_ref);
103 // file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
104 infos = file.getFileInfos("toto_distributed");
107 // We create the files ...
108 std::ostringstream oss;
110 std::ofstream f(oss.str().c_str());
112 f << "blablabla" << std::endl;
114 std::ostringstream oss2;
115 oss2 << "/tmp/toto_distributed_source";
116 std::ofstream f2(oss2.str().c_str());
118 f2 << "bliblibli" << std::endl;
124 catch (SALOME::SALOME_Exception & e)
126 std::cerr << "Exception : " << e.details.text << std::endl;
129 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
130 std::cerr << "Test of getFilesInfos()" << std::endl;
131 all_infos = file.getFilesInfos();
132 for (int i = 0; i < (int)all_infos->length(); i++)
134 print_infos(&((*all_infos)[i]));
137 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
138 std::cerr << "Test of getSalome_fileState()" << std::endl;
139 state = file.getSalome_fileState();
144 file3.setLocalFile("/tmp/toto");
145 file3.setLocalFile("/bin/cat");
146 state = file3.getSalome_fileState();
148 file3.save_all("test.hdf");
149 file3.setLocalFile("/bin/tutu");
150 file3.save("test2.hdf");
152 file4.load("test.hdf");
153 all_infos = file4.getFilesInfos();
154 for (int i = 0; i < (int)all_infos->length(); i++)
156 print_infos(&((*all_infos)[i]));
158 state = file4.getSalome_fileState();
160 file5.load("test2.hdf");
161 all_infos = file5.getFilesInfos();
162 for (int i = 0; i < (int)all_infos->length(); i++)
164 print_infos(&((*all_infos)[i]));
166 state = file5.getSalome_fileState();
169 // Test of ConvertFromHDFToASCII
170 // and ConvertFromASCIIToHDF
171 std::cerr << "Test of ConvertFromASCIIToHDF" << std::endl;
172 HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
173 std::cerr << "Test of ConvertFromHDFToASCII" << std::endl;
174 std::cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << std::endl;
175 std::cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << std::endl;
177 std::cerr << "End of tests" << std::endl;