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.hh>
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 private:
00088
00089 _IOManager_() {}
00090 friend _IOManager_& IOManager();
00091
00092
00093 public:
00094
00095
00102 bool read(const std::string& _filename,
00103 BaseImporter& _bi,
00104 Options& _opt);
00105
00106
00107
00114 bool write(const std::string& _filename,
00115 BaseExporter& _be,
00116 Options _opt=Options::Default);
00117
00118
00119
00121 bool can_read( const std::string& _format ) const;
00122
00124 bool can_write( const std::string& _format ) const;
00125
00126
00127 size_t binary_size(const std::string& _format,
00128 BaseExporter& _be,
00129 Options _opt = Options::Default)
00130 {
00131 const BaseWriter *bw = find_writer(_format);
00132 return bw ? bw->binary_size(_be,_opt) : 0;
00133 }
00134
00135
00136
00137 public:
00138
00139
00144 const std::string& qt_read_filters() const { return read_filters_; }
00145
00146
00151 const std::string& qt_write_filters() const { return write_filters_; }
00152
00153
00154
00155 private:
00156
00157
00158 void update_read_filters();
00159
00160
00161
00162 void update_write_filters();
00163
00164
00165
00166 public:
00167
00168
00172 bool register_module(BaseReader* _bl)
00173 {
00174 reader_modules_.insert(_bl);
00175 update_read_filters();
00176 return true;
00177 }
00178
00179
00180
00184 bool register_module(BaseWriter* _bw)
00185 {
00186 writer_modules_.insert(_bw);
00187 update_write_filters();
00188 return true;
00189 }
00190
00191
00192 private:
00193
00194 const BaseWriter *find_writer(const std::string& _format);
00195
00196
00197 std::set<BaseReader*> reader_modules_;
00198
00199
00200 std::set<BaseWriter*> writer_modules_;
00201
00202
00203 std::string read_filters_;
00204
00205
00206 std::string write_filters_;
00207 };
00208
00209
00210
00211
00212
00213 extern _IOManager_* __IOManager_instance;
00214
00215 _IOManager_& IOManager();
00216
00217
00218
00219
00220 }
00221 }
00222
00223 #endif
00224