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 #ifndef SG_TLS_CL_BASE_OBJ_H
00029 #define SG_TLS_CL_BASE_OBJ_H
00030
00031 #include "SugoiTools\config.h"
00032
00033 #include <sys/stat.h>
00034
00035
00036 #include <time.h>
00037
00038
00039 #if SG_TLS_MEMORY_MANAGER
00040 #include "SugoiTools\debug_new.h"
00041 #endif
00042
00043 namespace SGE{
00044
00045
00046
00047 enum TMANAGER_TYPE{
00048 TMANAGER_DEFAULT,
00049 TMANAGER_FILE
00050 };
00051
00052
00053 enum SGE_OBJ_TYPE{
00054 SGE_TYPE_int,
00055 SGE_TYPE_uint,
00056 SGE_TYPE_bool,
00057 SGE_TYPE_char,
00058 SGE_TYPE_uchar,
00059 SGE_TYPE_charArr,
00060 SGE_TYPE_string,
00061 SGE_TYPE_float,
00062 SGE_TYPE_double
00063 };
00064
00065 SGE_OBJ_TYPE WhatType(int &_Val);
00066 SGE_OBJ_TYPE WhatType(unsigned int &_Val);
00067 SGE_OBJ_TYPE WhatType(float &_Val);
00068 SGE_OBJ_TYPE WhatType(double &_Val);
00069 SGE_OBJ_TYPE WhatType(bool &_Val);
00070 SGE_OBJ_TYPE WhatType(unsigned char &_Val);
00071 SGE_OBJ_TYPE WhatType(char &_Val);
00072 SGE_OBJ_TYPE WhatType(char * _Val);
00073 SGE_OBJ_TYPE WhatType(std::string &_Val);
00074
00075
00081 template <typename IDType=std::string>
00082 class CL_BASE_OBJ
00083 {
00084 public:
00085
00089 _SG_TLS_INLINE
00090 CL_BASE_OBJ()
00091 {};
00092
00097 _SG_TLS_INLINE
00098 CL_BASE_OBJ(const IDType & _ID)
00099 {
00100 ID = _ID;
00101
00102
00103
00104
00105
00106 };
00107
00111 _SG_TLS_INLINE
00112 ~CL_BASE_OBJ(){};
00113
00118 _SG_TLS_INLINE
00119 const IDType &
00120 GetID()const
00121 {return ID;};
00122
00127 _SG_TLS_INLINE
00128 const std::string
00129 GetIDStr()
00130 {return ToCharStr(ID);};
00131
00136 _SG_TLS_INLINE virtual
00137 const std::string
00138 GetValStr()
00139 {return "Function not Defined!!";};
00140
00141 protected:
00145 _SG_TLS_INLINE
00146 void
00147 SetID(const IDType & _ID)
00148 {ID = _ID;}
00149
00150 IDType ID;
00151 template<class T, typename P> friend class CL_TEMPLATE_OBJECT_MANAGER;
00152 };
00153
00154
00155
00161 class _SG_TLS_EXPORT CL_BASE_OBJ_FILE :
00162 public virtual CL_BASE_OBJ<std::string>
00163 {
00164 public:
00169 _SG_TLS_INLINE
00170 CL_BASE_OBJ_FILE(const std::string & _Name);
00171
00175 _SG_TLS_INLINE
00176 ~CL_BASE_OBJ_FILE();
00177
00183 _SG_TLS_INLINE
00184 bool
00185 IsLoaded()const;
00186
00191 _SG_TLS_INLINE virtual
00192 int Load();
00193
00194 virtual _SG_TLS_INLINE int UnLoad();
00199 _SG_TLS_INLINE
00200 const std::string & GetPath()const;
00201
00206 _SG_TLS_INLINE const std::string & GetExtension()const;
00207
00212 _SG_TLS_INLINE const std::string GetFullName()const;
00213
00214 #if _SG_TLS_FILE_TEST
00215
00220 _SG_TLS_INLINE bool Exists()const;
00221
00227 static bool FileExists(const std::string & _Name);
00228
00229 #if 0
00230 static bool FileCopy(const std::string & _Src, const std::string & _Dst);
00231 static bool FileMove(const std::string & _Src, const std::string & _Dst);
00232 static bool FileDelete(const std::string & _Src);
00233 #endif
00234
00235
00241 _SG_TLS_INLINE bool IsFileModified();
00242
00243 protected:
00244 struct stat * FileAttrib;
00245 #endif
00246
00247 protected:
00251 _SG_TLS_INLINE
00252 void ParseFileName();
00253
00254 std::string Path;
00255 std::string Extension;
00256
00257 private:
00258 bool Loaded;
00259 };
00260
00261 };
00262 #if SG_TLS_MEMORY_MANAGER
00263 #include "SugoiTools\debug_new_off.h"
00264 #endif
00265
00266 #endif //SG_TLS_CL_BASE_OBJ_H