X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.h;h=abcd87cd9b02221edba66d33955eca56abe8c7ad;hb=651698847d5293cfb15b6fb23a394701388c0151;hp=4a22aa97862bfc2019890aefc8090f83e7114ea9;hpb=06c100aacb559fbbe7380e15981c4772092c269b;p=r2c2.git diff --git a/source/libmarklin/block.h b/source/libmarklin/block.h index 4a22aa9..abcd87c 100644 --- a/source/libmarklin/block.h +++ b/source/libmarklin/block.h @@ -1,5 +1,12 @@ -#ifndef MARKLIN_3D_BLOCK_H_ -#define MARKLIN_3D_BLOCK_H_ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#ifndef LIBMARKLIN_BLOCK_H_ +#define LIBMARKLIN_BLOCK_H_ #include #include @@ -7,8 +14,8 @@ namespace Marklin { +class Layout; class Train; -class TrafficManager; class Block { @@ -16,36 +23,43 @@ 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 EndpointSeq; - Block(TrafficManager &, Track *); +private: + Layout &layout; + unsigned id; + unsigned sensor_id; + unsigned turnout_id; + std::set tracks; + std::vector endpoints; + Train *train; + +public: + Block(Layout &, Track &); + ~Block(); + + unsigned get_id() const { return id; } 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 &get_tracks() const { return tracks; } + const std::vector &get_endpoints() const { return endpoints; } + int get_endpoint_by_link(const Block &) const; + unsigned traverse(unsigned, float * =0) const; void check_link(Block &); - bool reserve(const Train *); + void break_link(Block &); + Block *get_link(unsigned) const; + bool reserve(Train *); + 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 &); - - static unsigned next_id; + void find_paths(Track &, unsigned, unsigned, std::set &); + void determine_id(); }; -typedef std::list BlockSeq; } // namespace Marklin