diff --git a/include/Application.h b/include/Application.h new file mode 100644 index 0000000..fb6a541 --- /dev/null +++ b/include/Application.h @@ -0,0 +1,63 @@ +//This file is part of Photon (http://photon.sourceforge.net) +//Copyright (C) 2004-2005 James Turk +// +// Author: +// James Turk (jpt2433@rit.edu) +// +// Version: +// $Id: Application.h,v 1.1 2005/02/07 02:00:48 cozman Exp $ +// +// Revisions: +// $Log: Application.h,v $ +// Revision 1.1 2005/02/07 02:00:48 cozman +// Application re-integrated +// +// + +#ifndef PHOTON_APPLICATION_H +#define PHOTON_APPLICATION_H + +#include +#include + +namespace photon +{ + +// Class: Application +// Main class, from which all applications using Photon should be derived. +// Derived classes are made entrypoint via . +class Application +{ + +// Group: (Con/De)structors +public: + // Function: Application + // Default constructor, initializes the internal state & dependencies. + // + // Parameters: + // arg0 - Path to application (argv[0]) + Application(const char* arg0); + + // Function: ~Application + // Default destructor, shuts down dependencies. + virtual ~Application(); + + // Function: main + // Pure virtual, must be defined by derived class, using some preprocessor + // magic () on the derived class + // this becomes the entry point for a Amph application. + // + // Parameters: + // args - containing arguments passed to program. + // + // Returns: 0 upon success, other upon failure. + // (Same as main in Standard C/C++). + // + // See Also: + // + virtual int main(StrVec args)=0; +}; + +} + +#endif //PHOTON_APPLICATION_H diff --git a/include/entrypoint.h b/include/entrypoint.h new file mode 100644 index 0000000..bcdb135 --- /dev/null +++ b/include/entrypoint.h @@ -0,0 +1,64 @@ +//This file is part of Photon (http://photon.sourceforge.net) +//Copyright (C) 2004-2005 James Turk +// +// Author: +// James Turk (jpt2433@rit.edu) +// +// Version: +// $Id: entrypoint.h,v 1.1 2005/02/07 02:00:48 cozman Exp $ +// +// Revisions: +// $Log: entrypoint.h,v $ +// Revision 1.1 2005/02/07 02:00:48 cozman +// Application re-integrated +// +// + + +#ifndef PHOTON_ENTRYPOINT_H +#define PHOTON_ENTRYPOINT_H + +#include "Log.h" + +/* Title: Entrypoint */ + +/* + Macro: ENTRYPOINT + A macro which is used to specify the class containing the entrypoint. + For example, if the class PongGame is the class derived from + which implements main, in the file defining PongGame it is important to + include ENTRYPOINT(PongGame) so that the entry point becomes PongGame::main. +*/ +#define ENTRYPOINT(className) int main(int argc, char *argv[]) \ + { return photon::mainclass(argc,argv); } + +namespace photon +{ + +// function which does all the work of MAINCLASS +template +int mainclass(int argc, char *argv[]) +{ + try + { + StrVec args; + for(int i=0; i < argc; ++i) + args.push_back(argv[i]); + App app(argv[0]); + return app.main(args); + } + catch(photon::Exception &e) + { + photon::log.error() << e; + return 0; + } + catch(photon::Error &e) + { + photon::log.critical() << e; + return 1; + } +} + +} + +#endif //PHOTON_ENTRYPOINT_H diff --git a/src/Application.cpp b/src/Application.cpp new file mode 100644 index 0000000..9611ec1 --- /dev/null +++ b/src/Application.cpp @@ -0,0 +1,35 @@ +//This file is part of Photon (http://photon.sourceforge.net) +//Copyright (C) 2004-2005 James Turk +// +// Author: +// James Turk (jpt2433@rit.edu) +// +// Version: +// $Id: Application.cpp,v 1.1 2005/02/07 02:00:49 cozman Exp $ +// +// Revisions: +// $Log: Application.cpp,v $ +// Revision 1.1 2005/02/07 02:00:49 cozman +// Application re-integrated +// +// + + +#include "Application.h" + +#include "physfs.h" + +namespace photon +{ + +Application::Application(const char* arg0) +{ + PHYSFS_init(arg0); //init PhysFS +} + +Application::~Application() +{ + PHYSFS_deinit(); //shutdown PhysFS +} + +} diff --git a/todo.txt b/todo.txt index 92671ac..d49be87 100644 --- a/todo.txt +++ b/todo.txt @@ -1,11 +1,7 @@ -$Id: todo.txt,v 1.1 2005/01/31 15:51:17 cozman Exp $ - -day: - -test Log class +$Id: todo.txt,v 1.2 2005/02/07 02:00:48 cozman Exp $ week: - -get all of util:: working - -reintroduce application framework + -GLFW month: -be Amph-complete (selected portions)