00001 /* -*-mode: C++; style: K&R; c-basic-offset: 4 ; -*- */ 00002 00003 00028 /* 00029 * I'm quite proud of this code, if you have any feedback I'd be intersted 00030 * in hearing it. 00031 */ 00032 00033 00034 #ifndef _CVERSION_H_ 00035 #define _CVERSION_H_ 1 00036 00037 #include <vector> 00038 #include <string> 00039 00040 00057 class CVersionRecord 00058 { 00059 public: 00066 CVersionRecord( char *fileName, char *date, char *versionString ); 00067 00071 virtual ~CVersionRecord(); 00072 00073 public: 00078 std::string GetFile(); 00079 00084 std::string GetVersion(); 00085 00090 std::string GetDate(); 00091 00092 private: 00096 std::string m_fileName; 00097 00101 std::string m_version; 00102 00106 std::string m_date; 00107 00108 }; 00109 00110 00129 class CVersion 00130 { 00131 public: 00137 static CVersion * GetInstance(); 00138 00142 virtual ~CVersion(); 00143 00150 void AddFileVersion( char *file, char *date, char *version ); 00151 00156 std::vector< CVersionRecord *> * GetVersionRecords(); 00157 00166 static int compareFunction( CVersionRecord *a, CVersionRecord *b ); 00167 00168 protected: 00172 CVersion(); 00173 00177 static CVersion *m_instance; 00178 00179 private: 00183 std::vector< CVersionRecord * > *m_versions; 00184 00185 private: 00186 00190 void operator=(CVersion &src ); 00191 00195 CVersion( CVersion &src ); 00196 00197 }; 00198 00199 00240 class InstallVersion 00241 { 00242 public: 00257 InstallVersion( char *file, char *date, char *version ) 00258 { 00259 CVersion *vHolder = CVersion::GetInstance(); 00260 vHolder->AddFileVersion( file, date, version ); 00261 }; 00262 00263 }; 00264 00265 00266 00267 00268 #endif /* _CVERSION_H_ */ 00269