00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef BASICAPP_H
00023 #define BASICAPP_H
00024
00025 #include "basiclog.h"
00026 #include <string>
00027 #ifndef __windows__
00028 #include <sys/utsname.h>
00029 #endif
00030
00153
00154
00155
00161 #define BASICAPP_LOGGER(s) BasicLog::Logger log( BasicApp::getThe(), s )
00162
00176 class DECLSPEC BasicApp : public BasicLog
00177 {
00178 public:
00189 DECLSPEC BasicApp( int argc, char *argv[], const char *datapath = NULL, const char *debug = NULL );
00199 DECLSPEC BasicApp( int argc, char *argv[], TiXmlElement *el );
00200 virtual DECLSPEC ~BasicApp();
00201
00213 DECLSPEC int init(TiXmlElement *el = NULL);
00214
00218 virtual DECLSPEC void destroy();
00219
00229 virtual long mainLoop() { return 0; }
00230
00235 DECLSPEC const char * getExePath();
00236
00242 DECLSPEC const char * getDataPath();
00250 DECLSPEC std::string makeDataPath(const char *path);
00251
00258 const char *getUserdataPath() {return chUserdataPath;}
00266 DECLSPEC std::string makeUserPath(const char *path);
00267
00271 int getArgC() { return argc; }
00272
00276 const char * getArgV( int n ) { return argv[n]; }
00277
00284 DECLSPEC void exitWithMessage( const char *str );
00285
00293 DECLSPEC static bool setWorkingDir( const char *dn );
00294
00301 DECLSPEC static bool chDirToUser();
00306 DECLSPEC static const char *getOSName();
00310 DECLSPEC static const char *getCPUArch();
00315 DECLSPEC static const char *getRunningOSName();
00319 DECLSPEC static const char *getRunningOSVersion();
00323 DECLSPEC static const char *getRunningOSArch();
00324
00328 static BasicApp *the;
00337 DECLSPEC static BasicApp *getThe();
00338 protected:
00345 DECLSPEC void setDataPath(const char *path);
00353 DECLSPEC void setUserdataPath(const char *path);
00354 DECLSPEC void onInit();
00357 int nInitFailStatus;
00358 private:
00359 char *chExePath, *chDataPath, *chUserdataPath;
00360 int argc;
00361 char **argv;
00362 #ifndef __windows__
00363 static utsname osData;
00364 #endif
00365 };
00366
00367 #endif