X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.h;h=23a48c0ffbc40344ee3c98a04c5e6833a3173613;hb=2029c5e4220e0809a39744a28ca9e2ff22e8ad28;hp=64f02e50b7babe2242de6dd9d023b0e1075862f9;hpb=6dc18b0e518407bd2a86602bae1e9bbae05da7c8;p=r2c2.git diff --git a/source/libmarklin/block.h b/source/libmarklin/block.h index 64f02e5..23a48c0 100644 --- a/source/libmarklin/block.h +++ b/source/libmarklin/block.h @@ -1,12 +1,12 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ -#ifndef MARKLIN_3D_BLOCK_H_ -#define MARKLIN_3D_BLOCK_H_ +#ifndef LIBMARKLIN_BLOCK_H_ +#define LIBMARKLIN_BLOCK_H_ #include #include @@ -14,8 +14,9 @@ Distributed under the GPL namespace Marklin { +class Layout; +class Route; class Train; -class TrafficManager; class Block { @@ -31,32 +32,36 @@ public: }; private: - TrafficManager &trfc_mgr; + Layout &layout; unsigned id; unsigned sensor_id; unsigned turnout_id; std::set tracks; std::vector endpoints; - const Train *train; + Train *train; public: - Block(TrafficManager &, Track &); + Block(Layout &, Track &); + ~Block(); + unsigned get_id() const { return id; } unsigned get_sensor_id() const { return sensor_id; } unsigned get_turnout_id() const { return turnout_id; } const std::set &get_tracks() const { return tracks; } + bool has_track(Track &) const; const std::vector &get_endpoints() const { return endpoints; } - int get_endpoint_by_link(const Block &) const; - int traverse(unsigned, float * =0) const; + int get_endpoint_by_link(Block &) const; + unsigned traverse(unsigned, float * =0) const; + unsigned traverse(unsigned, const Route *, float * =0) const; void check_link(Block &); + void break_link(Block &); Block *get_link(unsigned) const; - bool reserve(const Train *); - const Train *get_train() const { return train; } + bool reserve(Train *); + Train *get_train() const { return train; } void print_debug(); private: void find_paths(Track &, unsigned, unsigned, std::set &); - - static unsigned next_id; + void determine_id(); }; } // namespace Marklin