Application re-integrated
This commit is contained in:
parent
70b47e9266
commit
e7e52cb57d
63
include/Application.h
Normal file
63
include/Application.h
Normal file
@ -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 <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace photon
|
||||||
|
{
|
||||||
|
|
||||||
|
// Class: Application
|
||||||
|
// Main class, from which all applications using Photon should be derived.
|
||||||
|
// Derived classes are made entrypoint via <ENTRYPOINT>.
|
||||||
|
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 (<MAINCLASS>) on the derived class
|
||||||
|
// this becomes the entry point for a Amph application.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// args - <ArgList> containing arguments passed to program.
|
||||||
|
//
|
||||||
|
// Returns: 0 upon success, other upon failure.
|
||||||
|
// (Same as main in Standard C/C++).
|
||||||
|
//
|
||||||
|
// See Also:
|
||||||
|
// <ENTRYPOINT>
|
||||||
|
virtual int main(StrVec args)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //PHOTON_APPLICATION_H
|
64
include/entrypoint.h
Normal file
64
include/entrypoint.h
Normal file
@ -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 <Application>
|
||||||
|
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<className>(argc,argv); }
|
||||||
|
|
||||||
|
namespace photon
|
||||||
|
{
|
||||||
|
|
||||||
|
// function which does all the work of MAINCLASS
|
||||||
|
template<class App>
|
||||||
|
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
|
35
src/Application.cpp
Normal file
35
src/Application.cpp
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
8
todo.txt
8
todo.txt
@ -1,11 +1,7 @@
|
|||||||
$Id: todo.txt,v 1.1 2005/01/31 15:51:17 cozman Exp $
|
$Id: todo.txt,v 1.2 2005/02/07 02:00:48 cozman Exp $
|
||||||
|
|
||||||
day:
|
|
||||||
-test Log class
|
|
||||||
|
|
||||||
week:
|
week:
|
||||||
-get all of util:: working
|
-GLFW
|
||||||
-reintroduce application framework
|
|
||||||
|
|
||||||
month:
|
month:
|
||||||
-be Amph-complete (selected portions)
|
-be Amph-complete (selected portions)
|
||||||
|
Loading…
Reference in New Issue
Block a user