Facebook
From Soft Zebra, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 49
  1. //
  2. // pedsim - A microscopic pedestrian simulation system.
  3. // Copyright (c) 2003 - 2014 by Christian Gloor
  4. //
  5. //
  6. // Adapted for Low Level Parallel Programming 2015
  7. //
  8.  
  9. #ifndef _parsescenario_h_
  10. #define _parsescenario_h_
  11.  
  12. #include "ped_agent.h"
  13. #include "ped_waypoint.h"
  14. #include <QtCore>
  15. #include <QXmlStreamReader>
  16. #include <vector>
  17. #include <set>
  18.  
  19. using namespace std;
  20.  
  21. class ParseScenario : public QObject
  22. {
  23.         Q_OBJECT
  24.  
  25. public:
  26.         ParseScenario(QString file);
  27.  
  28.         // returns the collection of agents defined by this scenario
  29.         vector<Ped::Tagent*> getAgents() const;
  30.         std::vector<Ped::Twaypoint*> getWaypoints();
  31.         private slots:
  32.         void processXmlLine(QByteArray data);
  33.         // contains all defined waypoints
  34.  
  35. private:
  36.         QXmlStreamReader xmlReader;
  37.  
  38.         // final collection of all created agents
  39.         vector<Ped::Tagent*> agents;
  40.  
  41.         // temporary collection of agents used to
  42.         // keep track of all agents that are generated
  43.         // within the current opened agents xml tag
  44.         vector<Ped::Tagent*> tempAgents;
  45.  
  46.         // contains all defined waypoints
  47.         map<QString, Ped::Twaypoint*> waypoints;
  48.  
  49.         // decides what to do on a new xml tag (tags: agent, waypoint, addwaypoint)
  50.         void handleXmlStartElement();
  51.  
  52.         // decides what to do if an xml tag is closed
  53.         void handleXmlEndElement();
  54.  
  55.         // creates a new waypoint on a waypoint xml tag
  56.         void createWaypoint();
  57.  
  58.         // creates a new agents on an agent xml tag
  59.         void createAgents();
  60.  
  61.         // add (by ID-)defined waypoint to current agents
  62.         void addWaypointToCurrentAgents(QString &id);
  63.  
  64.         QString readString(const QString &tag);
  65.         double readDouble(const QString &tag);
  66. };
  67.  
  68. #endif
  69.  
  70.  
  71. ParseScenario.h
  72.  
  73. Open with
  74.  
  75.  
  76.  
  77.  
  78.  
  79.