brought to compatibility with tests

This commit is contained in:
James Turk 2005-05-15 02:50:52 +00:00
parent dcf68651ae
commit 45282000b2
8 changed files with 58 additions and 37 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Application.hpp,v 1.7 2005/03/15 19:22:07 cozman Exp $
// $Id: Application.hpp,v 1.8 2005/05/15 02:51:10 cozman Exp $
#ifndef PHOTON_APPLICATION_HPP
#define PHOTON_APPLICATION_HPP
@ -63,7 +63,7 @@ public:
// Group: API Initialization
private:
util::VersionInfo initPhysFS(const char* arg0);
util::VersionInfo initPhysFS();
private:
// version number for photon

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Log.hpp,v 1.5 2005/03/15 19:12:59 cozman Exp $
// $Id: Log.hpp,v 1.6 2005/05/15 02:51:10 cozman Exp $
#ifndef PHOTON_LOG_HPP
#define PHOTON_LOG_HPP
@ -21,12 +21,9 @@ namespace photon
{
// Class: Log
// <Singleton> log class for photon, Log passes all messages to any attached
// <LogSinks>, which can then take care of any output which is desired.
//
// Parent:
// <Singleton>
class Log : public util::Singleton<Log>
// Log class for photon, Log passes all messages to any attached <LogSinks>,
// which can then take care of any output which is desired.
class Log
{
// Group: (Con/De)structors

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: entrypoint.hpp,v 1.4 2005/03/15 19:22:07 cozman Exp $
// $Id: entrypoint.hpp,v 1.5 2005/05/15 02:51:10 cozman Exp $
#ifndef PHOTON_ENTRYPOINT_HPP
@ -28,30 +28,34 @@
namespace photon
{
// function which does all the work of MAINCLASS
// function which does all the work of ENTRYPOINT
template<class App>
int mainclass(int argc, const char** argv)
{
Log log;
log.addSink(LogSinkPtr(new photon::ConsoleSink("out")));
try
{
App::setInitOptions(argv[0]);
App app;
StrVec args;
for(int i=0; i < argc; ++i)
{
args.push_back(argv[i]);
}
App::setInitOptions(argv[0]);
return app.main(args);
}
catch(Exception &e)
{
Log::getInstance().error() << e;
log.error() << e;
return 0;
}
catch(Error &e)
{
Log::getInstance().critical() << e;
log.critical() << e;
return 1;
}
}

View File

@ -13,6 +13,7 @@
#include "Log.hpp"
#include "ResourceManaged.hpp"
#include "ResourceManager.hpp"
#include "audio/AudioCore.hpp"
#include "math/math.hpp"
#include "math/Rect.hpp"
#include "math/Vector2.hpp"
@ -23,10 +24,9 @@
#include "util/RandGen.hpp"
#include "util/Timer.hpp"
#include "util/FileBuffer.hpp"
#include "audio/AudioCore.hpp"
#include "util/filesys/filesys.hpp"
#include "video/Pen.hpp"
#include "video/Color.hpp"
#include "video/VideoCore.hpp"
#include "util/filesys/filesys.hpp"
#endif // PHOTON_HPP

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Application.cpp,v 1.7 2005/04/21 19:30:19 cozman Exp $
// $Id: Application.cpp,v 1.8 2005/05/15 02:50:52 cozman Exp $
#include "Application.hpp"
@ -13,12 +13,13 @@
#include "GL/gl.h"
#include <boost/lexical_cast.hpp>
#include <iostream>
#include "exceptions.hpp"
#include "Log.hpp"
#include "Kernel.hpp"
#include "AppCore.hpp"
#include "video/VideoCore.hpp"
#include "audio/AudioCore.hpp"
namespace photon
{
@ -29,10 +30,10 @@ Application::Application() :
util::VersionInfo physfsReq(1,0,0); // requires PhysFS 1.0.0
// create the singletons
new Log;
new Kernel;
new AppCore;
new video::VideoCore;
new audio::AudioCore;
// StrVec args;
//
@ -41,7 +42,7 @@ Application::Application() :
// args.push_back(argv[i]);
// }
util::ensureVersion("PhysFS", initPhysFS(arg0_.c_str()), physfsReq);
util::ensureVersion("PhysFS", initPhysFS(), physfsReq);
}
Application::~Application()
@ -51,8 +52,8 @@ Application::~Application()
// destroy the singletons
AppCore::destroy();
video::VideoCore::destroy();
audio::AudioCore::destroy();
Kernel::destroy();
Log::destroy();
}
void Application::setInitOptions(const char* arg0)
@ -60,11 +61,11 @@ void Application::setInitOptions(const char* arg0)
arg0_ = arg0;
}
util::VersionInfo Application::initPhysFS(const char* arg0)
util::VersionInfo Application::initPhysFS()
{
PHYSFS_Version ver;
PHYSFS_init(arg0);
PHYSFS_addToSearchPath(arg0,0);
PHYSFS_init(arg0_.c_str());
PHYSFS_addToSearchPath(arg0_.c_str(),0);
PHYSFS_getLinkedVersion(&ver);
return util::VersionInfo(ver.major, ver.minor, ver.patch);
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Log.cpp,v 1.7 2005/03/01 07:52:20 cozman Exp $
// $Id: Log.cpp,v 1.8 2005/05/15 02:50:52 cozman Exp $
#include "Log.hpp"
@ -22,7 +22,7 @@ Log::Log()
Log::~Log()
{
flush();
removeSinks();;
removeSinks();
}
void Log::addSink(LogSinkPtr sink)

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: AudioCore.cpp,v 1.4 2005/03/15 18:42:40 cozman Exp $
// $Id: AudioCore.cpp,v 1.5 2005/05/15 02:50:52 cozman Exp $
#include "audio/AudioCore.hpp"
@ -19,7 +19,7 @@ namespace audio
AudioCore::AudioCore()
{
util::VersionInfo oalReq(1,0,0); // requires OpenAL 1.0 (TODO: check?)
util::VersionInfo oalReq(0,0,7); // requires OpenAL 1.0 (TODO: check?)
util::ensureVersion("OpenAL", initOpenAL(), oalReq);
}
@ -42,6 +42,7 @@ std::string AudioCore::getAudioDeviceName() const
ALCdevice* device (alcGetContextsDevice( alcGetCurrentContext() ));
std::string name ( reinterpret_cast<const char*>(
alcGetString(device, ALC_DEVICE_SPECIFIER)) );
return name;
}
@ -52,7 +53,7 @@ util::VersionInfo AudioCore::initOpenAL()
std::stringstream ss; // stream for parsing version
std::string junks; // junk string for parsing
char junkc; // junk character for parsing
uint major,minor; // version numbers
uint major,minor,patch; // version numbers
// obtain default device if no deviceName is set, otherwise use deviceName
device = alcOpenDevice(deviceName_.empty() ? 0 :
@ -75,10 +76,19 @@ util::VersionInfo AudioCore::initOpenAL()
alcMakeContextCurrent(context); // context must be current to get version
// Version is in format "OpenAL 1.0"
ss << alGetString(AL_VERSION);
ss >> junks >> major >> junkc >> minor;
return util::VersionInfo(major,minor,0);
#if defined(WINVER)
ss >> junks >> major >> junkc >> minor; // format is "OpenAL 1.0"
#elif defined(linux)
ss >> major >> junkc >> minor >> junkc >> patch;
#else
#warning OpenAL only built on Windows/Linux, find out version on OSX
#endif
//std::cerr << util::VersionInfo(major,minor,patch);
return util::VersionInfo(major,minor,patch);
}
std::string AudioCore::checkOpenALError()

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: ConfigFile.cpp,v 1.5 2005/03/03 09:25:47 cozman Exp $
// $Id: ConfigFile.cpp,v 1.6 2005/05/15 02:50:52 cozman Exp $
#include "util/ConfigFile.hpp"
#include "exceptions.hpp"
@ -59,6 +59,7 @@ void ConfigFile::open(const std::string& filename)
std::getline(file,str); //read in a line
clean = cleanString(str); //get a clean version
//if std::string is bracketed it is a section
if(clean[0] == '[' && clean[clean.length()-1] == ']')
{
@ -141,7 +142,11 @@ void ConfigFile::flush()
void ConfigFile::close()
{
//flush and clear out the data members
if(!filename_.empty())
{
flush();
}
filename_ = std::string();
layout_.clear();
}
@ -155,12 +160,16 @@ std::string ConfigFile::cleanString(const std::string& str)
static_cast<int(*)(int)>(std::tolower) );
//remove all spaces
for(std::string::iterator i=ret.begin(); i != ret.end(); ++i)
for(std::string::iterator i=ret.begin(); i != ret.end(); )
{
if(std::isspace(*i))
{
i = ret.erase(i);
}
else
{
++i;
}
}
return ret;