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 #ifndef __IOMANAGER_HH__
00034 #define __IOMANAGER_HH__
00035
00036
00037
00038
00039
00040
00041 #include <iostream>
00042 #include <sstream>
00043 #include <string>
00044 #include <set>
00045
00046
00047 #include <OpenMesh/Core/System/config.h>
00048 #include <OpenMesh/Core/IO/Options.hh>
00049 #include <OpenMesh/Core/IO/reader/BaseReader.hh>
00050 #include <OpenMesh/Core/IO/writer/BaseWriter.hh>
00051 #include <OpenMesh/Core/IO/importer/BaseImporter.hh>
00052 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
00053 #include <OpenMesh/Core/Utils/SingletonT.hh>
00054
00055
00056
00057
00058
00059 namespace OpenMesh {
00060 namespace IO {
00061
00062
00063
00064
00065
00085 class _IOManager_
00086 {
00087 public:
00088
00089
00096 bool read(const std::string& _filename,
00097 BaseImporter& _bi,
00098 Options& _opt);
00099
00100
00101
00108 bool write(const std::string& _filename,
00109 BaseExporter& _be,
00110 Options _opt=Options::Default);
00111
00112
00113
00115 bool can_read( const std::string& _format ) const;
00116
00118 bool can_write( const std::string& _format ) const;
00119
00120
00121 size_t binary_size(const std::string& _format,
00122 BaseExporter& _be,
00123 Options _opt = Options::Default)
00124 {
00125 const BaseWriter *bw = find_writer(_format);
00126 return bw ? bw->binary_size(_be,_opt) : 0;
00127 }
00128
00129
00130
00131 public:
00132
00133
00138 const std::string& qt_read_filters() const { return read_filters_; }
00139
00140
00145 const std::string& qt_write_filters() const { return write_filters_; }
00146
00147
00148
00149 private:
00150
00151
00152 void update_read_filters();
00153
00154
00155
00156 void update_write_filters();
00157
00158
00159
00160 public:
00161
00162
00166 bool register_module(BaseReader* _bl)
00167 {
00168 reader_modules_.insert(_bl);
00169 update_read_filters();
00170 return true;
00171 }
00172
00173
00174
00178 bool register_module(BaseWriter* _bw)
00179 {
00180 writer_modules_.insert(_bw);
00181 update_write_filters();
00182 return true;
00183 }
00184
00185
00186 private:
00187
00188 const BaseWriter *find_writer(const std::string& _format);
00189
00190
00191 std::set<BaseReader*> reader_modules_;
00192
00193
00194 std::set<BaseWriter*> writer_modules_;
00195
00196
00197 std::string read_filters_;
00198
00199
00200 std::string write_filters_;
00201 };
00202
00203
00204
00205
00206
00211 typedef SingletonT<_IOManager_> IOManager;
00212
00213
00214
00215 }
00216 }
00217
00218 #endif
00219