00001 #ifndef CAJUN_RNDF_PARSER_H
00002 #define CAJUN_RNDF_PARSER_H
00003
00004
00005
00006
00007
00008
00009 #include <set>
00010 #include <string>
00011 #include <vector>
00012 #include "rndf_builder.H"
00013
00014
00015 namespace cajun
00016 {
00017 class rndf_parser_t;
00018 };
00019
00020
00021 int rndf_parse (char const *path_,
00022 cajun::rndf_parser_t *parser_,
00023 cajun::rndf_builder_t *builder_);
00024
00025
00026 namespace cajun
00027 {
00028
00029
00030 class rndf_parser_t
00031 {
00032 public:
00033 bool parse (std::string const &path_, rndf_builder_t *builder_);
00034
00035 protected:
00036 friend int ::rndf_parse (char const *path_,
00037 cajun::rndf_parser_t *parser_,
00038 cajun::rndf_builder_t *builder_);
00039
00040 std::string m_path;
00041
00042 unsigned m_id[3];
00043
00044 unsigned m_num_segments;
00045 unsigned m_num_lanes;
00046
00047 unsigned m_num_zones;
00048 unsigned m_num_spots;
00049
00050 unsigned m_num_waypts;
00051
00052 void error (unsigned line_, char const *msg_);
00053
00054 bool next_segment (unsigned id_);
00055 bool segment_list_complete ();
00056 bool next_lane (unsigned id_[2]);
00057 bool lane_list_complete ();
00058
00059 bool next_zone (unsigned id_);
00060 bool zone_list_complete ();
00061 bool next_perimeter (unsigned id_[2]);
00062 bool next_spot (unsigned id_[2]);
00063 bool spot_list_complete ();
00064
00065 bool next_waypt (unsigned id_[3]);
00066 bool waypt_list_complete ();
00067
00068 bool valid_waypt (unsigned id_[3]);
00069
00070 class waypt_id_t
00071 {
00072 public:
00073 waypt_id_t () { m_id[0] = m_id[1] = m_id[2] = 0; }
00074 waypt_id_t (unsigned const id_[3])
00075 { for (unsigned i = 0; i < 3; i++) m_id[i] = id_[i]; }
00076
00077 bool operator< (waypt_id_t const &v_) const
00078 {
00079 for (unsigned i = 0; i < 3; i++)
00080 if (m_id[i] != v_.m_id[i])
00081 return m_id[i] < v_.m_id[i];
00082 return false;
00083 }
00084 private:
00085 unsigned m_id[3];
00086 };
00087 std::set<waypt_id_t> m_waypt;
00088
00089 void register_waypt (unsigned id_[3]);
00090
00091 struct waypt_ref_t
00092 {
00093 unsigned line;
00094 waypt_id_t id;
00095 };
00096 std::vector<waypt_ref_t> m_waypt_ref;
00097
00098 void register_waypt_ref (unsigned line_, unsigned id_[3]);
00099
00100 struct checkpt_t
00101 {
00102 unsigned line;
00103 unsigned checkpt_id;
00104 waypt_id_t id;
00105 };
00106 std::vector<checkpt_t> m_checkpt;
00107
00108 void register_checkpt (unsigned line_,
00109 unsigned checkpt_id_, unsigned id_[3]);
00110
00111 bool verify_refs ();
00112 };
00113
00114
00115 };
00116
00117
00118 #endif