00001 00018 #ifndef __READER_H__ 00019 #define __READER_H__ 00020 00021 #include <global.h> 00022 #include <exception.h> 00023 #include <cad/cad_model.h> 00024 00025 #include <stdio.h> 00026 00034 class Reader { 00035 public: 00036 // ##### Exceptions ################################################ 00037 00041 class ReaderException : public Exception { 00042 public: 00044 ReaderException() : Exception() {} 00046 ReaderException(string msg) : Exception(msg) {} 00047 }; 00048 00052 class ReadFileException : public ReaderException { 00053 public: 00055 ReadFileException(const char* fileName) 00056 : ReaderException("Error reading file " + (string)fileName) {} 00057 }; 00058 00062 class FileFormatException : public ReaderException { 00063 public: 00065 FileFormatException(string msg) : ReaderException(msg) {} 00066 00073 FileFormatException(const char* formatName, const char* fileName, 00074 int line) { 00075 char msg[STR_LEN]; 00076 00077 sprintf(msg, "%s-Format Error at line %d in File %s", 00078 formatName, line, fileName); 00079 message= msg; 00080 } 00081 }; 00082 00083 // ###### Reader ################################################### 00087 enum FormatType {DXF 00088 }; 00089 00106 static Reader* readFile(const char* fileName) 00107 throw (ReadFileException*, FileFormatException*); 00108 00116 virtual CadModel* getCadModel(Color color, bool splitQuad)= 0; 00117 00123 virtual const char* getLibVersion()= 0; 00124 00131 virtual const char* getFileFormatVersion()= 0; 00132 00137 virtual const char* getFormatName()= 0; 00138 00143 virtual const FormatType getFormatType()= 0; 00144 00151 virtual void print()= 0; 00152 00153 }; // class Reader 00154 00155 #endif // ! READER_H