diff --git a/core/idle.cpp b/core/idle.cpp index 899a291e..647c26f3 100644 --- a/core/idle.cpp +++ b/core/idle.cpp @@ -1,4 +1,5 @@ -/* +/** + * @file * Copyright 2013 (c) Anna Schumaker. */ #include diff --git a/include/core/idle.h b/include/core/idle.h index 0baa51f9..7067d971 100644 --- a/include/core/idle.h +++ b/include/core/idle.h @@ -1,23 +1,47 @@ -/* +/** + * @file * Copyright 2013 (c) Anna Schumaker. */ #ifndef OCARINA_CORE_IDLE_H #define OCARINA_CORE_IDLE_H +/** + * Namespace for controlling idle tasks. + */ namespace idle { + /** + * Base class for creating new IdleTasks. + */ class IdleBase { protected: + /** + * Add the IdleBase to the idle queue. + */ void schedule(); public: + /** + * Constructor for the IdleBase class. + */ IdleBase(); + + /** + * IdleBase destructor. + */ virtual ~IdleBase(); + + /** + * Run the idle task. + */ virtual void run() = 0; }; + /** + * Generic IdleTask class. + */ template class IdleTask : public IdleBase { private: @@ -25,19 +49,46 @@ namespace idle T data; public: + /** + * IdleTask constructor. + * @param func Function to call when running this task. + * @param data Data to pass to the function. + */ IdleTask(void (*)(T &), T); + + /** + * IdleTask destructor. + */ ~IdleTask(); + + /** + * Run the IdleTask. + */ void run(); }; + /** + * Create a new IdleTask and add it to the queue. + * @param func Function to call when running the new task. + * @param data Data to pass to the function. + */ template static inline void schedule(void (*func)(T &), T param) { new IdleTask(func, param); } + /** + * Run the next task on the idle queue. + * @return True if there are still tracks on the queue, false otherwise. + */ bool run_task(); + + /** + * Call to find the progress of the idle queue. + * @return A fraction representing the idle queue progress. + */ float get_progress(); }; diff --git a/include/core/idle.hpp b/include/core/idle.hpp index b548ad63..5fc466eb 100644 --- a/include/core/idle.hpp +++ b/include/core/idle.hpp @@ -1,4 +1,5 @@ -/* +/** + * @file * Copyright 2013 (c) Anna Schumaker. * * DO NOT INCLUDE THIS FILE DIRECTLY. THIS IS A TEMPLATE DEFINITION FILE