IODispatcher.h 4.8 KB
Newer Older
1
/**
2 3
 * \file        IODispatcher.h
 * \date        Nov 20, 2010
4
 * \version     v0.6
5
 * \copyright   <2009-2014> Forschungszentrum Jülich GmbH. All rights reserved.
Ulrich Kemloh's avatar
Ulrich Kemloh committed
6
 *
7
 * \section License
8 9 10
 * This file is part of JuPedSim.
 *
 * JuPedSim is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Lesser General Public License as published by
12 13 14 15 16 17 18 19
 * 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.
 *
20
 * You should have received a copy of the GNU Lesser General Public License
21 22
 * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
 *
23
 * \section Description
24 25
 *
 *
26 27
 **/

Ulrich Kemloh's avatar
Ulrich Kemloh committed
28
#ifndef _IODISPATCHER_H
Mohcine Chraibi's avatar
Mohcine Chraibi committed
29
#define _IODISPATCHER_H
Ulrich Kemloh's avatar
Ulrich Kemloh committed
30 31 32 33

#include "OutputHandler.h"
#include "../geometry/Building.h"

Ulrich Kemloh's avatar
Ulrich Kemloh committed
34 35
#include <cstring>
#include <vector>
Ulrich Kemloh's avatar
Ulrich Kemloh committed
36 37 38

extern OutputHandler* Log;

39 40 41 42
class Trajectories;

class IODispatcher
{
43
private:
44
     std::vector<Trajectories*> _outputHandlers;
45 46 47 48 49

public:
     IODispatcher();
     virtual ~IODispatcher();

50 51
     void AddIO(Trajectories* ioh);
     const std::vector<Trajectories*>& GetIOHandlers();
52
     void WriteHeader(long nPeds, double fps, Building* building, int seed);
53 54 55 56 57 58 59 60 61 62 63 64
     void WriteGeometry(Building* building);
     void WriteFrame(int frameNr, Building* building);
     void WriteFooter();
};

class Trajectories
{
public:
     Trajectories()
     {
          _outputHandler = NULL;
     };
65
     virtual ~Trajectories(){delete _outputHandler;};
66
     virtual void WriteHeader(long nPeds, double fps, Building* building, int seed)=0;
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
     virtual void WriteGeometry(Building* building)=0;
     virtual void WriteFrame(int frameNr, Building* building)=0;
     virtual void WriteFooter()=0;

     void Write(const std::string& str)
     {
          _outputHandler->Write(str);
     }
     void SetOutputHandler(OutputHandler* outputHandler)
     {
          _outputHandler=outputHandler;
     }

     template<typename A>
         bool IsElementInVector(const std::vector<A> &vec, A& el)
         {
              typename std::vector<A>::const_iterator it;
              it = std::find(vec.begin(), vec.end(), el);
              if (it == vec.end())
              {
                   return false;
              }
              else
              {
                   return true;
              }
         }

protected:
     OutputHandler* _outputHandler;
};


class TrajectoriesJPSV04: public Trajectories {

public:
     TrajectoriesJPSV04(){};
     virtual ~TrajectoriesJPSV04(){};

106
     virtual void WriteHeader(long nPeds, double fps, Building* building, int seed);
107 108 109
     virtual void WriteGeometry(Building* building);
     virtual void WriteFrame(int frameNr, Building* building);
     virtual void WriteFooter();
110 111
     std::string  WritePed(Pedestrian* ped);
};
112

113
class TrajectoriesJPSV05: public Trajectories {
114

115 116 117
public:
     TrajectoriesJPSV05(){};
     virtual ~TrajectoriesJPSV05(){};
Ulrich Kemloh's avatar
Ulrich Kemloh committed
118

119
     virtual void WriteHeader(long nPeds, double fps, Building* building, int seed);
120 121 122
     virtual void WriteGeometry(Building* building);
     virtual void WriteFrame(int frameNr, Building* building);
     virtual void WriteFooter();
Ulrich Kemloh's avatar
Ulrich Kemloh committed
123 124 125
};


126 127
class TrajectoriesFLAT: public Trajectories
{
Ulrich Kemloh's avatar
Ulrich Kemloh committed
128

129 130
public:
     TrajectoriesFLAT();
131 132 133 134
     virtual ~TrajectoriesFLAT()
     {
     }
     ;
Ulrich Kemloh's avatar
Ulrich Kemloh committed
135

136
     virtual void WriteHeader(long nPeds, double fps, Building* building, int seed);
137 138 139
     virtual void WriteGeometry(Building* building);
     virtual void WriteFrame(int frameNr, Building* building);
     virtual void WriteFooter();
140 141 142

};

143 144
class TrajectoriesVTK: public Trajectories
{
145

146 147
public:
     TrajectoriesVTK();
148 149 150 151
     virtual ~TrajectoriesVTK()
     {
     }
     ;
152

153
     virtual void WriteHeader(long nPeds, double fps, Building* building, int seed);
154 155 156
     virtual void WriteGeometry(Building* building);
     virtual void WriteFrame(int frameNr, Building* building);
     virtual void WriteFooter();
Ulrich Kemloh's avatar
Ulrich Kemloh committed
157 158 159

};

160 161
class TrajectoriesXML_MESH: public Trajectories
{
162

163
public:
164 165 166 167 168 169 170 171
     TrajectoriesXML_MESH()
     {
     }
     ;
     virtual ~TrajectoriesXML_MESH()
     {
     }
     ;
172

173 174 175 176
     //virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
     //virtual void WriteFrame(int frameNr, Building* building);
     //virtual void WriteFooter();
     virtual void WriteGeometry(Building* building);
177 178
};

179 180
class TrajectoriesJPSV06: public Trajectories
{
181

182
public:
183 184
     TrajectoriesJPSV06(){};
     virtual ~TrajectoriesJPSV06(){ };
185

186
     virtual void WriteHeader(long nPeds, double fps, Building* building, int seed);
187 188 189
     virtual void WriteGeometry(Building* building);
     virtual void WriteFrame(int frameNr, Building* building);
     virtual void WriteFooter();
190
};
Ulrich Kemloh's avatar
Ulrich Kemloh committed
191

Mohcine Chraibi's avatar
Mohcine Chraibi committed
192
#endif  /* _IODISPATCHER_H */