00001
00002 #ifndef _IOTEXTFILE_H
00003 #define _IOTEXTFILE_H
00004
00005 #include "IOManager.h"
00006 #include "TextFile.h"
00007
00008 namespace gk {
00009
00010
00011 class TextFileIO : public IOManager<TextFile>
00012 {
00013
00014 TextFileIO( const TextFileIO& );
00015 TextFileIO& operator=( const TextFileIO& );
00016
00017
00018 TextFileIO( )
00019 :
00020 IOManager<TextFile>()
00021 {}
00022
00023 ~TextFileIO( ) {}
00024
00025 public:
00026
00027 static
00028 TextFile *read( const std::string& filename, const std::string& name= "" )
00029 {
00030
00031 if(filename.empty() == true)
00032 return NULL;
00033
00034 TextFile *file= manager().find(filename, name);
00035 if(file != NULL)
00036 return file;
00037
00038
00039 file= new TextFile(filename);
00040 if(file->read(filename) < 0)
00041 {
00042 delete file;
00043 return NULL;
00044 }
00045
00046
00047 return manager().insert(file, filename, name);
00048 }
00049
00050 static
00051 TextFileIO& manager( )
00052 {
00053 static TextFileIO manager;
00054 return manager;
00055 }
00056 };
00057
00058 }
00059
00060 #endif