1 // Copyright (C) 2007-2008 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.
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 #include "Salome_file_i.hxx"
26 #include "HDFascii.hxx"
31 void print_infos(Engines::file*);
32 void print_state(Engines::SfState*);
34 void print_infos(Engines::file * infos)
36 cerr << "-------------------------------------------------------------------" << endl;
37 cerr << "file_name = " << infos->file_name << endl;
38 cerr << "path = " << infos->path << endl;
39 cerr << "type = " << infos->type << endl;
40 cerr << "source_file_name = " << infos->source_file_name << endl;
41 cerr << "status = " << infos->status << endl;
44 void print_state(Engines::SfState * state)
46 cerr << "-------------------------------------------------------------------" << endl;
47 cerr << "name = " << state->name << endl;
48 cerr << "hdf5_file_name = " << state->hdf5_file_name << endl;
49 cerr << "number_of_files = " << state->number_of_files << endl;
50 cerr << "files_ok = " << state->files_ok << endl;
54 int main (int argc, char * argv[])
56 system("rm toto cat test.hdf test2.hdf");
63 Engines::file * infos;
64 Engines::SfState * state;
65 Engines::files * all_infos;
66 PortableServer::POA_var root_poa;
67 PortableServer::POAManager_var pman;
68 CORBA::Object_var obj;
70 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
71 cerr << "Test of setLocalFile()" << endl;
72 file.setLocalFile("/tmp/toto");
73 infos = file.getFileInfos("toto");
77 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
78 cerr << "Test of getFilesInfos()" << endl;
79 all_infos = file.getFilesInfos();
80 for (int i = 0; i < all_infos->length(); i++)
82 print_infos(&((*all_infos)[i]));
85 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
86 cerr << "Test of getSalome_fileState()" << endl;
87 state = file.getSalome_fileState();
91 CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv);
92 obj = orb->resolve_initial_references("RootPOA");
93 root_poa = PortableServer::POA::_narrow(obj);
94 pman = root_poa->the_POAManager();
97 file2.setLocalFile("/tmp/toto_distributed_source");
98 Engines::Salome_file_ptr file2_ref = file2._this();
100 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
101 cerr << "Test of setDistributedFile()" << endl;
102 file.setDistributedFile("/tmp/toto_distributed");
103 file.connectDistributedFile("toto_distributed", file2_ref);
104 // file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
105 infos = file.getFileInfos("toto_distributed");
108 // We create the files ...
109 std::ostringstream oss;
111 std::ofstream f(oss.str().c_str());
113 f << "blablabla" << std::endl;
115 std::ostringstream oss2;
116 oss2 << "/tmp/toto_distributed_source";
117 std::ofstream f2(oss2.str().c_str());
119 f2 << "bliblibli" << std::endl;
125 catch (SALOME::SALOME_Exception & e)
127 cerr << "Exception : " << e.details.text << endl;
130 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
131 cerr << "Test of getFilesInfos()" << endl;
132 all_infos = file.getFilesInfos();
133 for (int i = 0; i < all_infos->length(); i++)
135 print_infos(&((*all_infos)[i]));
138 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
139 cerr << "Test of getSalome_fileState()" << endl;
140 state = file.getSalome_fileState();
145 file3.setLocalFile("/tmp/toto");
146 file3.setLocalFile("/bin/cat");
147 state = file3.getSalome_fileState();
149 file3.save_all("test.hdf");
150 file3.setLocalFile("/bin/tutu");
151 file3.save("test2.hdf");
153 file4.load("test.hdf");
154 all_infos = file4.getFilesInfos();
155 for (int i = 0; i < all_infos->length(); i++)
157 print_infos(&((*all_infos)[i]));
159 state = file4.getSalome_fileState();
161 file5.load("test2.hdf");
162 all_infos = file5.getFilesInfos();
163 for (int i = 0; i < all_infos->length(); i++)
165 print_infos(&((*all_infos)[i]));
167 state = file5.getSalome_fileState();
170 // Test of ConvertFromHDFToASCII
171 // and ConvertFromASCIIToHDF
172 cerr << "Test of ConvertFromASCIIToHDF" << endl;
173 HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
174 cerr << "Test of ConvertFromHDFToASCII" << endl;
175 cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << endl;
176 cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << endl;
178 cerr << "End of tests" << endl;