util:: source review

This commit is contained in:
James Turk 2005-07-18 06:18:50 +00:00
parent 39669bc6c6
commit 0610686ce6
9 changed files with 49 additions and 25 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: ConfigFile.hpp,v 1.4 2005/07/05 06:44:56 cozman Exp $
// $Id: ConfigFile.hpp,v 1.5 2005/07/18 06:18:51 cozman Exp $
#ifndef PHOTON_UTIL_CONFIGFILE_HPP
#define PHOTON_UTIL_CONFIGFILE_HPP
@ -44,7 +44,7 @@ public: // types used in ConfigFile
typedef std::pair<std::string,std::string> Variable;
typedef std::list< Variable > Section;
typedef std::pair< std::string, std::list< Variable > > NamedSection;
typedef std::pair< std::string, Section > NamedSection;
typedef std::list< NamedSection > Layout;
// Group: (Con/De)structors

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: RandGen.hpp,v 1.4 2005/03/15 18:47:46 cozman Exp $
// $Id: RandGen.hpp,v 1.5 2005/07/18 06:18:51 cozman Exp $
#ifndef PHOTON_UTIL_RANDGEN_HPP
#define PHOTON_UTIL_RANDGEN_HPP

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Singleton.hpp,v 1.7 2005/03/15 18:51:00 cozman Exp $
// $Id: Singleton.hpp,v 1.8 2005/07/18 06:18:51 cozman Exp $
#ifndef PHOTON_UTIL_SINGLETON_HPP
#define PHOTON_UTIL_SINGLETON_HPP
@ -20,12 +20,12 @@ namespace util
{
// Class: Singleton
// Template class for singleton pattern. Is non-copyable to enforce
// correct behavior.
// Template class for singleton pattern. Is non-copyable to enforce correct
// behavior.
//
// Defining a Singleton:
// (code)
// YourClass : public Singleton<Class>
// class YourClass : public Singleton<Class>
// {
// // class definition
// };

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Timer.hpp,v 1.1 2005/03/02 08:39:03 cozman Exp $
// $Id: Timer.hpp,v 1.2 2005/07/18 06:18:51 cozman Exp $
#ifndef PHOTON_UTIL_TIMER_HPP
#define PHOTON_UTIL_TIMER_HPP
@ -71,6 +71,9 @@ public:
// True if timer is paused, false if timer is running.
bool isPaused() const;
private:
double getTimeInternal() const; // get time from source timer
// data members
private:
AppCore& appCore_;

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: VersionInfo.hpp,v 1.6 2005/04/21 19:30:19 cozman Exp $
// $Id: VersionInfo.hpp,v 1.7 2005/07/18 06:18:51 cozman Exp $
#ifndef PHOTON_UTIL_VERSIONINFO_HPP
#define PHOTON_UTIL_VERSIONINFO_HPP
@ -68,7 +68,7 @@ public:
// pat - Patch number.
// ext - Extra info string. [default: ""]
VersionInfo(unsigned int maj, unsigned int min, unsigned int pat,
std::string ext="");
const std::string& ext="");
//operators
bool operator<(const VersionInfo &rhs) const;

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: FileBuffer.cpp,v 1.7 2005/06/27 04:24:16 cozman Exp $
// $Id: FileBuffer.cpp,v 1.8 2005/07/18 06:18:50 cozman Exp $
#include "util/FileBuffer.hpp"
@ -27,7 +27,12 @@ FileBuffer::FileBuffer(const std::string& filename)
}
FileBuffer::~FileBuffer()
{}
{
if(file_ != 0)
{
close();
}
}
void FileBuffer::open(const std::string& filename)
{
@ -46,6 +51,7 @@ void FileBuffer::close()
}
PHYSFS_close(file_);
file_ = 0;
}
std::vector<ubyte> FileBuffer::getData(int amount)

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: Timer.cpp,v 1.2 2005/03/15 18:52:07 cozman Exp $
// $Id: Timer.cpp,v 1.3 2005/07/18 06:18:50 cozman Exp $
#include "util/Timer.hpp"
@ -27,7 +27,7 @@ Timer::~Timer()
void Timer::reset()
{
lastPause_ = pausedTime_ = appCore_.getTime();
lastPause_ = pausedTime_ = getTimeInternal();
paused_ = false;
}
@ -35,7 +35,7 @@ void Timer::pause()
{
if(!paused_)
{
lastPause_ = appCore_.getTime();
lastPause_ = getTimeInternal();
paused_ = true;
}
}
@ -45,7 +45,7 @@ void Timer::unpause()
if(paused_)
{
//when unpausing update the total paused time by that pause
pausedTime_ += (appCore_.getTime()-lastPause_);
pausedTime_ += (getTimeInternal()-lastPause_);
paused_ = false;
}
}
@ -60,7 +60,7 @@ double Timer::getTime() const
else
{
//paused time is the total time the program has been paused
return appCore_.getTime() - pausedTime_;
return getTimeInternal() - pausedTime_;
}
}
@ -69,5 +69,17 @@ bool Timer::isPaused() const
return paused_;
}
double Timer::getTimeInternal() const
{
if(appTimeLinked_)
{
return appCore_.getTime(); // get from AppCore timer if linked
}
else
{
return glfwGetTime(); // raw timer if not linked
}
}
}
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: VersionInfo.cpp,v 1.7 2005/04/21 19:30:19 cozman Exp $
// $Id: VersionInfo.cpp,v 1.8 2005/07/18 06:18:50 cozman Exp $
#include "util/VersionInfo.hpp"
@ -19,7 +19,7 @@ namespace util
{
VersionInfo::VersionInfo(unsigned int maj, unsigned int min, unsigned int pat,
std::string ext) :
const std::string& ext) :
majorRelease(maj), minorRelease(min), patch(pat), extra(ext)
{}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// Version:
// $Id: filesys.cpp,v 1.4 2005/02/16 06:58:26 cozman Exp $
// $Id: filesys.cpp,v 1.5 2005/07/18 06:18:50 cozman Exp $
#include "util/filesys/filesys.hpp"
@ -17,6 +17,9 @@ namespace util
namespace filesys
{
// most functions are simple wrappers around PhysFS functions of virtually
// the same name, some convert 'char**'s into 'vector<string>'s.
std::vector<std::string> getCDDirs()
{
std::vector<std::string> dirs;