00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef __IOMANAGER_HH__
00049 #define __IOMANAGER_HH__
00050
00051
00052
00053
00054
00055
00056 #include <iostream>
00057 #include <sstream>
00058 #include <string>
00059 #include <set>
00060
00061
00062 #include <OpenMesh/Core/System/config.h>
00063 #include <OpenMesh/Core/IO/Options.hh>
00064 #include <OpenMesh/Core/IO/reader/BaseReader.hh>
00065 #include <OpenMesh/Core/IO/writer/BaseWriter.hh>
00066 #include <OpenMesh/Core/IO/importer/BaseImporter.hh>
00067 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
00068 #include <OpenMesh/Core/Utils/SingletonT.hh>
00069
00070
00071
00072
00073
00074 namespace OpenMesh {
00075 namespace IO {
00076
00077
00078
00079
00080
00100 class _IOManager_
00101 {
00102 private:
00103
00104 _IOManager_() {}
00105 friend _IOManager_& IOManager();
00106
00107
00108 public:
00109
00110
00117 bool read(const std::string& _filename,
00118 BaseImporter& _bi,
00119 Options& _opt);
00120
00127 bool read(std::istream& _filename,
00128 const std::string& _ext,
00129 BaseImporter& _bi,
00130 Options& _opt);
00131
00132
00139 bool write(const std::string& _filename,
00140 BaseExporter& _be,
00141 Options _opt=Options::Default);
00142
00149 bool write(std::ostream& _filename,
00150 const std::string& _ext,
00151 BaseExporter& _be,
00152 Options _opt=Options::Default);
00153
00154
00156 bool can_read( const std::string& _format ) const;
00157
00159 bool can_write( const std::string& _format ) const;
00160
00161
00162 size_t binary_size(const std::string& _format,
00163 BaseExporter& _be,
00164 Options _opt = Options::Default)
00165 {
00166 const BaseWriter *bw = find_writer(_format);
00167 return bw ? bw->binary_size(_be,_opt) : 0;
00168 }
00169
00170
00171
00172 public:
00173
00174
00179 const std::string& qt_read_filters() const { return read_filters_; }
00180
00181
00186 const std::string& qt_write_filters() const { return write_filters_; }
00187
00188
00189
00190 private:
00191
00192
00193 void update_read_filters();
00194
00195
00196
00197 void update_write_filters();
00198
00199
00200
00201 public:
00202
00203
00207 bool register_module(BaseReader* _bl)
00208 {
00209 reader_modules_.insert(_bl);
00210 update_read_filters();
00211 return true;
00212 }
00213
00214
00215
00219 bool register_module(BaseWriter* _bw)
00220 {
00221 writer_modules_.insert(_bw);
00222 update_write_filters();
00223 return true;
00224 }
00225
00226
00227 private:
00228
00229 const BaseWriter *find_writer(const std::string& _format);
00230
00231
00232 std::set<BaseReader*> reader_modules_;
00233
00234
00235 std::set<BaseWriter*> writer_modules_;
00236
00237
00238 std::string read_filters_;
00239
00240
00241 std::string write_filters_;
00242 };
00243
00244
00245
00246
00247
00248 extern _IOManager_* __IOManager_instance;
00249
00250 _IOManager_& IOManager();
00251
00252
00253
00254
00255 }
00256 }
00257
00258 #endif
00259