00001 /*************************************************************************** 00002 * Copyright (C) 2006-2008 by Antonello Lobianco * 00003 * http://regmas.org * 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 3 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 #ifndef MANAGERBASE_H 00021 #define MANAGERBASE_H 00022 00023 // standard headers 00024 #include <string> 00025 #include <vector> 00026 #include <stdexcept> 00027 #include <iostream> 00028 #include <sstream> 00029 00030 // regmas headers... 00031 #include "Agent_base.h" 00032 00033 using namespace std; 00034 class SuperAgentManager; //forward declaration 00035 00037 00047 class Manager_base: public BaseRegmas{ 00048 00049 public: 00050 Manager_base(ThreadManager* MTHREAD_h, string name_h); 00051 virtual ~Manager_base(); 00052 00056 virtual void riseMyAgents()=0; 00057 00058 virtual void locateMyAgents()=0; 00062 virtual void assignObjectsToAgents(); 00063 virtual void assignSpatialObjectsToAgents(){}; 00064 virtual void createBehaviours()=0; 00065 virtual void endInit(){}; 00066 virtual void prepare()=0; 00067 virtual void act()=0; 00068 virtual void update()=0; 00069 virtual void planNext()=0; 00070 00071 // data member access.. 00072 int getNewMouldLocalID(){int toReturn=mouldLocalIDCounter; mouldLocalIDCounter++; return toReturn;} 00073 int getNewAgentLocalID(){int toReturn=agentLocalIDCounter; agentLocalIDCounter++; return toReturn;} 00074 string getName(){return name;}; 00075 vector <Agent_base*>getMyAgents(){return managedAgents;}; 00076 int countMyAgents(){return managedAgents.size();}; 00077 00078 Agent_base * getAgentByLocalID(double localID_h); 00079 vector <Agent_base*>getRandomAgents(int size_h); 00080 00083 virtual void setAgentMoulds()=0; 00084 void rescaleMoulds(double factor_h); 00085 void setName(string name_h){name=name_h;}; 00086 vector<int> getMouldIDs(); 00087 int getMouldLocalIDCounter(){return mouldLocalIDCounter;}; 00088 int getManagerID(){return managerID;}; 00089 00090 protected: 00091 vector <Agent_base*> agentsMoulds; 00092 vector <Agent_base*> managedAgents; 00093 vector <Agent_base*> removedAgents; 00094 int mouldLocalIDCounter; 00095 int agentLocalIDCounter; 00096 string name; 00097 int managerID; 00098 Agent_base* collectorAgent; 00099 00100 }; 00101 #endif