From e7658ccce408e18cdeb03faa0be410987343c0d0 Mon Sep 17 00:00:00 2001 From: James Turk Date: Wed, 17 Aug 2005 06:35:54 +0000 Subject: [PATCH] Kernel --> TaskManager --- RELEASE-HOWTO.txt | 45 ++++++++++++-------- include/Application.hpp | 28 ++++++------ include/photon.hpp | 4 +- include/{ => util}/Task.hpp | 20 +++++---- include/{Kernel.hpp => util/TaskManager.hpp} | 41 +++++++++--------- ndoc/Menu.txt | 2 +- photon.mm | 5 +-- src/Application.cpp | 20 ++++----- src/{ => util}/Task.cpp | 7 ++- src/{Kernel.cpp => util/TaskManager.cpp} | 27 ++++++------ test/Audio_test.cpp | 4 +- test/FPSDisplayTask.hpp | 9 +++- test/Font_test.cpp | 4 +- test/Image_test.cpp | 4 +- test/Input_test.cpp | 4 +- test/Pen_test.cpp | 4 +- test/Texture_test.cpp | 4 +- 17 files changed, 128 insertions(+), 104 deletions(-) rename include/{ => util}/Task.hpp (92%) rename include/{Kernel.hpp => util/TaskManager.hpp} (71%) rename src/{ => util}/Task.cpp (89%) rename src/{Kernel.cpp => util/TaskManager.cpp} (87%) diff --git a/RELEASE-HOWTO.txt b/RELEASE-HOWTO.txt index a2c4aed..3aa692f 100644 --- a/RELEASE-HOWTO.txt +++ b/RELEASE-HOWTO.txt @@ -1,22 +1,31 @@ -Sanity Check - Check Compilation from CVS - Ensure Tests Run from CVS - Sanity Check NaturalDocs -Bump Version Number +Process: + human: bump version numbers* + script: checkout fresh CVS + script: check building of library & tests + 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 src/Application.cpp : photonVer_ CHANGELOG.txt photon.mm - Tag CVS with version number -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 - - -$Id: RELEASE-HOWTO.txt,v 1.3 2005/08/08 22:54:15 cozman Exp $ + CVS Tag + +**Non-Distribution Files: + photon/.cvsignore + photon/docs/.cvsignore + photon/ndoc/.cvsignore + +$Id: RELEASE-HOWTO.txt,v 1.4 2005/08/17 06:35:54 cozman Exp $ diff --git a/include/Application.hpp b/include/Application.hpp index b9ab3fc..129e29d 100644 --- a/include/Application.hpp +++ b/include/Application.hpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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 #define PHOTON_APPLICATION_HPP @@ -20,7 +20,7 @@ #include "types.hpp" #include "util/VersionInfo.hpp" #include "State.hpp" -#include "Kernel.hpp" +#include "util/TaskManager.hpp" #include "audio/AudioCore.hpp" #include "util/Singleton.hpp" @@ -64,21 +64,21 @@ public: // Sets Quit flag, terminating application. void quit(); - // Function: getUpdateKernel - // Access the application's update , registered with this - // kernel are executed after the current . + // Function: getUpdateTaskManager + // Access the application's update , registered with + // this TaskManager are executed after the current . // // Returns: - // Reference to "Update Kernel" - Kernel& getUpdateKernel(); + // Reference to "Update TaskManager" + util::TaskManager& getUpdateTaskManager(); - // Function: getRenderKernel - // Access the application's render , registered with this - // kernel are executed after the current . + // Function: getRenderTaskManager + // Access the application's render , registered with + // this TaskManager are executed after the current . // // Returns: - // Reference to "Render Kernel" - Kernel& getRenderKernel(); + // Reference to "Render TaskManager" + util::TaskManager& getRenderTaskManager(); // Function: isActive // Checks if application is active, which on most systems simply means it @@ -429,8 +429,8 @@ private: // other bool quit_; - Kernel updateKernel_; - Kernel renderKernel_; + util::TaskManager updateTaskManager_; + util::TaskManager renderTaskManager_; // state system static std::stack stateStack_; diff --git a/include/photon.hpp b/include/photon.hpp index 7ebb0ab..e7f226a 100644 --- a/include/photon.hpp +++ b/include/photon.hpp @@ -1,11 +1,9 @@ #ifndef PHOTON_HPP #define PHOTON_HPP -#include "Kernel.hpp" #include "types.hpp" #include "State.hpp" #include "Application.hpp" -#include "Task.hpp" #include "exceptions.hpp" #include "photon.hpp" #include "entrypoint.hpp" @@ -22,7 +20,9 @@ #include "math/Circle.hpp" #include "util/ConfigFile.hpp" #include "util/VersionInfo.hpp" +#include "util/Task.hpp" #include "util/Singleton.hpp" +#include "util/TaskManager.hpp" #include "util/RandGen.hpp" #include "util/Timer.hpp" #include "util/FileBuffer.hpp" diff --git a/include/Task.hpp b/include/util/Task.hpp similarity index 92% rename from include/Task.hpp rename to include/util/Task.hpp index 0bb6faa..5c6ac3b 100644 --- a/include/Task.hpp +++ b/include/util/Task.hpp @@ -5,10 +5,10 @@ // James Turk (jpt2433@rit.edu) // // 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 -#define PHOTON_TASK_HPP +#ifndef PHOTON_UTIL_TASK_HPP +#define PHOTON_UTIL_TASK_HPP #include @@ -16,6 +16,8 @@ namespace photon { +namespace util +{ // Title: Task @@ -38,7 +40,8 @@ enum PriorityLevel }; // Class: Task -// Abstract class for tasks, which are runnable classes for use with . +// Abstract class for tasks, which are runnable classes for use with +// . // // When writing a task, only update() needs to be overloaded. class Task @@ -51,7 +54,7 @@ public: // Parameters: // name - Name for task, must be unique! // priority - Optional argument for desired priority for the Task, - // controls order in which tasks are run by the . + // controls order in which tasks are run by the . // Default Priority is PRI_NORMAL Task(const std::string& name, PriorityLevel priority=PRI_NORMAL); @@ -97,8 +100,8 @@ public: virtual void onUnpause(); // Function: kill - // Sets state of application to dead, dead tasks remove themselves from - // the Kernel's task pool. + // Sets state of task to dead, dead tasks remove themselves from the + // 's task pool. void kill(); // Group: Accessors @@ -144,6 +147,7 @@ private: // via a pointer. typedef shared_ptr TaskPtr; +} } -#endif //PHOTON_TASK_HPP +#endif //PHOTON_UTIL_TASK_HPP diff --git a/include/Kernel.hpp b/include/util/TaskManager.hpp similarity index 71% rename from include/Kernel.hpp rename to include/util/TaskManager.hpp index 9139067..d63f199 100644 --- a/include/Kernel.hpp +++ b/include/util/TaskManager.hpp @@ -5,10 +5,10 @@ // James Turk (jpt2433@rit.edu) // // 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 -#define PHOTON_KERNEL_HPP +#ifndef PHOTON_UTIL_TASKMANAGER_HPP +#define PHOTON_UTIL_TASKMANAGER_HPP #include #include @@ -17,31 +17,33 @@ namespace photon { +namespace util +{ -// Class: Kernel -// Kernel class, maintains a list of and manages their status, +// Class: TaskManager +// TaskManager class, maintains a list of and manages their status, // handles adding, deleting, pausing, and unpausing tasks. // -// To use Kernel: +// To use TaskManager: // - (1) Add any tasks (should be derived from ) // - (2) Call step() every frame when task should update. -class Kernel +class TaskManager { // Group: (Con/De)structors public: - // Function: Kernel - // Kernel constructor, initializes kernel singleton. - Kernel(); + // Function: TaskManager + // TaskManager constructor, initializes task manager + TaskManager(); - // Function: ~Kernel - // Kernel destructor, destroys kernel singleton. - ~Kernel(); + // Function: ~TaskManager + // TaskManager destructor, destroys task manager + ~TaskManager(); // Group: Running public: // 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 // tasks have the same priority, they are run in the order they were added. @@ -54,7 +56,7 @@ public: // Group: Task Management public: // Function: addTask - // Add a new to the Kernel's list. All tasks MUST have unique + // Add a new to the TaskManager's list. All tasks MUST have unique // names. // // Parameters: @@ -62,7 +64,7 @@ public: void addTask(TaskPtr task); // 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. // // Parameters: @@ -70,14 +72,14 @@ public: void killTask(const std::string& taskName); // Function: pauseTask - // Pause a task in the Kernel task list. + // Pause a task in the TaskManager task list. // // Parameters: // taskName - Name of task to pause. void pauseTask(const std::string& taskName); // Function: unpauseTask - // Unpause a task in the Kernel task list. + // Unpause a task in the TaskManager task list. // // Parameters: // taskName - Name of task to unpause. @@ -102,6 +104,7 @@ private: }; }; +} } -#endif //PHOTON_KERNEL_HPP +#endif //PHOTON_UTIL_TASKMANAGER_HPP diff --git a/ndoc/Menu.txt b/ndoc/Menu.txt index d26ba85..c13d079 100644 --- a/ndoc/Menu.txt +++ b/ndoc/Menu.txt @@ -32,7 +32,6 @@ Group: photon:: { File: Application (Application.hpp) File: Basic Types (types.hpp) File: Exception/Error Types (exceptions.hpp) - File: Kernel (Kernel.hpp) File: Log (Log.hpp) File: Logging Utilities (LogSink.hpp) File: PhotonMain (entrypoint.hpp) @@ -40,6 +39,7 @@ Group: photon:: { File: ResourceManager (ResourceManager.hpp) File: State (State.hpp) File: Task (Task.hpp) + File: TaskManager (Kernel.hpp) Group: Audio:: { diff --git a/photon.mm b/photon.mm index 427e35c..252e0c8 100644 --- a/photon.mm +++ b/photon.mm @@ -21,7 +21,7 @@ - + @@ -183,12 +183,11 @@ - + - diff --git a/src/Application.cpp b/src/Application.cpp index 847b71e..0a5027c 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" @@ -118,14 +118,14 @@ void Application::update() while(timeAccumulator_ >= fixedTimeStep_) { stateStack_.top()->update(fixedTimeStep_); - updateKernel_.step(fixedTimeStep_); + updateTaskManager_.step(fixedTimeStep_); timeAccumulator_ -= fixedTimeStep_; } } else { stateStack_.top()->update(elapsedTime_); - updateKernel_.step(elapsedTime_); + updateTaskManager_.step(elapsedTime_); } } @@ -135,7 +135,7 @@ void Application::update() // clear everything before rendering glClear(clearFlags_); stateStack_.top()->render(); - renderKernel_.step(fixedTimeStep_); + renderTaskManager_.step(fixedTimeStep_); glfwSwapBuffers(); // swap buffers after rendering } } @@ -147,14 +147,14 @@ void Application::quit() 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() @@ -305,8 +305,6 @@ void Application::setOrthoProjection(scalar width, scalar height) //back to modelview glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - - setDepthBufferParams(true); } void Application::setPerspectiveProjection(scalar fovy, scalar zNear, @@ -323,6 +321,8 @@ void Application::setPerspectiveProjection(scalar fovy, scalar zNear, //back to modelview glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + setDepthBufferParams(true); } void Application::setDepthBufferParams(bool enable, scalar depth) diff --git a/src/Task.cpp b/src/util/Task.cpp similarity index 89% rename from src/Task.cpp rename to src/util/Task.cpp index ccf58af..201d09b 100644 --- a/src/Task.cpp +++ b/src/util/Task.cpp @@ -5,12 +5,14 @@ // James Turk (jpt2433@rit.edu) // // 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 util +{ Task::Task(const std::string& name, PriorityLevel priority) : name_(name), priority_(priority), alive_(true), paused_(false) @@ -60,3 +62,4 @@ bool Task::isPaused() const } } +} diff --git a/src/Kernel.cpp b/src/util/TaskManager.cpp similarity index 87% rename from src/Kernel.cpp rename to src/util/TaskManager.cpp index 16e540b..d7721d4 100644 --- a/src/Kernel.cpp +++ b/src/util/TaskManager.cpp @@ -5,27 +5,27 @@ // James Turk (jpt2433@rit.edu) // // 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 "Log.hpp" - namespace photon { +namespace util +{ -Kernel::Kernel() +TaskManager::TaskManager() { } -Kernel::~Kernel() +TaskManager::~TaskManager() { killAllTasks(); } -void Kernel::step(scalar timeDelta) +void TaskManager::step(scalar timeDelta) { std::list::iterator it; @@ -59,7 +59,7 @@ void Kernel::step(scalar timeDelta) } } -void Kernel::addTask(TaskPtr task) +void TaskManager::addTask(TaskPtr task) { std::list::iterator it = tasks_.begin(); // attempt to find task @@ -84,7 +84,7 @@ void Kernel::addTask(TaskPtr task) 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 std::list::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 std::list::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 std::list::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 for(std::list::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 { return lhs->getName() == rhs; } } +} diff --git a/test/Audio_test.cpp b/test/Audio_test.cpp index d0e1b3d..17492bf 100644 --- a/test/Audio_test.cpp +++ b/test/Audio_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" using namespace photon; @@ -190,7 +190,7 @@ int PhotonMain(const StrVec& args) app.initAudioCore(); // initialize audio core // be sure to add FPSDisplayTask - //Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); + app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.setState(); // register state and make active app.run(); // run until finished diff --git a/test/FPSDisplayTask.hpp b/test/FPSDisplayTask.hpp index efbc35a..3f78f9c 100644 --- a/test/FPSDisplayTask.hpp +++ b/test/FPSDisplayTask.hpp @@ -7,7 +7,12 @@ // 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 // 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: FPSDisplayTask() : @@ -16,7 +21,7 @@ public: lastUpdate(0) { } - void update() + void update(scalar timeDelta) { // update (at most) once a second if(app.getTime() - lastUpdate > 1.0) diff --git a/test/Font_test.cpp b/test/Font_test.cpp index 13559ef..29a36e8 100644 --- a/test/Font_test.cpp +++ b/test/Font_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" using namespace photon; @@ -54,7 +54,7 @@ int PhotonMain(const StrVec& args) app.createDisplay(800,600,32,0,0,false); // create window // be sure to add FPSDisplayTask - //Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); + //TaskManager::getInstance().addTask(util::TaskPtr(new FPSDisplayTask())); app.setState(); // register state and make active app.run(); // run until finished diff --git a/test/Image_test.cpp b/test/Image_test.cpp index 4f2c0f8..1f6e270 100644 --- a/test/Image_test.cpp +++ b/test/Image_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" using namespace photon; @@ -65,7 +65,7 @@ int PhotonMain(const StrVec& args) app.createDisplay(800,600,32,0,0,false); // create window // be sure to add FPSDisplayTask - //Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); + app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.setState(); // register state and make active app.run(); // run until finished diff --git a/test/Input_test.cpp b/test/Input_test.cpp index b498d62..b116695 100644 --- a/test/Input_test.cpp +++ b/test/Input_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" using namespace photon; @@ -124,7 +124,7 @@ int PhotonMain(const StrVec& args) app.createDisplay(800,600,32,0,0,false); // create window // be sure to add FPSDisplayTask - //Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); + app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.setState(); // register state and make active app.run(); // run until finished diff --git a/test/Pen_test.cpp b/test/Pen_test.cpp index 5f02619..d3b1329 100644 --- a/test/Pen_test.cpp +++ b/test/Pen_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" using namespace photon; @@ -78,7 +78,7 @@ int PhotonMain(const StrVec& args) app.createDisplay(800,600,32,0,0,false); // create window // be sure to add FPSDisplayTask - //Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); + app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.setState(); // register state and make active app.run(); // run until finished diff --git a/test/Texture_test.cpp b/test/Texture_test.cpp index 2186c65..d05f578 100644 --- a/test/Texture_test.cpp +++ b/test/Texture_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // 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" using namespace photon; @@ -78,7 +78,7 @@ int PhotonMain(const StrVec& args) app.createDisplay(800,600,32,0,0,false); // create window // be sure to add FPSDisplayTask - //Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); + app.getUpdateTaskManager().addTask(util::TaskPtr(new FPSDisplayTask())); app.setState(); // register state and make active app.run(); // run until finished