+#include "engraver-group-engraver.hh"
+#include "bar.hh"
+#include "rest.hh"
+#include "engraver.hh"
+#include "item.hh"
+#include "spanner.hh"
+
+/*
+ TODO: figure what to do in grace?
+
+ TODO: documentme.
+ */
+class Auto_beam_engraver : public Engraver
+{
+public:
+ Auto_beam_engraver ();
+ VIRTUAL_COPY_CONS (Translator);
+
+protected:
+ virtual void stop_translation_timestep ();
+ virtual void start_translation_timestep ();
+ virtual void finalize ();
+ virtual void acknowledge_grob (Grob_info);
+ virtual void create_grobs ();
+
+private:
+ bool test_moment (Direction, Moment);
+ void consider_begin (Moment);
+ void consider_end (Moment);
+ Spanner* create_beam_p ();
+ void begin_beam ();
+ void end_beam ();
+ void junk_beam ();
+ bool same_grace_state_b (Grob* e);
+ void typeset_beam ();
+
+ /*
+ shortest_mom is the shortest note in the beam.
+ */
+ Moment shortest_mom_;
+ Spanner *finished_beam_p_;
+ Link_array<Item>* stem_l_arr_p_;
+
+
+ int count_i_;
+ Moment last_add_mom_;
+
+ /*
+ Projected ending of the beam we're working on.
+ */
+ Moment extend_mom_;
+ Moment beam_start_moment_;
+ Moment beam_start_location_;
+
+ // We act as if beam were created, and start a grouping anyway.
+ Beaming_info_list*grouping_p_;
+ Beaming_info_list*finished_grouping_p_;
+};