AgentsSource.h 3.97 KB
Newer Older
1 2 3
/**
 * \file        AgentSource.h
 * \date        Apr 04, 2015
4 5
 * \version     v0.7
 * \copyright   <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
6
 *
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 * \section License
 * This file is part of JuPedSim.
 *
 * JuPedSim is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * JuPedSim is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
 *
 * \section Description
 * This class is responsible for materialising agent in a given location at a given frequency.
 * The optimal position where to put the agents is given by various algorithms, for instance
 * the Voronoi algorithm or the Mitchell Best candidate algorithm.
 *
 **/
29 30 31 32 33 34

#ifndef AGENTSOURCE_H_
#define AGENTSOURCE_H_

#include <string>
#include <vector>
35
#include <memory>
36 37 38

class Pedestrian;
class OutputHandler;
39
class StartDistribution;
40
class Building;
41 42 43 44 45 46 47 48 49 50 51

// external variables
extern OutputHandler* Log;


class AgentsSource
{
public:
     /**
      * Constructor
      */
52
     AgentsSource(int id, const std::string& caption,int max_agents,int group_id,int frequency, bool greedy, double time, int agent_id);
53 54 55 56 57 58 59 60 61 62

     /**
      * Destructor
      */
     virtual ~AgentsSource();

     /**
      * Add a new agent to this source
      * @param ped
      */
63
     void AddToPool(Pedestrian* ped);
64 65 66 67 68 69 70

     /**
      * Generate a number of agents, based on the frequency given in the constructor.
      * No agents are generated if the the maximum (_maxAgents) is reached.
      * @see _maxAgents
      * @param ped
      */
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
     void GenerateAgentsAndAddToPool(int count, Building* building);

     /**
      * Generate agents, but do not add them to the pool
      * @param ped, the container for the agents
      * @param count, the number of agents to generate
      * @param building, a pointer to the building object
      */
     void GenerateAgents(std::vector<Pedestrian*>& peds, int count, Building* building);

     /**
      * Generate count agents and save them in the vector
      * @param ped, the container for the agents
      * @param count, the number of agents to generate
      */
     void RemoveAgentsFromPool(std::vector<Pedestrian*>& peds, int count);
87

88 89 90 91 92 93 94
     /**
      * Add the agents to the pool. This might be important in the case the removed agents could not
      * be placed correctly. They can be requeued using this function.
      * @param peds
      */
     void AddAgentsToPool(std::vector<Pedestrian*>& peds);

95 96 97 98 99 100 101 102 103 104 105 106 107
     /**
      * @return the number of agents remaining
      */
     int GetPoolSize() const;

     /**
      * Print relevant information
      */
     void Dump() const;

     int GetAgentsGenerated() const;
     void SetAgentsGenerated(int agentsGenerated);
     const double* GetBoundaries() const;
108
     void Setboundaries(double * bounds);
109 110 111 112
     const std::string& GetCaption() const;
     int GetFrequency() const;
     int GetGroupId() const;
     int GetId() const;
113 114
     int GetAgentId() const;
     double GetPlanTime() const;
115
     int GetMaxAgents() const;
Mohcine Chraibi's avatar
Mohcine Chraibi committed
116
     bool Greedy() const;
117
     void SetStartDistribution(std::shared_ptr<StartDistribution>);
118 119
     const std::shared_ptr<StartDistribution> GetStartDistribution() const;

120 121 122 123 124 125 126

private:
     int _id=-1;
     int _frequency=0;
     int _maxAgents=0;
     int _groupID=-1;
     std::string _caption="no caption";
Mohcine Chraibi's avatar
Mohcine Chraibi committed
127 128 129
     bool _greedy = false;
     int _agentsGenerated=0;
     double _boundaries[4];// = { 0, 0, 0, 0 };
130 131
     int _agent_id;
     double _time;
132
     std::vector<Pedestrian*> _agents;
133
     std::shared_ptr<StartDistribution> _startDistribution;
134 135 136 137 138

};

#endif /* AGENTSOURCE_H_ */