1 #ifndef LIBR2C2_BLOCKALLOCATOR_H_
2 #define LIBR2C2_BLOCKALLOCATOR_H_
5 #include <msp/datafile/objectloader.h>
16 class Loader: public Msp::DataFile::ObjectLoader<BlockAllocator>
23 Loader(BlockAllocator &);
31 typedef std::list<BlockIter> BlockList;
35 BlockList::iterator cur_blocks_end;
37 const Block *stop_at_block;
41 BlockAllocator(Train &);
43 void start_from(const BlockIter &);
45 bool empty() const { return blocks.empty(); }
46 void stop_at(const Block *);
48 const BlockIter &first() const;
49 const BlockIter &last() const;
50 const BlockIter &last_current() const;
51 const BlockIter &iter_for(const Block &) const;
53 bool has_block(const Block &) const;
54 bool is_block_current(const Block &) const;
56 BlockList::const_iterator find_block(const BlockList::const_iterator &, const BlockList::const_iterator &, const Block &) const;
61 bool reserve_block(const BlockIter &);
63 bool release_from(const Block &);
64 void release_noncurrent();
66 void release_blocks_begin(const BlockList::iterator &);
67 void release_blocks_end(const BlockList::iterator &);
68 void release_block(const BlockList::iterator &);
73 void turnout_path_changed(Track &);
74 void block_reserved(Block &, const Train *);
75 void sensor_state_changed(Sensor &, Sensor::State);
78 void save(std::list<Msp::DataFile::Statement> &) const;