D:/WorkDir/SugoiProjects/SugoiTools/include/SugoiTools/cl_base_obj.h

00001 /* LICENSE_BEGIN
00002 SutoiTools library supply support for debugging, testing and 
00003 setting good bases for you application. It is part of the 
00004 SugoiEngine project.
00005 Copyright (C) 2006 Allusse Yannick (yannick dot allusse at laposte dot net)
00006 
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 LICENSE_END
00022 */
00023 
00024 /* \file SG_TLS_cl_base.h
00025  * \brief Supply two basic class used by the CL_template_manager.
00026  * \author Yannick Allusse
00027 */
00028 #ifndef SG_TLS_CL_BASE_OBJ_H
00029 #define SG_TLS_CL_BASE_OBJ_H
00030 
00031 #include "SugoiTools\config.h"
00032 //#include "xml.h"
00033 #include <sys/stat.h>
00034 //#include <unistd.h>
00035 //io.h dosio.h
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 //class _SG_TLS_EXPORT CL_BASE_OBJ_FILE;
00045 //class _SG_TLS_EXPORT CL_BASE_OBJ;
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                     /*        if (typeid(IDType) == typeid(std::string))
00102                               {
00103                                         std::string TmpStr = ToCharStr(ID, TmpStr);
00104                                         StringToUpper(TmpStr);
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;               //<! Create a file attribute structure, store date size and other...
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 };//namespace
00262 #if SG_TLS_MEMORY_MANAGER
00263           #include "SugoiTools\debug_new_off.h"//Must be the last....
00264 #endif 
00265 
00266 #endif //SG_TLS_CL_BASE_OBJ_H

Generated on Mon Mar 19 23:15:10 2007 for SugoiTools by  doxygen 1.4.6-NO