Kernel --> TaskManager
This commit is contained in:
parent
d483237b66
commit
e7658ccce4
@ -1,22 +1,31 @@
|
|||||||
Sanity Check
|
Process:
|
||||||
Check Compilation from CVS
|
human: bump version numbers*
|
||||||
Ensure Tests Run from CVS
|
script: checkout fresh CVS
|
||||||
Sanity Check NaturalDocs
|
script: check building of library & tests
|
||||||
Bump Version Number
|
script: check building of docs
|
||||||
|
human: sanity check tests
|
||||||
|
human: sanity check docs
|
||||||
|
human: check building on Windows
|
||||||
|
script: tag CVS with version number
|
||||||
|
script: CVS export `cvs -z3 -d:ext:cozman@cvs.sourceforge.net:/cvsroot/photon export -r release-VERSION photon`
|
||||||
|
script: build docs with `scons docs`
|
||||||
|
script: remove non-distribution files**
|
||||||
|
script: rename directory to photon-MAJOR.MINOR
|
||||||
|
script: package source with tar cjf photon-MAJOR.MINOR.RELEASE-src.tar.bz2 photon-MAJOR.MINOR/
|
||||||
|
human: place in sourceforge File Release System
|
||||||
|
script: upload docs to sourceforge webspace
|
||||||
|
human: write release announcement
|
||||||
|
|
||||||
|
*Version Number Locations:
|
||||||
ndoc/Menu.txt : Title
|
ndoc/Menu.txt : Title
|
||||||
src/Application.cpp : photonVer_
|
src/Application.cpp : photonVer_
|
||||||
CHANGELOG.txt
|
CHANGELOG.txt
|
||||||
photon.mm
|
photon.mm
|
||||||
Tag CVS with version number
|
CVS Tag
|
||||||
Sourceforge.net
|
|
||||||
Get with `cvs -z3 -d:ext:cozman@cvs.sourceforge.net:/cvsroot/photon export -r release-VERSION photon`
|
|
||||||
rename directory to photon-MAJOR.MINOR
|
|
||||||
Build docs with `scons docs`
|
|
||||||
prune any files that shouldn't be included (.cvsignores)
|
|
||||||
package source with tar cjf photon-MAJOR.MINOR.RELEASE.tar.bz2 photon-MAJOR.MINOR/
|
|
||||||
Upload to Sourceforge and release via Sourceforge release system
|
|
||||||
Upload docs to Sourceforge webspace
|
|
||||||
Write release announcement, post on DevBlog/Mailing list
|
|
||||||
|
|
||||||
|
**Non-Distribution Files:
|
||||||
|
photon/.cvsignore
|
||||||
|
photon/docs/.cvsignore
|
||||||
|
photon/ndoc/.cvsignore
|
||||||
|
|
||||||
$Id: RELEASE-HOWTO.txt,v 1.3 2005/08/08 22:54:15 cozman Exp $
|
$Id: RELEASE-HOWTO.txt,v 1.4 2005/08/17 06:35:54 cozman Exp $
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Application.hpp,v 1.21 2005/08/17 03:15:24 cozman Exp $
|
// $Id: Application.hpp,v 1.22 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#ifndef PHOTON_APPLICATION_HPP
|
#ifndef PHOTON_APPLICATION_HPP
|
||||||
#define PHOTON_APPLICATION_HPP
|
#define PHOTON_APPLICATION_HPP
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "util/VersionInfo.hpp"
|
#include "util/VersionInfo.hpp"
|
||||||
#include "State.hpp"
|
#include "State.hpp"
|
||||||
#include "Kernel.hpp"
|
#include "util/TaskManager.hpp"
|
||||||
#include "audio/AudioCore.hpp"
|
#include "audio/AudioCore.hpp"
|
||||||
#include "util/Singleton.hpp"
|
#include "util/Singleton.hpp"
|
||||||
|
|
||||||
@ -64,21 +64,21 @@ public:
|
|||||||
// Sets Quit flag, terminating application.
|
// Sets Quit flag, terminating application.
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
// Function: getUpdateKernel
|
// Function: getUpdateTaskManager
|
||||||
// Access the application's update <Kernel>, <Tasks> registered with this
|
// Access the application's update <TaskManager>, <Tasks> registered with
|
||||||
// kernel are executed after the current <State's> <State::update>.
|
// this TaskManager are executed after the current <State::update>.
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// Reference to "Update Kernel"
|
// Reference to "Update TaskManager"
|
||||||
Kernel& getUpdateKernel();
|
util::TaskManager& getUpdateTaskManager();
|
||||||
|
|
||||||
// Function: getRenderKernel
|
// Function: getRenderTaskManager
|
||||||
// Access the application's render <Kernel>, <Tasks> registered with this
|
// Access the application's render <TaskManager>, <Tasks> registered with
|
||||||
// kernel are executed after the current <State's> <State::render>.
|
// this TaskManager are executed after the current <State::render>.
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// Reference to "Render Kernel"
|
// Reference to "Render TaskManager"
|
||||||
Kernel& getRenderKernel();
|
util::TaskManager& getRenderTaskManager();
|
||||||
|
|
||||||
// Function: isActive
|
// Function: isActive
|
||||||
// Checks if application is active, which on most systems simply means it
|
// Checks if application is active, which on most systems simply means it
|
||||||
@ -429,8 +429,8 @@ private:
|
|||||||
|
|
||||||
// other
|
// other
|
||||||
bool quit_;
|
bool quit_;
|
||||||
Kernel updateKernel_;
|
util::TaskManager updateTaskManager_;
|
||||||
Kernel renderKernel_;
|
util::TaskManager renderTaskManager_;
|
||||||
|
|
||||||
// state system
|
// state system
|
||||||
static std::stack<StatePtr> stateStack_;
|
static std::stack<StatePtr> stateStack_;
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#ifndef PHOTON_HPP
|
#ifndef PHOTON_HPP
|
||||||
#define PHOTON_HPP
|
#define PHOTON_HPP
|
||||||
|
|
||||||
#include "Kernel.hpp"
|
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "State.hpp"
|
#include "State.hpp"
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "Task.hpp"
|
|
||||||
#include "exceptions.hpp"
|
#include "exceptions.hpp"
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
#include "entrypoint.hpp"
|
#include "entrypoint.hpp"
|
||||||
@ -22,7 +20,9 @@
|
|||||||
#include "math/Circle.hpp"
|
#include "math/Circle.hpp"
|
||||||
#include "util/ConfigFile.hpp"
|
#include "util/ConfigFile.hpp"
|
||||||
#include "util/VersionInfo.hpp"
|
#include "util/VersionInfo.hpp"
|
||||||
|
#include "util/Task.hpp"
|
||||||
#include "util/Singleton.hpp"
|
#include "util/Singleton.hpp"
|
||||||
|
#include "util/TaskManager.hpp"
|
||||||
#include "util/RandGen.hpp"
|
#include "util/RandGen.hpp"
|
||||||
#include "util/Timer.hpp"
|
#include "util/Timer.hpp"
|
||||||
#include "util/FileBuffer.hpp"
|
#include "util/FileBuffer.hpp"
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Task.hpp,v 1.5 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Task.hpp,v 1.1 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#ifndef PHOTON_TASK_HPP
|
#ifndef PHOTON_UTIL_TASK_HPP
|
||||||
#define PHOTON_TASK_HPP
|
#define PHOTON_UTIL_TASK_HPP
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
namespace photon
|
namespace photon
|
||||||
{
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
// Title: Task
|
// Title: Task
|
||||||
|
|
||||||
@ -38,7 +40,8 @@ enum PriorityLevel
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Class: Task
|
// Class: Task
|
||||||
// Abstract class for tasks, which are runnable classes for use with <Kernel>.
|
// Abstract class for tasks, which are runnable classes for use with
|
||||||
|
// <TaskManager>.
|
||||||
//
|
//
|
||||||
// When writing a task, only update() needs to be overloaded.
|
// When writing a task, only update() needs to be overloaded.
|
||||||
class Task
|
class Task
|
||||||
@ -51,7 +54,7 @@ public:
|
|||||||
// Parameters:
|
// Parameters:
|
||||||
// name - Name for task, must be unique!
|
// name - Name for task, must be unique!
|
||||||
// priority - Optional argument for desired priority for the Task,
|
// priority - Optional argument for desired priority for the Task,
|
||||||
// controls order in which tasks are run by the <Kernel>.
|
// controls order in which tasks are run by the <TaskManager>.
|
||||||
// Default Priority is PRI_NORMAL
|
// Default Priority is PRI_NORMAL
|
||||||
Task(const std::string& name, PriorityLevel priority=PRI_NORMAL);
|
Task(const std::string& name, PriorityLevel priority=PRI_NORMAL);
|
||||||
|
|
||||||
@ -97,8 +100,8 @@ public:
|
|||||||
virtual void onUnpause();
|
virtual void onUnpause();
|
||||||
|
|
||||||
// Function: kill
|
// Function: kill
|
||||||
// Sets state of application to dead, dead tasks remove themselves from
|
// Sets state of task to dead, dead tasks remove themselves from the
|
||||||
// the Kernel's task pool.
|
// <TaskManager>'s task pool.
|
||||||
void kill();
|
void kill();
|
||||||
|
|
||||||
// Group: Accessors
|
// Group: Accessors
|
||||||
@ -144,6 +147,7 @@ private:
|
|||||||
// via a pointer.
|
// via a pointer.
|
||||||
typedef shared_ptr<Task> TaskPtr;
|
typedef shared_ptr<Task> TaskPtr;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //PHOTON_TASK_HPP
|
#endif //PHOTON_UTIL_TASK_HPP
|
@ -5,10 +5,10 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Kernel.hpp,v 1.4 2005/08/16 06:32:39 cozman Exp $
|
// $Id: TaskManager.hpp,v 1.1 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#ifndef PHOTON_KERNEL_HPP
|
#ifndef PHOTON_UTIL_TASKMANAGER_HPP
|
||||||
#define PHOTON_KERNEL_HPP
|
#define PHOTON_UTIL_TASKMANAGER_HPP
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -17,31 +17,33 @@
|
|||||||
|
|
||||||
namespace photon
|
namespace photon
|
||||||
{
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
// Class: Kernel
|
// Class: TaskManager
|
||||||
// Kernel class, maintains a list of <Tasks> and manages their status,
|
// TaskManager class, maintains a list of <Tasks> and manages their status,
|
||||||
// handles adding, deleting, pausing, and unpausing tasks.
|
// handles adding, deleting, pausing, and unpausing tasks.
|
||||||
//
|
//
|
||||||
// To use Kernel:
|
// To use TaskManager:
|
||||||
// - (1) Add any tasks (should be derived from <Task>)
|
// - (1) Add any tasks (should be derived from <Task>)
|
||||||
// - (2) Call step() every frame when task should update.
|
// - (2) Call step() every frame when task should update.
|
||||||
class Kernel
|
class TaskManager
|
||||||
{
|
{
|
||||||
|
|
||||||
// Group: (Con/De)structors
|
// Group: (Con/De)structors
|
||||||
public:
|
public:
|
||||||
// Function: Kernel
|
// Function: TaskManager
|
||||||
// Kernel constructor, initializes kernel singleton.
|
// TaskManager constructor, initializes task manager
|
||||||
Kernel();
|
TaskManager();
|
||||||
|
|
||||||
// Function: ~Kernel
|
// Function: ~TaskManager
|
||||||
// Kernel destructor, destroys kernel singleton.
|
// TaskManager destructor, destroys task manager
|
||||||
~Kernel();
|
~TaskManager();
|
||||||
|
|
||||||
// Group: Running
|
// Group: Running
|
||||||
public:
|
public:
|
||||||
// Function: step
|
// Function: step
|
||||||
// Steps the kernel, calling each active task once.
|
// Steps the task manager, calling each active task once.
|
||||||
//
|
//
|
||||||
// Each 'step' all tasks are run in order of their priorities, if two
|
// Each 'step' all tasks are run in order of their priorities, if two
|
||||||
// tasks have the same priority, they are run in the order they were added.
|
// tasks have the same priority, they are run in the order they were added.
|
||||||
@ -54,7 +56,7 @@ public:
|
|||||||
// Group: Task Management
|
// Group: Task Management
|
||||||
public:
|
public:
|
||||||
// Function: addTask
|
// Function: addTask
|
||||||
// Add a new <Task> to the Kernel's list. All tasks MUST have unique
|
// Add a new <Task> to the TaskManager's list. All tasks MUST have unique
|
||||||
// names.
|
// names.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
@ -62,7 +64,7 @@ public:
|
|||||||
void addTask(TaskPtr task);
|
void addTask(TaskPtr task);
|
||||||
|
|
||||||
// Function: killTask
|
// Function: killTask
|
||||||
// Kill a task in the Kernel task list.
|
// Kill a task in the TaskManager task list.
|
||||||
// Dead tasks are removed in next loop through tasks.
|
// Dead tasks are removed in next loop through tasks.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
@ -70,14 +72,14 @@ public:
|
|||||||
void killTask(const std::string& taskName);
|
void killTask(const std::string& taskName);
|
||||||
|
|
||||||
// Function: pauseTask
|
// Function: pauseTask
|
||||||
// Pause a task in the Kernel task list.
|
// Pause a task in the TaskManager task list.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// taskName - Name of task to pause.
|
// taskName - Name of task to pause.
|
||||||
void pauseTask(const std::string& taskName);
|
void pauseTask(const std::string& taskName);
|
||||||
|
|
||||||
// Function: unpauseTask
|
// Function: unpauseTask
|
||||||
// Unpause a task in the Kernel task list.
|
// Unpause a task in the TaskManager task list.
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// taskName - Name of task to unpause.
|
// taskName - Name of task to unpause.
|
||||||
@ -102,6 +104,7 @@ private:
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //PHOTON_KERNEL_HPP
|
#endif //PHOTON_UTIL_TASKMANAGER_HPP
|
@ -32,7 +32,6 @@ Group: photon:: {
|
|||||||
File: Application (Application.hpp)
|
File: Application (Application.hpp)
|
||||||
File: Basic Types (types.hpp)
|
File: Basic Types (types.hpp)
|
||||||
File: Exception/Error Types (exceptions.hpp)
|
File: Exception/Error Types (exceptions.hpp)
|
||||||
File: Kernel (Kernel.hpp)
|
|
||||||
File: Log (Log.hpp)
|
File: Log (Log.hpp)
|
||||||
File: Logging Utilities (LogSink.hpp)
|
File: Logging Utilities (LogSink.hpp)
|
||||||
File: PhotonMain (entrypoint.hpp)
|
File: PhotonMain (entrypoint.hpp)
|
||||||
@ -40,6 +39,7 @@ Group: photon:: {
|
|||||||
File: ResourceManager (ResourceManager.hpp)
|
File: ResourceManager (ResourceManager.hpp)
|
||||||
File: State (State.hpp)
|
File: State (State.hpp)
|
||||||
File: Task (Task.hpp)
|
File: Task (Task.hpp)
|
||||||
|
File: TaskManager (Kernel.hpp)
|
||||||
|
|
||||||
Group: Audio:: {
|
Group: Audio:: {
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<node ID="Freemind_Link_1902843385" TEXT="depthBuffer enable/disable">
|
<node ID="Freemind_Link_1902843385" TEXT="depthBuffer enable/disable">
|
||||||
<icon BUILTIN="button_ok"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
</node>
|
</node>
|
||||||
<node ID="Freemind_Link_1912839994" TEXT="dual Kernels">
|
<node ID="Freemind_Link_1912839994" TEXT="dual Kernels (TaskManager)">
|
||||||
<icon BUILTIN="button_ok"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
@ -183,12 +183,11 @@
|
|||||||
<node ID="Freemind_Link_959094471" TEXT="Contest"/>
|
<node ID="Freemind_Link_959094471" TEXT="Contest"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.27 2005/08/16 06:32:39 cozman Exp $">
|
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.28 2005/08/17 06:35:54 cozman Exp $">
|
||||||
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
|
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
|
||||||
</node>
|
</node>
|
||||||
<node ID="Freemind_Link_853483912" POSITION="left" TEXT="Current Problems">
|
<node ID="Freemind_Link_853483912" POSITION="left" TEXT="Current Problems">
|
||||||
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
|
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
|
||||||
<node ID="Freemind_Link_1298604697" TEXT="reintegrate FPSDisplayTask"/>
|
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</map>
|
</map>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Application.cpp,v 1.26 2005/08/17 03:15:23 cozman Exp $
|
// $Id: Application.cpp,v 1.27 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
|
||||||
@ -118,14 +118,14 @@ void Application::update()
|
|||||||
while(timeAccumulator_ >= fixedTimeStep_)
|
while(timeAccumulator_ >= fixedTimeStep_)
|
||||||
{
|
{
|
||||||
stateStack_.top()->update(fixedTimeStep_);
|
stateStack_.top()->update(fixedTimeStep_);
|
||||||
updateKernel_.step(fixedTimeStep_);
|
updateTaskManager_.step(fixedTimeStep_);
|
||||||
timeAccumulator_ -= fixedTimeStep_;
|
timeAccumulator_ -= fixedTimeStep_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stateStack_.top()->update(elapsedTime_);
|
stateStack_.top()->update(elapsedTime_);
|
||||||
updateKernel_.step(elapsedTime_);
|
updateTaskManager_.step(elapsedTime_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ void Application::update()
|
|||||||
// clear everything before rendering
|
// clear everything before rendering
|
||||||
glClear(clearFlags_);
|
glClear(clearFlags_);
|
||||||
stateStack_.top()->render();
|
stateStack_.top()->render();
|
||||||
renderKernel_.step(fixedTimeStep_);
|
renderTaskManager_.step(fixedTimeStep_);
|
||||||
glfwSwapBuffers(); // swap buffers after rendering
|
glfwSwapBuffers(); // swap buffers after rendering
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,14 +147,14 @@ void Application::quit()
|
|||||||
quit_ = true;
|
quit_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel& Application::getUpdateKernel()
|
util::TaskManager& Application::getUpdateTaskManager()
|
||||||
{
|
{
|
||||||
return updateKernel_;
|
return updateTaskManager_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel& Application::getRenderKernel()
|
util::TaskManager& Application::getRenderTaskManager()
|
||||||
{
|
{
|
||||||
return renderKernel_;
|
return renderTaskManager_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isActive()
|
bool Application::isActive()
|
||||||
@ -305,8 +305,6 @@ void Application::setOrthoProjection(scalar width, scalar height)
|
|||||||
//back to modelview
|
//back to modelview
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
setDepthBufferParams(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setPerspectiveProjection(scalar fovy, scalar zNear,
|
void Application::setPerspectiveProjection(scalar fovy, scalar zNear,
|
||||||
@ -323,6 +321,8 @@ void Application::setPerspectiveProjection(scalar fovy, scalar zNear,
|
|||||||
//back to modelview
|
//back to modelview
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
setDepthBufferParams(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setDepthBufferParams(bool enable, scalar depth)
|
void Application::setDepthBufferParams(bool enable, scalar depth)
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Task.cpp,v 1.4 2005/08/07 07:12:47 cozman Exp $
|
// $Id: Task.cpp,v 1.1 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "Task.hpp"
|
#include "util/Task.hpp"
|
||||||
|
|
||||||
namespace photon
|
namespace photon
|
||||||
{
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
Task::Task(const std::string& name, PriorityLevel priority) :
|
Task::Task(const std::string& name, PriorityLevel priority) :
|
||||||
name_(name), priority_(priority), alive_(true), paused_(false)
|
name_(name), priority_(priority), alive_(true), paused_(false)
|
||||||
@ -60,3 +62,4 @@ bool Task::isPaused() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
@ -5,27 +5,27 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Kernel.cpp,v 1.5 2005/08/16 06:32:39 cozman Exp $
|
// $Id: TaskManager.cpp,v 1.1 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "Kernel.hpp"
|
#include "util/TaskManager.hpp"
|
||||||
|
|
||||||
#include "exceptions.hpp"
|
#include "exceptions.hpp"
|
||||||
|
|
||||||
#include "Log.hpp"
|
|
||||||
|
|
||||||
namespace photon
|
namespace photon
|
||||||
{
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
Kernel::Kernel()
|
TaskManager::TaskManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::~Kernel()
|
TaskManager::~TaskManager()
|
||||||
{
|
{
|
||||||
killAllTasks();
|
killAllTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kernel::step(scalar timeDelta)
|
void TaskManager::step(scalar timeDelta)
|
||||||
{
|
{
|
||||||
std::list<TaskPtr>::iterator it;
|
std::list<TaskPtr>::iterator it;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ void Kernel::step(scalar timeDelta)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kernel::addTask(TaskPtr task)
|
void TaskManager::addTask(TaskPtr task)
|
||||||
{
|
{
|
||||||
std::list<TaskPtr>::iterator it = tasks_.begin();
|
std::list<TaskPtr>::iterator it = tasks_.begin();
|
||||||
// attempt to find task
|
// attempt to find task
|
||||||
@ -84,7 +84,7 @@ void Kernel::addTask(TaskPtr task)
|
|||||||
tasks_.insert(it, task); // insert task after iterator
|
tasks_.insert(it, task); // insert task after iterator
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kernel::killTask(const std::string& taskName)
|
void TaskManager::killTask(const std::string& taskName)
|
||||||
{
|
{
|
||||||
// attempt to find the task
|
// attempt to find the task
|
||||||
std::list<TaskPtr>::iterator task = std::find_if(tasks_.begin(),
|
std::list<TaskPtr>::iterator task = std::find_if(tasks_.begin(),
|
||||||
@ -102,7 +102,7 @@ void Kernel::killTask(const std::string& taskName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kernel::pauseTask(const std::string& taskName)
|
void TaskManager::pauseTask(const std::string& taskName)
|
||||||
{
|
{
|
||||||
// attempt to find the task
|
// attempt to find the task
|
||||||
std::list<TaskPtr>::iterator task = std::find_if(tasks_.begin(),
|
std::list<TaskPtr>::iterator task = std::find_if(tasks_.begin(),
|
||||||
@ -120,7 +120,7 @@ void Kernel::pauseTask(const std::string& taskName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kernel::unpauseTask(const std::string& taskName)
|
void TaskManager::unpauseTask(const std::string& taskName)
|
||||||
{
|
{
|
||||||
// attempt to find the task
|
// attempt to find the task
|
||||||
std::list<TaskPtr>::iterator task = std::find_if(tasks_.begin(),
|
std::list<TaskPtr>::iterator task = std::find_if(tasks_.begin(),
|
||||||
@ -138,7 +138,7 @@ void Kernel::unpauseTask(const std::string& taskName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kernel::killAllTasks()
|
void TaskManager::killAllTasks()
|
||||||
{
|
{
|
||||||
// set all tasks to dead
|
// set all tasks to dead
|
||||||
for(std::list<TaskPtr>::iterator it = tasks_.begin();
|
for(std::list<TaskPtr>::iterator it = tasks_.begin();
|
||||||
@ -149,10 +149,11 @@ void Kernel::killAllTasks()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Kernel::TaskNameEq::operator()(const TaskPtr& lhs,
|
bool TaskManager::TaskNameEq::operator()(const TaskPtr& lhs,
|
||||||
const std::string& rhs) const
|
const std::string& rhs) const
|
||||||
{
|
{
|
||||||
return lhs->getName() == rhs;
|
return lhs->getName() == rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Audio_test.cpp,v 1.15 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Audio_test.cpp,v 1.16 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -190,7 +190,7 @@ int PhotonMain(const StrVec& args)
|
|||||||
app.initAudioCore(); // initialize audio core
|
app.initAudioCore(); // initialize audio core
|
||||||
|
|
||||||
// be sure to add FPSDisplayTask
|
// be sure to add FPSDisplayTask
|
||||||
//Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
|
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));
|
||||||
|
|
||||||
app.setState<MainState>(); // register state and make active
|
app.setState<MainState>(); // register state and make active
|
||||||
app.run(); // run until finished
|
app.run(); // run until finished
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
// Used to measure FPS and display it in the title bar. Pretty good example
|
// Used to measure FPS and display it in the title bar. Pretty good example
|
||||||
// of when to use a Task, logic is entirely separate from rest of application
|
// of when to use a Task, logic is entirely separate from rest of application
|
||||||
// and should be executed regularly.
|
// and should be executed regularly.
|
||||||
class FPSDisplayTask : public photon::Task
|
//
|
||||||
|
// Note: Realistically framerate should not be displayed in the title bar
|
||||||
|
// because changing the title causes a stutter, and changing the title
|
||||||
|
// bar every second makes applications with a lot of movement look
|
||||||
|
// terrible.
|
||||||
|
class FPSDisplayTask : public photon::util::Task
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FPSDisplayTask() :
|
FPSDisplayTask() :
|
||||||
@ -16,7 +21,7 @@ public:
|
|||||||
lastUpdate(0)
|
lastUpdate(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void update()
|
void update(scalar timeDelta)
|
||||||
{
|
{
|
||||||
// update (at most) once a second
|
// update (at most) once a second
|
||||||
if(app.getTime() - lastUpdate > 1.0)
|
if(app.getTime() - lastUpdate > 1.0)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Font_test.cpp,v 1.12 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Font_test.cpp,v 1.13 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -54,7 +54,7 @@ int PhotonMain(const StrVec& args)
|
|||||||
app.createDisplay(800,600,32,0,0,false); // create window
|
app.createDisplay(800,600,32,0,0,false); // create window
|
||||||
|
|
||||||
// be sure to add FPSDisplayTask
|
// be sure to add FPSDisplayTask
|
||||||
//Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
|
//TaskManager::getInstance().addTask(util::TaskPtr(new FPSDisplayTask()));
|
||||||
|
|
||||||
app.setState<MainState>(); // register state and make active
|
app.setState<MainState>(); // register state and make active
|
||||||
app.run(); // run until finished
|
app.run(); // run until finished
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Image_test.cpp,v 1.12 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Image_test.cpp,v 1.13 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -65,7 +65,7 @@ int PhotonMain(const StrVec& args)
|
|||||||
app.createDisplay(800,600,32,0,0,false); // create window
|
app.createDisplay(800,600,32,0,0,false); // create window
|
||||||
|
|
||||||
// be sure to add FPSDisplayTask
|
// be sure to add FPSDisplayTask
|
||||||
//Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
|
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));
|
||||||
|
|
||||||
app.setState<MainState>(); // register state and make active
|
app.setState<MainState>(); // register state and make active
|
||||||
app.run(); // run until finished
|
app.run(); // run until finished
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Input_test.cpp,v 1.11 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Input_test.cpp,v 1.12 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -124,7 +124,7 @@ int PhotonMain(const StrVec& args)
|
|||||||
app.createDisplay(800,600,32,0,0,false); // create window
|
app.createDisplay(800,600,32,0,0,false); // create window
|
||||||
|
|
||||||
// be sure to add FPSDisplayTask
|
// be sure to add FPSDisplayTask
|
||||||
//Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
|
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));
|
||||||
|
|
||||||
app.setState<MainState>(); // register state and make active
|
app.setState<MainState>(); // register state and make active
|
||||||
app.run(); // run until finished
|
app.run(); // run until finished
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Pen_test.cpp,v 1.9 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Pen_test.cpp,v 1.10 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -78,7 +78,7 @@ int PhotonMain(const StrVec& args)
|
|||||||
app.createDisplay(800,600,32,0,0,false); // create window
|
app.createDisplay(800,600,32,0,0,false); // create window
|
||||||
|
|
||||||
// be sure to add FPSDisplayTask
|
// be sure to add FPSDisplayTask
|
||||||
//Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
|
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));
|
||||||
|
|
||||||
app.setState<MainState>(); // register state and make active
|
app.setState<MainState>(); // register state and make active
|
||||||
app.run(); // run until finished
|
app.run(); // run until finished
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// James Turk (jpt2433@rit.edu)
|
// James Turk (jpt2433@rit.edu)
|
||||||
//
|
//
|
||||||
// Version:
|
// Version:
|
||||||
// $Id: Texture_test.cpp,v 1.10 2005/08/16 06:32:39 cozman Exp $
|
// $Id: Texture_test.cpp,v 1.11 2005/08/17 06:35:56 cozman Exp $
|
||||||
|
|
||||||
#include "photon.hpp"
|
#include "photon.hpp"
|
||||||
using namespace photon;
|
using namespace photon;
|
||||||
@ -78,7 +78,7 @@ int PhotonMain(const StrVec& args)
|
|||||||
app.createDisplay(800,600,32,0,0,false); // create window
|
app.createDisplay(800,600,32,0,0,false); // create window
|
||||||
|
|
||||||
// be sure to add FPSDisplayTask
|
// be sure to add FPSDisplayTask
|
||||||
//Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask()));
|
app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask()));
|
||||||
|
|
||||||
app.setState<MainState>(); // register state and make active
|
app.setState<MainState>(); // register state and make active
|
||||||
app.run(); // run until finished
|
app.run(); // run until finished
|
||||||
|
Loading…
Reference in New Issue
Block a user