]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/tracktype.h
Support more complex article numbers
[r2c2.git] / source / libmarklin / tracktype.h
index 310d17f4eca60fc748ef79e7d5a6964add537f69..b1aff1e0920e3229113c517d5fb228c62a511501 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -9,7 +9,8 @@ Distributed under the GPL
 #define LIBMARKLIN_TRACKTYPE_H_
 
 #include <msp/datafile/loader.h>
-#include "endpoint.h"
+#include "articlenumber.h"
+#include "geometry.h"
 #include "trackpart.h"
 
 namespace Marklin {
@@ -17,40 +18,52 @@ namespace Marklin {
 class TrackType
 {
 public:
-       class Loader: public Msp::DataFile::Loader
+       struct Endpoint
        {
-       private:
-               TrackType &ttype;
+               Point pos;
+               float dir;  // Direction outwards from the endpoint
+               unsigned paths;
+
+               Endpoint(float, float, float, unsigned);
+       };
 
+       class Loader: public Msp::DataFile::BasicLoader<TrackType>
+       {
        public:
                Loader(TrackType &);
-               TrackType &get_object() { return ttype; }
        private:
                virtual void finish();
-
                void part();
                void position(float, float, float);
        };
 
 private:
-       unsigned     art_nr;
-       std::string  description;
+       ArticleNumber art_nr;
+       std::string description;
        std::vector<TrackPart> parts;
        std::vector<Endpoint> endpoints;
+       bool double_address;
+       unsigned autofit_preference;
 
 public:
-       TrackType(unsigned);
+       TrackType(const ArticleNumber &);
 
-       unsigned get_article_number() const { return art_nr; }
+       const ArticleNumber &get_article_number() const { return art_nr; }
        const std::string &get_description() const { return description; }
        float get_total_length() const;
-       float get_route_length(int) const;
-       unsigned get_n_routes() const;
+       float get_path_length(int) const;
+       unsigned get_paths() const;
+       unsigned get_n_paths() const;
+       bool is_turnout() const;
+       bool is_dead_end() const;
+       bool is_double_address() const { return double_address; }
+       unsigned get_autofit_preference() const { return autofit_preference; }
        const std::vector<TrackPart> &get_parts() const { return parts; }
-       const std::vector<Endpoint>  &get_endpoints() const { return endpoints; }
+       const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
+       TrackPoint get_point(unsigned, unsigned, float) const;
 
 private:
-       void  collect_endpoints();
+       void collect_endpoints();
 };
 
 } // namespace Marklin