]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/block.h
Change terminology to better distinguish routes on the layout from paths across track...
[r2c2.git] / source / libmarklin / block.h
index 4a22aa97862bfc2019890aefc8090f83e7114ea9..64f02e50b7babe2242de6dd9d023b0e1075862f9 100644 (file)
@@ -1,3 +1,10 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2006-2009  Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
 #ifndef MARKLIN_3D_BLOCK_H_
 #define MARKLIN_3D_BLOCK_H_
 
@@ -16,36 +23,41 @@ public:
        struct Endpoint
        {
                Track *track;
-               const Track::Endpoint *track_ep;
-               Block  *link;
-               unsigned routes;
+               unsigned track_ep;
+               Block *link;
+               unsigned paths;
 
-               Endpoint(Track *, const Track::Endpoint *);
+               Endpoint(Track *, unsigned);
        };
-       typedef std::list<Endpoint> EndpointSeq;
 
-       Block(TrafficManager &, Track *);
+private:
+       TrafficManager &trfc_mgr;
+       unsigned id;
+       unsigned sensor_id;
+       unsigned turnout_id;
+       std::set<Track *> tracks;
+       std::vector<Endpoint> endpoints;
+       const Train *train;
+
+public:
+       Block(TrafficManager &, Track &);
+
        unsigned get_sensor_id() const { return sensor_id; }
-       const TrackSet &get_tracks() const { return tracks; }
-       const EndpointSeq &get_endpoints() const { return endpoints; }
-       const Endpoint *get_endpoint_by_link(const Block *) const;
-       const Endpoint *traverse(const Endpoint *) const;
+       unsigned get_turnout_id() const { return turnout_id; }
+       const std::set<Track *> &get_tracks() const { return tracks; }
+       const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
+       int get_endpoint_by_link(const Block &) const;
+       int traverse(unsigned, float * =0) const;
        void check_link(Block &);
+       Block *get_link(unsigned) const;
        bool reserve(const Train *);
+       const Train *get_train() const { return train; }
        void print_debug();
 private:
-       TrafficManager &trfc_mgr;
-       unsigned       id;
-       unsigned       sensor_id;
-       TrackSet       tracks;
-       EndpointSeq    endpoints;
-       const Train    *train;
-
-       void find_routes(Track *, const Track::Endpoint *, unsigned, TrackSet &);
+       void find_paths(Track &, unsigned, unsigned, std::set<Track *> &);
 
        static unsigned next_id;
 };
-typedef std::list<Block *> BlockSeq;
 
 } // namespace Marklin