1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, 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"
24 #include "HDFascii.hxx"
27 void print_infos(Engines::file*);
28 void print_state(Engines::SfState*);
30 void print_infos(Engines::file * infos)
32 std::cerr << "-------------------------------------------------------------------" << std::endl;
33 std::cerr << "file_name = " << infos->file_name << std::endl;
34 std::cerr << "path = " << infos->path << std::endl;
35 std::cerr << "type = " << infos->type << std::endl;
36 std::cerr << "source_file_name = " << infos->source_file_name << std::endl;
37 std::cerr << "status = " << infos->status << std::endl;
40 void print_state(Engines::SfState * state)
42 std::cerr << "-------------------------------------------------------------------" << std::endl;
43 std::cerr << "name = " << state->name << std::endl;
44 std::cerr << "hdf5_file_name = " << state->hdf5_file_name << std::endl;
45 std::cerr << "number_of_files = " << state->number_of_files << std::endl;
46 std::cerr << "files_ok = " << state->files_ok << std::endl;
50 int main (int argc, char * argv[])
52 system("rm toto cat test.hdf test2.hdf");
59 Engines::file * infos;
60 Engines::SfState * state;
61 Engines::files * all_infos;
62 PortableServer::POA_var root_poa;
63 PortableServer::POAManager_var pman;
64 CORBA::Object_var obj;
66 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
67 std::cerr << "Test of setLocalFile()" << std::endl;
68 file.setLocalFile("/tmp/toto");
69 infos = file.getFileInfos("toto");
73 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
74 std::cerr << "Test of getFilesInfos()" << std::endl;
75 all_infos = file.getFilesInfos();
76 for (int i = 0; i < all_infos->length(); i++)
78 print_infos(&((*all_infos)[i]));
81 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
82 std::cerr << "Test of getSalome_fileState()" << std::endl;
83 state = file.getSalome_fileState();
87 CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv);
88 obj = orb->resolve_initial_references("RootPOA");
89 root_poa = PortableServer::POA::_narrow(obj);
90 pman = root_poa->the_POAManager();
93 file2.setLocalFile("/tmp/toto_distributed_source");
94 Engines::Salome_file_ptr file2_ref = file2._this();
96 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
97 std::cerr << "Test of setDistributedFile()" << std::endl;
98 file.setDistributedFile("/tmp/toto_distributed");
99 file.connectDistributedFile("toto_distributed", file2_ref);
100 // file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
101 infos = file.getFileInfos("toto_distributed");
104 // We create the files ...
105 std::ostringstream oss;
107 std::ofstream f(oss.str().c_str());
109 f << "blablabla" << std::endl;
111 std::ostringstream oss2;
112 oss2 << "/tmp/toto_distributed_source";
113 std::ofstream f2(oss2.str().c_str());
115 f2 << "bliblibli" << std::endl;
121 catch (SALOME::SALOME_Exception & e)
123 std::cerr << "Exception : " << e.details.text << std::endl;
126 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
127 std::cerr << "Test of getFilesInfos()" << std::endl;
128 all_infos = file.getFilesInfos();
129 for (int i = 0; i < all_infos->length(); i++)
131 print_infos(&((*all_infos)[i]));
134 std::cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
135 std::cerr << "Test of getSalome_fileState()" << std::endl;
136 state = file.getSalome_fileState();
141 file3.setLocalFile("/tmp/toto");
142 file3.setLocalFile("/bin/cat");
143 state = file3.getSalome_fileState();
145 file3.save_all("test.hdf");
146 file3.setLocalFile("/bin/tutu");
147 file3.save("test2.hdf");
149 file4.load("test.hdf");
150 all_infos = file4.getFilesInfos();
151 for (int i = 0; i < all_infos->length(); i++)
153 print_infos(&((*all_infos)[i]));
155 state = file4.getSalome_fileState();
157 file5.load("test2.hdf");
158 all_infos = file5.getFilesInfos();
159 for (int i = 0; i < all_infos->length(); i++)
161 print_infos(&((*all_infos)[i]));
163 state = file5.getSalome_fileState();
166 // Test of ConvertFromHDFToASCII
167 // and ConvertFromASCIIToHDF
168 std::cerr << "Test of ConvertFromASCIIToHDF" << std::endl;
169 HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
170 std::cerr << "Test of ConvertFromHDFToASCII" << std::endl;
171 std::cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << std::endl;
172 std::cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << std::endl;
174 std::cerr << "End of tests" << std::endl;