simple_task_manager.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Kutumov Alexey                                  *
00003  *   ru.pixel@gmail.com                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00034 #include "gpucalc/simple_task_manager.h"
00035 
00036 
00037 namespace gpucalc
00038 {
00039 
00040  SimpleTaskManager::SimpleTaskManager(): TaskManager(_SimpleTaskManagerName), mSimpleTaskMap()
00041  {
00042  }
00043 
00044 
00045  SimpleTaskManager::~SimpleTaskManager()
00046  {
00047   clearContainer(mSimpleTaskMap);
00048  }
00049 
00050 
00051  Task * SimpleTaskManager::create(const std::string & TaskName, bool ReturnIfExists)
00052  {
00053   SimpleTaskMap::iterator i = mSimpleTaskMap.find(TaskName);
00054   if (i != mSimpleTaskMap.end())
00055   {
00056    if (ReturnIfExists)
00057    {
00058     return i->second;
00059    }
00060    else
00061    {
00062     Except<ERR_DUPLICATE_ITEM>(this, "Simple Task \"" + TaskName + "\" already exists.", "SimpleTaskManager::createTask()", __FILE__, __LINE__);
00063     return 0;
00064    }
00065   }
00066   else
00067   {
00068    SimpleTask * task = new SimpleTask(TaskName);
00069    addToContainer(task, TaskName, mSimpleTaskMap);
00070    return task;
00071   }
00072  }
00073 
00074 
00075  Task * SimpleTaskManager::find(const std::string & TaskName)
00076  {
00077   SimpleTaskMap::iterator i = mSimpleTaskMap.find(TaskName);
00078   if (i != mSimpleTaskMap.end())
00079   {
00080    return i->second;
00081   }
00082   else
00083   {
00084    Except<ERR_ITEM_NOT_FOUND>(this, "Simple Task \"" + TaskName + "\" cannot be found.", "Simpletaskmanager::find()", __FILE__, __LINE__);
00085    return 0;
00086   }
00087  }
00088 
00089 
00090  void SimpleTaskManager::destroy(Task * task)
00091  {
00092   if (!removeFromContainer(task->getObjectName(), mSimpleTaskMap))
00093   {
00094    Warning<ERR_ITEM_NOT_FOUND>(this, "SimpleTask \"" + task->getObjectName() + "\" cannot de found!!! Destroying anyway.",
00095     "SimpleTaskManager::deleteTask()", __FILE__, __LINE__);
00096    delete task;
00097   }
00098  }
00099 
00100 
00101 }

Generated on Thu Mar 5 22:36:42 2009 for gpucalc by  doxygen 1.5.6