basicapp.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 2005 by Tobias Nadler                                         */
00005 /*                                                                              */
00006 /*  This library is free software; you can redistribute it and/or               */
00007 /*  modify it under the terms of the GNU Lesser General Public                  */
00008 /*  License as published by the Free Software Foundation; either                */
00009 /*  version 2.1 of the License, or (at your option) any later version.          */
00010 /*                                                                              */
00011 /*  This library is distributed in the hope that it will be useful,             */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of              */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           */
00014 /*  Lesser General Public License for more details.                             */
00015 /*                                                                              */
00016 /*  You should have received a copy of the GNU Lesser General Public            */
00017 /*  License along with this library; if not, write to the Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
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 // Prepends the data path to a string
00154 //#define MAKE_DATA_PATH(fn)    ((string(BasicApp::the->getDataPath()) + fn).c_str())
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

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1