TaskScheduler.hpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename TaskScheduler.hpp
00024  * @Description TaskScheduler declaration
00025  * @Status Work in Progress
00026  * @Version $Id: TaskScheduler.hpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer nmsra (nmsra@mega.ist.utl.pt)
00028  */
00029 
00030 #ifndef __ACTIVEOBJECT_TASKSCHEDULER_H
00031 #define __ACTIVEOBJECT_TASKSCHEDULER_H
00032 
00033 #include "Task.hpp"
00034 #include "TaskSchedulerPolicy.hpp"
00035 
00036 #include <queue>
00037 
00038 
00039 
00040 namespace mermaid
00041 {
00042   namespace support
00043   {
00044     namespace activeobject
00045     {
00046     
00047       using boost::shared_ptr;
00048       
00049       /**
00050       * @Typedef typedef priority_queue<Task*, vector<Task*>, TaskSchedulerPolicy> SchedulingQueue
00051       * @Description SchedulingQueue type.
00052       * @Author Marco Barbosa + Nelson Ramos
00053       */
00054       typedef std::priority_queue<shared_ptr<Task>, std::vector<shared_ptr<Task> >, TaskSchedulerPolicy> SchedulingQueue;
00055       
00056       /**
00057       * @Class TaskScheduler TaskScheduler.hpp "TaskScheduler.hpp"
00058       * @Description TaskScheduler class
00059       * @Author Marco Barbosa + Nelson Ramos
00060       */
00061       class TaskScheduler
00062       {
00063         public:
00064           /**
00065           * @Description Default constructor
00066           * @Author Marco Barbosa + Nelson Ramos
00067           */
00068           TaskScheduler();
00069           
00070           /**
00071           * @Description Adds a Task to the TaskScheduler.
00072           * @Param t Task to be added to TaskScheduler
00073           * @Author Marco Barbosa + Nelson Ramos
00074           */
00075           void addTask (shared_ptr<Task> t);
00076           
00077           /**
00078           * @Description Getter for the next scheduled Task.
00079           * @Returns Task that should be run next according to the current scheduling policy of the TaskScheduler os invalid pointer if no task is available
00080           * @Author Marco Barbosa + Nelson Ramos
00081           */
00082           shared_ptr<Task> getNextTask();
00083           
00084           /**
00085           * @Description Peaker for the next scheduled Task. Returns the next task but doesn't remove it from the scheduler
00086           * @Returns Task that should be run next according to the current scheduling policy of the TaskScheduler or invalid pointer if no task is available
00087           * @Author Marco Barbosa + Nelson Ramos
00088           */
00089           shared_ptr<Task> peakNextTask();
00090           
00091           /**
00092           * @Description Policy setter. Sets the policy that should be used by the TaskScheduler
00093           * p Policy that TaskScheduler should use.
00094           * @Author Marco Barbosa + Nelson Ramos
00095           */
00096           //        void setSchedulerPolicy(TaskSchedulerPolicy p);
00097           
00098         private:
00099           shared_ptr<SchedulingQueue> sq_;
00100           TaskSchedulerPolicy policy_;
00101       };
00102     } // namespace activeobject
00103   } // namespace support
00104 } // namespace mermaid
00105 
00106 
00107 #endif // __ACTIVEOBJECT_TASKSCHEDULER_H
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3