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 * infos)
33 cerr << "-------------------------------------------------------------------" << endl;
34 cerr << "file_name = " << infos->file_name << endl;
35 cerr << "path = " << infos->path << endl;
36 cerr << "type = " << infos->type << endl;
37 cerr << "source_file_name = " << infos->source_file_name << endl;
38 cerr << "status = " << infos->status << endl;
41 void print_state(Engines::SfState * state)
43 cerr << "-------------------------------------------------------------------" << endl;
44 cerr << "name = " << state->name << endl;
45 cerr << "hdf5_file_name = " << state->hdf5_file_name << endl;
46 cerr << "number_of_files = " << state->number_of_files << endl;
47 cerr << "files_ok = " << state->files_ok << endl;
51 int main (int argc, char * argv[])
53 system("rm toto cat test.hdf test2.hdf");
60 Engines::file * infos;
61 Engines::SfState * state;
62 Engines::files * all_infos;
63 PortableServer::POA_var root_poa;
64 PortableServer::POAManager_var pman;
65 CORBA::Object_var obj;
67 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
68 cerr << "Test of setLocalFile()" << endl;
69 file.setLocalFile("/tmp/toto");
70 infos = file.getFileInfos("toto");
74 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
75 cerr << "Test of getFilesInfos()" << endl;
76 all_infos = file.getFilesInfos();
77 for (int i = 0; i < all_infos->length(); i++)
79 print_infos(&((*all_infos)[i]));
82 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
83 cerr << "Test of getSalome_fileState()" << endl;
84 state = file.getSalome_fileState();
88 CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv);
89 obj = orb->resolve_initial_references("RootPOA");
90 root_poa = PortableServer::POA::_narrow(obj);
91 pman = root_poa->the_POAManager();
94 file2.setLocalFile("/tmp/toto_distributed_source");
95 Engines::Salome_file_ptr file2_ref = file2._this();
97 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
98 cerr << "Test of setDistributedFile()" << endl;
99 file.setDistributedFile("/tmp/toto_distributed");
100 file.connectDistributedFile("toto_distributed", file2_ref);
101 // file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
102 infos = file.getFileInfos("toto_distributed");
105 // We create the files ...
106 std::ostringstream oss;
108 std::ofstream f(oss.str().c_str());
110 f << "blablabla" << std::endl;
112 std::ostringstream oss2;
113 oss2 << "/tmp/toto_distributed_source";
114 std::ofstream f2(oss2.str().c_str());
116 f2 << "bliblibli" << std::endl;
122 catch (SALOME::SALOME_Exception & e)
124 cerr << "Exception : " << e.details.text << endl;
127 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
128 cerr << "Test of getFilesInfos()" << endl;
129 all_infos = file.getFilesInfos();
130 for (int i = 0; i < all_infos->length(); i++)
132 print_infos(&((*all_infos)[i]));
135 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
136 cerr << "Test of getSalome_fileState()" << endl;
137 state = file.getSalome_fileState();
142 file3.setLocalFile("/tmp/toto");
143 file3.setLocalFile("/bin/cat");
144 state = file3.getSalome_fileState();
146 file3.save_all("test.hdf");
147 file3.setLocalFile("/bin/tutu");
148 file3.save("test2.hdf");
150 file4.load("test.hdf");
151 all_infos = file4.getFilesInfos();
152 for (int i = 0; i < all_infos->length(); i++)
154 print_infos(&((*all_infos)[i]));
156 state = file4.getSalome_fileState();
158 file5.load("test2.hdf");
159 all_infos = file5.getFilesInfos();
160 for (int i = 0; i < all_infos->length(); i++)
162 print_infos(&((*all_infos)[i]));
164 state = file5.getSalome_fileState();
167 // Test of ConvertFromHDFToASCII
168 // and ConvertFromASCIIToHDF
169 cerr << "Test of ConvertFromASCIIToHDF" << endl;
170 HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
171 cerr << "Test of ConvertFromHDFToASCII" << endl;
172 cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << endl;
173 cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << endl;
175 cerr << "End of tests" << endl;