]> git.tdb.fi Git - r2c2.git/commitdiff
Style fixes, including:
authorMikko Rasa <tdb@tdb.fi>
Sun, 1 Jun 2008 08:49:18 +0000 (08:49 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 1 Jun 2008 08:49:18 +0000 (08:49 +0000)
- Reorder members in class declarations
- Get rid of rest of the container typedefs
- Convert typecasts to C++ style

37 files changed:
source/3d/layout.cpp
source/3d/layout.h
source/3d/misc.h [deleted file]
source/3d/track.cpp
source/3d/track.h
source/designer/designer.cpp
source/designer/designer.h
source/designer/manipulator.cpp
source/designer/manipulator.h
source/designer/measure.h
source/designer/selection.h
source/engineer/engineer.cpp
source/engineer/engineer.h
source/engineer/mainpanel.h
source/engineer/trainpanel.h
source/engineer/trainproperties.h
source/libmarklin/block.h
source/libmarklin/catalogue.h
source/libmarklin/command.cpp [new file with mode: 0644]
source/libmarklin/command.h
source/libmarklin/control.cpp
source/libmarklin/control.h
source/libmarklin/geometry.h
source/libmarklin/layout.cpp
source/libmarklin/layout.h
source/libmarklin/locomotive.cpp
source/libmarklin/locomotive.h
source/libmarklin/route.h
source/libmarklin/sensor.h
source/libmarklin/trackpart.h
source/libmarklin/trafficmanager.cpp
source/libmarklin/trafficmanager.h
source/libmarklin/train.cpp
source/libmarklin/train.h
source/libmarklin/turnout.cpp
source/libmarklin/turnout.h
source/shoppinglist/main.cpp

index 18457f095bf6aac4a0085e8400d94b5c3fdaceff..9c260b97a0a6581281dd765c29cac156c25403e8 100644 (file)
@@ -21,44 +21,44 @@ Layout3D::Layout3D(Layout &l):
 
 Layout3D::~Layout3D()
 {
-       for(Track3DSeq::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+       for(list<Track3D *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
                delete *i;
 }
 
 void Layout3D::set_quality(unsigned q)
 {
        quality=q;
-       for(Track3DSeq::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+       for(list<Track3D *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
                (*i)->set_quality(quality);
 }
 
-void Layout3D::render(bool endpoints)
+void Layout3D::render(bool endpoints) const
 {
        GL::Texture::unbind();
        glEnable(GL_DEPTH_TEST);
 
-       for(Track3DSeq::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+       for(list<Track3D *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
                (*i)->render();
 
        if(endpoints)
        {
                glDepthMask(false);
-               for(Track3DSeq::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               for(list<Track3D *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
                        (*i)->render_endpoints();
                glDepthMask(true);
        }
 }
 
-Track3D *Layout3D::get_track(const Track *t)
+Track3D &Layout3D::get_track(const Track &t) const
 {
-       for(Track3DSeq::iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               if(&(*i)->get_track()==t)
-                       return *i;
-
-       return 0;
+       for(list<Track3D *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               if(&(*i)->get_track()==&t)
+                       return **i;
+       
+       throw KeyError("Unknown track");
 }
 
-Track3D *Layout3D::pick_track(float x, float y, float size)
+Track3D *Layout3D::pick_track(float x, float y, float size) const
 {
        vector<GL::SelectRecord> select_buf;
        GL::select_buffer(select_buf);
@@ -120,7 +120,7 @@ void Layout3D::track_added(Track &t)
 
 void Layout3D::track_removed(Track &t)
 {
-       for(Track3DSeq::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+       for(list<Track3D *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
                if(&(*i)->get_track()==&t)
                {
                        delete *i;
index 99706047815f6f454bfb0dc72b70b3fbbacd7856..d469dc9aea9af1e2b2f04057912e927b0a767703 100644 (file)
@@ -8,20 +8,21 @@ namespace Marklin {
 
 class Layout3D
 {
+private:
+       Layout     &layout;
+       std::list<Track3D *> tracks;
+       unsigned   quality;
+
 public:
        Layout3D(Layout &);
        ~Layout3D();
 
        void set_quality(unsigned);
-       const Track3DSeq &get_tracks() const { return tracks; }
-       void  render(bool =false);
-       Track3D *get_track(const Track *);
-       Track3D *pick_track(float, float, float);
+       const std::list<Track3D *> &get_tracks() const { return tracks; }
+       void  render(bool =false) const;
+       Track3D &get_track(const Track &) const;
+       Track3D *pick_track(float, float, float) const;
 private:
-       Layout     &layout;
-       Track3DSeq tracks;
-       unsigned   quality;
-
        void track_added(Track &);
        void track_removed(Track &);
 };
diff --git a/source/3d/misc.h b/source/3d/misc.h
deleted file mode 100644 (file)
index 8d77ee2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef MARKLIN3D_MISC_H_
-#define MARKLIN3D_MISC_H_
-
-namespace Marklin {
-
-struct Color
-{
-       float r, g, b;
-
-       Color(float r_, float g_, float b_): r(r_), g(g_), b(b_) { }
-};
-
-} // namespace Marklin
-
-#endif
index d9370844e8ae24cb0f061777dd1e00d0381fce0e..9d5c5df783bcdae26d78e5145230f1ef9793464f 100644 (file)
@@ -52,11 +52,11 @@ void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
        }
 }
 
-void Track3D::render()
+void Track3D::render() const
 {
        prepare_render();
 
-       glPushName((unsigned)this);
+       glPushName(reinterpret_cast<unsigned>(this));
 
        varray.apply();
        glColor4f(0.25*color.r, 0.25*color.g, 0.25*color.b, 1);
@@ -71,7 +71,7 @@ void Track3D::render()
        glPopMatrix();
 }
 
-void Track3D::render_endpoints()
+void Track3D::render_endpoints() const
 {
        prepare_render();
 
@@ -99,7 +99,7 @@ void Track3D::render_endpoints()
        glPopMatrix();
 }
 
-void Track3D::render_route(int route)
+void Track3D::render_route(int route) const
 {
        prepare_render();
 
@@ -115,7 +115,7 @@ void Track3D::render_route(int route)
        glPopMatrix();
 }
 
-void Track3D::prepare_render()
+void Track3D::prepare_render() const
 {
        const Point &pos=track.get_position();
        float rot=track.get_rotation();
@@ -175,7 +175,7 @@ void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_build
        unsigned nsegs;
        if(radius)
        {
-               nsegs=(unsigned)(part.length*(1<<quality))+1;
+               nsegs=static_cast<unsigned>(part.length*(1<<quality))+1;
                Point center(x-sin(dir)*radius, y+cos(dir)*radius, 0);
                float r=fabs(radius);
                float start=((radius<0)?M_PI:0)+dir;
index a9154b7c6bbb628fb486d7d934601224a03a37ce..cf3c051ee22e381b17daf1f6c4b85cd65d91aee3 100644 (file)
@@ -2,28 +2,19 @@
 #define MARKLIN3D_TRACK_H_
 
 #include <list>
+#include <msp/gl/color.h>
 #include <msp/gl/vertexarray.h>
 #include <msp/gl/vertexarraybuilder.h>
 #include "libmarklin/track.h"
 #include "libmarklin/trackpart.h"
-#include "misc.h"
 
 namespace Marklin {
 
 class Track3D
 {
-public:
-       Track3D(Track &, unsigned);
-       void set_color(const Color &c)  { color=c; }
-       void set_quality(unsigned);
-       void get_bounds(float, Point &, Point &) const;
-       Track &get_track() const { return track; }
-       void render();
-       void render_endpoints();
-       void render_route(int);
 private:
        Track        &track;
-       Color        color;
+       Msp::GL::Color color;
        std::vector<Point> border;
        Msp::GL::VertexArray varray;
        std::vector<unsigned> base_seq;
@@ -31,11 +22,21 @@ private:
        std::vector<std::vector<unsigned> > route_seq;
        unsigned quality;
 
-       void prepare_render();
+public:
+       Track3D(Track &, unsigned);
+
+       void set_color(const Msp::GL::Color &c)  { color=c; }
+       void set_quality(unsigned);
+       void get_bounds(float, Point &, Point &) const;
+       Track &get_track() const { return track; }
+       void render() const;
+       void render_endpoints() const;
+       void render_route(int) const;
+private:
+       void prepare_render() const;
        void build_object();
        void build_part(const TrackPart &, Msp::GL::VertexArrayBuilder &, unsigned &);
 };
-typedef std::list<Track3D *> Track3DSeq;
 
 } // namespace Marklin
 
index 9edf816afcdef1ec7a557b42a9617c586777f3a4..3ca630f2431cfccbc12b475b91e357fd0b9edc65 100644 (file)
@@ -63,15 +63,15 @@ Designer::Designer(int argc, char **argv):
        if(argc>1)
        {
                layout->load(argv[1]);
-               const Track3DSeq &ltracks=layout_3d->get_tracks();
-               for(Track3DSeq::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
+               const list<Track3D *> &ltracks=layout_3d->get_tracks();
+               for(list<Track3D *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
                {
                        if((*i)->get_track().get_sensor_id())
-                               (*i)->set_color(Color(1, 1, 0.5));
+                               (*i)->set_color(GL::Color(1, 1, 0.5));
                        else if((*i)->get_track().get_turnout_id())
-                               (*i)->set_color(Color(0.5, 1, 1));
+                               (*i)->set_color(GL::Color(0.5, 1, 1));
                        else if((*i)->get_track().get_flex())
-                               (*i)->set_color(Color(1, 0.5, 1));
+                               (*i)->set_color(GL::Color(1, 0.5, 1));
                }
        }
 
@@ -83,6 +83,17 @@ Designer::Designer(int argc, char **argv):
        measure->signal_done.connect(sigc::mem_fun(this, &Designer::measure_done));
 }
 
+Designer::~Designer()
+{
+       delete manipulator;
+       delete selection;
+       delete layout;
+       delete layout_3d;
+       delete cat_layout;
+       delete cat_layout_3d;
+       delete measure;
+}
+
 int Designer::main()
 {
        setenv("__GL_SYNC_TO_VBLANK", "1", 0);
@@ -132,8 +143,8 @@ void Designer::map_pointer_coords(int x, int y, float &gx, float &gy)
        float uy=sin_yaw*-sin_pitch*0.41421;
        float uz=cos_pitch*0.41421;
 
-       float xf=(float)x*2/screen_w-1;
-       float yf=1-(float)y*2/screen_h;
+       float xf=static_cast<float>(x)*2/screen_w-1;
+       float yf=1-static_cast<float>(y)*2/screen_h;
 
        float vx=cos_yaw*cos_pitch + xf*rx + yf*ux;
        float vy=sin_yaw*cos_pitch + xf*ry + yf*uy;
@@ -148,7 +159,7 @@ void Designer::tick()
        SDL_Event event;
        while(SDL_PollEvent(&event))
        {
-               float gx,gy;
+               float gx, gy;
                switch(event.type)
                {
                case SDL_MOUSEBUTTONDOWN:
@@ -256,17 +267,6 @@ void Designer::tick()
        SDL_GL_SwapBuffers();
 }
 
-Designer::~Designer()
-{
-       delete manipulator;
-       delete selection;
-       delete layout;
-       delete layout_3d;
-       delete cat_layout;
-       delete cat_layout_3d;
-       delete measure;
-}
-
 /*** private ***/
 
 void Designer::key_press(unsigned key, unsigned mod, wchar_t ch)
@@ -358,11 +358,11 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t ch)
                                if(*j!=*i)
                                        (*i)->snap_to(**j, true);
 
-                       Track3D *t3d=layout_3d->get_track(*i);
+                       Track3D &t3d=layout_3d->get_track(**i);
                        if((*i)->get_flex())
-                               t3d->set_color(Color(1, 0.5, 1));
+                               t3d.set_color(GL::Color(1, 0.5, 1));
                        else
-                               t3d->set_color(Color(1, 1, 1));
+                               t3d.set_color(GL::Color(1, 1, 1));
                }
        }
        else if(key==SDLK_f)
@@ -536,18 +536,6 @@ void Designer::render()
                        measure->render();
        }
 
-       /*glBegin(GL_LINES);
-       glColor4f(1, 0, 0, 1);
-       glVertex3f(0, 0, 0);
-       glVertex3f(0.5, 0, 0);
-       glColor4f(0, 1, 0, 1);
-       glVertex3f(0, 0, 0);
-       glVertex3f(0, 0.5, 0);
-       glColor4f(0, 0, 1, 1);
-       glVertex3f(0, 0, 0);
-       glVertex3f(0, 0, 0.5);
-       glEnd();*/
-
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, screen_w, 0, screen_h, 0, 1);
@@ -582,9 +570,9 @@ Track3D *Designer::pick_track(int x, int y)
        if(mode==CATALOGUE)
                l=cat_layout_3d;
 
-       float xx=((float)(x-(int)screen_w/2)/screen_h)*0.82843;
-       float yy=((float)y/screen_h-0.5)*0.82843;
-       float size=(float)4/screen_h*0.82843;
+       float xx=(static_cast<float>(x-static_cast<int>(screen_w)/2)/screen_h)*0.82843;
+       float yy=(static_cast<float>(y)/screen_h-0.5)*0.82843;
+       float size=4.0/screen_h*0.82843;
 
        project_3d();
        apply_camera();
@@ -621,9 +609,9 @@ void Designer::measure_done()
 
 void Designer::move_tooltip(int x, int y)
 {
-       int w=(int)(font->get_string_width(tooltip)*20);
-       tooltip_x=max(min((int)screen_w-w, x), 0);
-       tooltip_y=max(min((int)screen_h-20, y), 0);
+       int w=static_cast<int>(font->get_string_width(tooltip)*20);
+       tooltip_x=max(min(static_cast<int>(screen_w)-w, x), 0);
+       tooltip_y=max(min(static_cast<int>(screen_h)-20, y), 0);
 }
 
 void Designer::save_accept()
@@ -639,11 +627,11 @@ void Designer::turnout_id_accept()
        unsigned id=lexical_cast<unsigned>(input->get_text());
        track->set_turnout_id(id);
 
-       Track3D *t3d=layout_3d->get_track(track);
+       Track3D &t3d=layout_3d->get_track(*track);
        if(id)
-               t3d->set_color(Color(0.5, 1, 1));
+               t3d.set_color(GL::Color(0.5, 1, 1));
        else
-               t3d->set_color(Color(1, 1, 1));
+               t3d.set_color(GL::Color(1, 1, 1));
 
        input_dismiss();
 }
@@ -654,11 +642,11 @@ void Designer::sensor_id_accept()
        unsigned id=lexical_cast<unsigned>(input->get_text());
        track->set_sensor_id(id);
 
-       Track3D *t3d=layout_3d->get_track(track);
+       Track3D &t3d=layout_3d->get_track(*track);
        if(id)
-               t3d->set_color(Color(1, 1, 0.5));
+               t3d.set_color(GL::Color(1, 1, 0.5));
        else
-               t3d->set_color(Color(1, 1, 1));
+               t3d.set_color(GL::Color(1, 1, 1));
 
        input_dismiss();
 }
index 553b25c3e4faf91d35f554c68128fe53a2c832f4..c72dd5c680068ed0432902b78b7567fda308d5c2 100644 (file)
@@ -17,14 +17,6 @@ class Selection;
 
 class Designer: public Msp::Application
 {
-public:
-       Designer(int, char **);
-       Marklin::Layout *get_layout() { return layout; }
-       Marklin::Layout3D *get_layout_3d() { return layout_3d; }
-       Msp::GL::Font   &get_font()   { return *font; }
-       int             main();
-       void            map_pointer_coords(int, int, float &, float &);
-       ~Designer();
 private:
        enum Mode
        {
@@ -65,6 +57,16 @@ private:
        Msp::Time::TimeStamp tooltip_timeout;
        Msp::Time::TimeStamp last_tick;
 
+public:
+       Designer(int, char **);
+       ~Designer();
+
+       Marklin::Layout *get_layout() { return layout; }
+       Marklin::Layout3D *get_layout_3d() { return layout_3d; }
+       Msp::GL::Font   &get_font()   { return *font; }
+       int             main();
+       void            map_pointer_coords(int, int, float &, float &);
+private:
        void tick();
        void key_press(unsigned, unsigned, wchar_t);
        void key_release(unsigned, unsigned);
index e7cceadcc1b286d63fdc8f2467ae11d25e395b65..c07003e4eae3f13617029ee23f02f1ce31ee1e69 100644 (file)
@@ -379,18 +379,18 @@ void Manipulator::selection_changed()
 void Manipulator::update_wrap()
 {
        wrap.clear();
-       float min_x=0,max_x=0;
-       float min_y=0,max_y=0;
+       float min_x=0, max_x=0;
+       float min_y=0, max_y=0;
        for(vector<MTrack>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
        {
-               Track3D *t3d=designer.get_layout_3d()->get_track(i->track);
+               Track3D &t3d=designer.get_layout_3d()->get_track(*i->track);
 
                TrackWrap tw;
                float min_area=100;
                for(float a=0; a<M_PI; a+=0.01)
                {
-                       Point minp,maxp;
-                       t3d->get_bounds(a, minp, maxp);
+                       Point minp, maxp;
+                       t3d.get_bounds(a, minp, maxp);
                        float area=(maxp.x-minp.x)*(maxp.y-minp.y);
                        if(area<min_area)
                        {
index 9e17384e4ee39b90c178d8e55c402e81bc9ec601..a17ad8d5e13ab0286bfe68badfda43977d843ff5 100644 (file)
@@ -9,22 +9,6 @@ class Selection;
 
 class Manipulator
 {
-public:
-       sigc::signal<void, const std::string &> signal_status;
-       sigc::signal<void, bool> signal_done;
-
-       Manipulator(Designer &);
-       void set_selection(Selection *);
-       void start_move();
-       void start_rotate();
-       void start_elevate();
-       void duplicate();
-       void flatten();
-       void even_slope(bool =false);
-       void cancel();
-       void button_press(int, int, float, float, unsigned);
-       void pointer_motion(int, int, float, float);
-       void render();
 private:
        enum Mode
        {
@@ -78,6 +62,24 @@ private:
        std::set<Marklin::Track *> neighbors;
        sigc::connection selection_changed_conn;
 
+public:
+       sigc::signal<void, const std::string &> signal_status;
+       sigc::signal<void, bool> signal_done;
+
+       Manipulator(Designer &);
+
+       void set_selection(Selection *);
+       void start_move();
+       void start_rotate();
+       void start_elevate();
+       void duplicate();
+       void flatten();
+       void even_slope(bool =false);
+       void cancel();
+       void button_press(int, int, float, float, unsigned);
+       void pointer_motion(int, int, float, float);
+       void render();
+private:
        void selection_changed();
        void update_wrap();
        void update_neighbors();
index d7c7b7719ad3c6b079b2a5317bba01f472183a24..61a5a754c7b19af8fea92927400b32fa06006834 100644 (file)
@@ -7,18 +7,6 @@ class Designer;
 
 class Measure
 {
-public:
-       sigc::signal<void> signal_done;
-       sigc::signal<void> signal_changed;
-
-       Measure(Designer &);
-       float get_parallel_distance() const      { return par_dist; }
-       float get_perpendicular_distance() const { return perp_dist; }
-       float get_angle_difference() const       { return adiff; }
-       void start();
-       void button_press(int, int, float, float, unsigned);
-       void pointer_motion(int, int, float, float);
-       void render();
 private:
        enum State
        {
@@ -36,6 +24,19 @@ private:
        float adiff;
        State state;
 
+public:
+       sigc::signal<void> signal_done;
+       sigc::signal<void> signal_changed;
+
+       Measure(Designer &);
+       float get_parallel_distance() const      { return par_dist; }
+       float get_perpendicular_distance() const { return perp_dist; }
+       float get_angle_difference() const       { return adiff; }
+       void start();
+       void button_press(int, int, float, float, unsigned);
+       void pointer_motion(int, int, float, float);
+       void render();
+private:
        void snap_to_tracks(Marklin::Point &, float &);
 };
 
index 21c5de187f0667ff4c0d82ab30f1093c4ff153c5..1c0d267f1618044271f7672c967c61d8cb118db6 100644 (file)
@@ -7,6 +7,9 @@
 
 class Selection
 {
+private:
+       std::set<Marklin::Track *> tracks;
+
 public:
        sigc::signal<void> signal_changed;
 
@@ -19,8 +22,6 @@ public:
        void toggle_track(Marklin::Track *);
        void select_more();
        void select_linked();
-private:
-       std::set<Marklin::Track *> tracks;
 };
 
 #endif
index d5f8495171daecd082a2e43d75670c0952335b49..3ac7c7682a605cc06942c23cfee7607db157259c 100644 (file)
@@ -113,7 +113,7 @@ Train *Engineer::add_train(unsigned addr)
                TrainPanel *tpanel=new TrainPanel(*this, ui_res, *train);
                root->add(*tpanel);
                int y=main_panel->get_geometry().y;
-               for(TrainPanelSeq::iterator i=train_panels.begin(); i!=train_panels.end(); ++i)
+               for(list<TrainPanel *>::iterator i=train_panels.begin(); i!=train_panels.end(); ++i)
                        y-=(*i)->get_geometry().h;
                tpanel->set_position(0, y-tpanel->get_geometry().h);
                train_panels.push_back(tpanel);
@@ -213,8 +213,8 @@ void Engineer::tick()
 
        glDisable(GL_LIGHTING);
        glColor4f(1, 1, 1, 1);
-       const Track3DSeq &ltracks=layout_3d.get_tracks();
-       for(Track3DSeq::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
+       const list<Track3D *> &ltracks=layout_3d.get_tracks();
+       for(list<Track3D *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
        {
                Track &track=(*i)->get_track();
                if(track.get_turnout_id())
@@ -286,7 +286,7 @@ void Engineer::button_press(int x, int y, unsigned btn, unsigned)
        {
                if(btn==1 && placing_block)
                {
-                       set_block_color(*placing_block, Color(1, 1, 1));
+                       set_block_color(*placing_block, GL::Color(1, 1, 1));
 
                        placing_train->place(placing_block, placing_entry);
                        placing_train=0;
@@ -335,10 +335,10 @@ void Engineer::pointer_motion(int x, int y)
                        if(&block!=placing_block)
                        {
                                if(placing_block)
-                                       set_block_color(*placing_block, Color(1, 1, 1));
+                                       set_block_color(*placing_block, GL::Color(1, 1, 1));
                                placing_block=&block;
                                placing_entry=0;
-                               set_block_color(*placing_block, Color(0.5, 1, 0.7));
+                               set_block_color(*placing_block, GL::Color(0.5, 1, 0.7));
                        }
                }
                else if(track && track->get_track().get_turnout_id())
@@ -350,7 +350,7 @@ void Engineer::pointer_motion(int x, int y)
 
 void Engineer::view_all()
 {
-       const Track3DSeq &tracks=layout_3d.get_tracks();
+       const list<Track3D *> &tracks=layout_3d.get_tracks();
 
        cam_rot=0;
        float best_height=-1;
@@ -362,9 +362,9 @@ void Engineer::view_all()
                float max_x=0;
                float min_y=0;
                float max_y=0;
-               for(Track3DSeq::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               for(list<Track3D *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
                {
-                       Point minp,maxp;
+                       Point minp, maxp;
                        (*i)->get_bounds(angle, minp, maxp);
                        min_x=min(min_x, minp.x);
                        max_x=max(max_x, maxp.x);
@@ -392,11 +392,11 @@ void Engineer::view_all()
        cam_pos.z=max(best_height*1.05/0.82843, 0.15);
 }
 
-void Engineer::set_block_color(const Block &block, const Color &color)
+void Engineer::set_block_color(const Block &block, const GL::Color &color)
 {
        const set<Track *> &tracks=block.get_tracks();
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               layout_3d.get_track(*i)->set_color(color);
+               layout_3d.get_track(**i).set_color(color);
 }
 
 void Engineer::sensor_event(bool state, Sensor *sensor)
@@ -407,11 +407,11 @@ void Engineer::sensor_event(bool state, Sensor *sensor)
                {
                        Block &block=trfc_mgr->get_block_by_track((*i)->get_track());
                        if(state)
-                               (*i)->set_color(Color(1, 0.5, 0.3));
+                               (*i)->set_color(GL::Color(1, 0.5, 0.3));
                        else if(block.get_train())
-                               set_block_color(block, Color(1, 1, 0.3));
+                               set_block_color(block, GL::Color(1, 1, 0.3));
                        else
-                               (*i)->set_color(Color(1, 1, 1));
+                               (*i)->set_color(GL::Color(1, 1, 1));
                }
 }
 
@@ -425,26 +425,25 @@ void Engineer::block_reserved(const Block &block, const Train *train)
        }
 
        if(train)
-               set_block_color(block, Color(1, 1, 0.3));
+               set_block_color(block, GL::Color(1, 1, 0.3));
        else
-               set_block_color(block, Color(1, 1, 1));
+               set_block_color(block, GL::Color(1, 1, 1));
 }
 
 void Engineer::project_3d()
 {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
-       //glFrustum(-0.055228, 0.055228, -0.041421, 0.041421, 0.1, 10);
-       glFrustum(-0.069036, 0.041421, -0.041421, 0.041421, 0.1, 10);
+       float offset=200.0/screen_w*0.055228;
+       glFrustum(-0.055228-offset, 0.055228-offset, -0.041421, 0.041421, 0.1, 10);
        glMatrixMode(GL_MODELVIEW);
 }
 
 Track3D *Engineer::pick_track(int x, int y)
 {
-       float xx=((float)(x-(int)screen_w*5/8)/screen_h)*0.82843;
-       //float xx=((float)(x-(int)screen_w/2)/screen_h)*0.82843;
-       float yy=((float)y/screen_h-0.5)*0.82843;
-       float size=(float)4/screen_h*0.82843;
+       float xx=(static_cast<float>(x-static_cast<int>(screen_w)/2-100)/screen_h)*0.82843;
+       float yy=(static_cast<float>(y)/screen_h-0.5)*0.82843;
+       float size=4.0/screen_h*0.82843;
 
        project_3d();
        glLoadIdentity();
index 1575c0c31e381ad1d18a0a9727b2727746fff3db..6131c6f2f4fc3d4a10596355ef442a77f4e55379 100644 (file)
@@ -18,17 +18,7 @@ class TrainProperties;
 
 class Engineer: public Msp::Application
 {
-public:
-       Engineer(int argc, char **argv);
-       ~Engineer();
-
-       Marklin::Control &get_control()    { return control; }
-       Marklin::Train   *add_train(unsigned);
-       int      main();
-       void     quit() { exit(0); }
 private:
-       typedef std::list<TrainPanel *> TrainPanelSeq;
-
        Msp::Graphics::Display   *dpy;
        Msp::Graphics::Window    *wnd;
        Msp::Graphics::GLContext *glc;
@@ -44,7 +34,7 @@ private:
        float              cam_rot;
        Msp::GLtk::Resources ui_res;
        MainPanel          *main_panel;
-       TrainPanelSeq      train_panels;
+       std::list<TrainPanel *> train_panels;
        bool               no_lighting;
        Marklin::TrafficManager *trfc_mgr;
        Marklin::Train     *placing_train;
@@ -54,13 +44,22 @@ private:
        TrainProperties    *train_prop;
        bool               train_prop_stale;
 
+public:
+       Engineer(int argc, char **argv);
+       ~Engineer();
+
+       Marklin::Control &get_control()    { return control; }
+       Marklin::Train   *add_train(unsigned);
+       int      main();
+       void     quit() { exit(0); }
+private:
        void tick();
        void key_press(unsigned, unsigned, wchar_t);
        void button_press(int, int, unsigned, unsigned);
        void button_release(int, int, unsigned, unsigned);
        void pointer_motion(int, int);
        void view_all();
-       void set_block_color(const Marklin::Block &, const Marklin::Color &);
+       void set_block_color(const Marklin::Block &, const Msp::GL::Color &);
        void sensor_event(bool, Marklin::Sensor *);
        void block_reserved(const Marklin::Block &, const Marklin::Train *);
        void project_3d();
index 091d9707d31b240317524d3be8b0b1352c13e4ee..3e58d12bdca29ba17c14986672fabafff0376d31 100644 (file)
@@ -9,15 +9,17 @@ class Engineer;
 
 class MainPanel: public Msp::GLtk::Panel
 {
-public:
-       MainPanel(Engineer &, Msp::GLtk::Resources &);
-       void set_status_text(const std::string &);
 private:
        Engineer &engineer;
        Msp::GLtk::Indicator *ind_on;
        Msp::GLtk::Indicator *ind_off;
        Msp::GLtk::Label *lbl_status;
 
+public:
+       MainPanel(Engineer &, Msp::GLtk::Resources &);
+
+       void set_status_text(const std::string &);
+private:
        void power_on();
        void power_off();
        void new_loc();
index d21e5618694c8fc69d86c69fc71d4b64cb76f5d9..3e44241bf3e7700e041f28f0b97413c231ba5138 100644 (file)
@@ -10,8 +10,6 @@ class Engineer;
 
 class TrainPanel: public Msp::GLtk::Panel
 {
-public:
-       TrainPanel(Engineer &, const Msp::GLtk::Resources &, Marklin::Train &);
 private:
        Engineer &engineer;
        Marklin::Train &train;
@@ -21,6 +19,9 @@ private:
        Marklin::Locomotive *loco;
        Msp::GLtk::Label *lbl_speed;
 
+public:
+       TrainPanel(Engineer &, const Msp::GLtk::Resources &, Marklin::Train &);
+private:
        void speed_slider_changed(double);
        void loco_speed_changed(unsigned);
 };
index b63bc3d00848770c6a32db86644e1bbac74d7aed..5d24613a7329a3cf718189a94adf635fc0ff6760 100644 (file)
@@ -9,16 +9,17 @@ class Engineer;
 
 class TrainProperties: public Msp::GLtk::Panel
 {
-public:
-       sigc::signal<void> signal_ok;
-
-       TrainProperties(Engineer &, Msp::GLtk::Resources &, Marklin::Train *);
 private:
        Engineer &engineer;
        Marklin::Train *train;
        Msp::GLtk::Entry *ent_addr;
        Msp::GLtk::Entry *ent_name;
 
+public:
+       sigc::signal<void> signal_ok;
+
+       TrainProperties(Engineer &, Msp::GLtk::Resources &, Marklin::Train *);
+private:
        void ok_clicked();
 };
 
index 186f0f13d85b6103e59e546f376193678c2adc18..076637240a21835c2579a269ef1fa05aba0503ab 100644 (file)
@@ -33,6 +33,7 @@ private:
 
 public:
        Block(TrafficManager &, Track &);
+
        unsigned get_sensor_id() const { return sensor_id; }
        const std::set<Track *> &get_tracks() const { return tracks; }
        const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
@@ -48,7 +49,6 @@ private:
 
        static unsigned next_id;
 };
-typedef std::list<Block *> BlockSeq;
 
 } // namespace Marklin
 
index 6277158df699246952fe29e5286c6bd3bb02f60f..66e34667e2f161bfba4c90b42d55150062b78f8f 100644 (file)
@@ -20,6 +20,7 @@ public:
 
                void track(unsigned);
        };
+
 private:
        std::map<unsigned, TrackType *> tracks;
 
diff --git a/source/libmarklin/command.cpp b/source/libmarklin/command.cpp
new file mode 100644 (file)
index 0000000..f953cbd
--- /dev/null
@@ -0,0 +1,17 @@
+#include "command.h"
+
+using namespace std;
+
+namespace Marklin {
+
+Command::Command(const string &c):
+       cmd(c),
+       sent(false)
+{ }
+
+void Command::set_sent(bool s)
+{
+       sent=s;
+}
+
+} // namespace Marklin
index 2106d237bb67f0d44464529297d6914daff7f78a..4e4c9866d1a705c3d125d852b8deab045897bd76 100644 (file)
@@ -9,16 +9,18 @@ namespace Marklin {
 
 class Command
 {
+private:
+       std::string cmd;
+       bool        sent;
+
 public:
        sigc::signal<void, Error, const std::string &> signal_done;
 
-       Command(const std::string &c): cmd(c), sent(false) { }
-       void              set_sent(bool s)     { sent=s; }
+       Command(const std::string &);
+
+       void              set_sent(bool);
        const std::string &get_command() const { return cmd; }
        bool              get_sent() const     { return sent; }
-private:
-       std::string cmd;
-       bool        sent;
 };
 
 } // namespace Marklin
index 6e82614c21ebf904a65fd3d4d29b359bfe77c03e..bd63f9f66f661c75d110820edd7ddd3610e48d2c 100644 (file)
@@ -21,6 +21,17 @@ Control::Control():
        debug(false)
 { }
 
+Control::~Control()
+{
+       for(map<unsigned, Sensor *>::iterator i=sensors.begin(); i!=sensors.end(); ++i)
+               delete i->second;
+       for(map<unsigned, Turnout *>::iterator i=turnouts.begin(); i!=turnouts.end(); ++i)
+               delete i->second;
+       for(map<unsigned, Locomotive *>::iterator i=locomotives.begin(); i!=locomotives.end(); ++i)
+               delete i->second;
+       close(serial_fd);
+}
+
 void Control::set_power(bool p)
 {
        power=p;
@@ -30,6 +41,11 @@ void Control::set_power(bool p)
                command(string(1, CMD_POWER_OFF));
 }
 
+void Control::set_debug(bool d)
+{
+       debug=d;
+}
+
 void Control::open(const string &dev)
 {
        serial_fd=::open(dev.c_str(), O_RDWR);
@@ -158,28 +174,28 @@ void Control::tick()
                poll_sensors=false;
        }
 
-       if(queue.size() && queue.front().get_sent())
+       if(!queue.empty() && queue.front().get_sent())
        {
                pollfd pfd={serial_fd, POLLIN, 0};
                if(poll(&pfd, 1, 0)>0)
                {
-                       string resp=read_reply((Cmd)(unsigned char)queue.front().get_command()[0]);
+                       string resp=read_reply(static_cast<Cmd>(static_cast<unsigned char>(queue.front().get_command()[0])));
                        if(debug)
                        {
                                printf("read:  ");
                                for(unsigned i=0; i<resp.size(); ++i)
-                                       printf("%02X ", (unsigned char)resp[i]);
+                                       printf("%02X ", static_cast<unsigned char>(resp[i]));
                                printf("(%d bytes)\n", resp.size());
                        }
 
-                       queue.front().signal_done.emit((Error)resp[0], resp.substr(1));
+                       queue.front().signal_done.emit(static_cast<Error>(resp[0]), resp.substr(1));
                        queue.erase(queue.begin());
                }
                else
                        return;
        }
 
-       if(queue.size())
+       if(!queue.empty())
        {
                string cmd=queue.front().get_command();
 
@@ -195,8 +211,8 @@ void Control::tick()
                {
                        printf("write: ");
                        for(unsigned i=0; i<cmd.size(); ++i)
-                               printf("%02X ",(unsigned char)cmd[i]);
-                       printf("(%d bytes)\n",cmd.size());
+                               printf("%02X ", static_cast<unsigned char>(cmd[i]));
+                       printf("(%d bytes)\n", cmd.size());
                }
 
                write(serial_fd, cmd.data(), cmd.size());
@@ -209,19 +225,6 @@ Time::Timer::Slot &Control::set_timer(const Time::TimeDelta &dt)
        return timer.add(dt);
 }
 
-Control::~Control()
-{
-       for(map<unsigned, Sensor *>::iterator i=sensors.begin(); i!=sensors.end(); ++i)
-               delete i->second;
-       for(map<unsigned, Turnout *>::iterator i=turnouts.begin(); i!=turnouts.end(); ++i)
-               delete i->second;
-       for(map<unsigned, Locomotive *>::iterator i=locomotives.begin(); i!=locomotives.end(); ++i)
-               delete i->second;
-       close(serial_fd);
-}
-
-/*** private ***/
-
 void Control::read_all(int fd, char *buf, int size)
 {
        int pos=0;
@@ -315,7 +318,7 @@ void Control::turnout_event_done(Error, const string &resp)
        unsigned count=resp[0];
        for(unsigned i=0; i<count; ++i)
        {
-               unsigned addr=(unsigned char)resp[i*2+1]+((resp[i*2+2]&7)<<8);
+               unsigned addr=static_cast<unsigned char>(resp[i*2+1])+((resp[i*2+2]&7)<<8);
                bool status=!(resp[i*2+2]&0x80);
                cout<<"Turnout "<<addr<<", status "<<status<<'\n';
                signal_turnout_event.emit(addr, status);
@@ -326,7 +329,7 @@ void Control::sensor_event_done(Error, const string &resp)
 {
        for(unsigned i=0; resp[i]; i+=3)
        {
-               unsigned module=(unsigned char)resp[i];
+               unsigned module=static_cast<unsigned char>(resp[i]);
 
                cout<<"S88 module "<<module<<", status ";
                for(unsigned j=0; j<16; ++j)
index 4729695d7dbeb10d00e40f13578877a9f8493f61..0b7b8c0a00d388ed55376a2d418d7769449a6cd2 100644 (file)
@@ -34,23 +34,25 @@ public:
        sigc::signal<void, unsigned, bool> signal_sensor_event;
 
        Control();
+       ~Control();
+
        void       set_power(bool);
        bool       get_power() const { return power; }
-       void       set_debug(bool d) { debug=d; }
-       //const TurnoutMap &get_turnouts() const { return turnouts; }
+       void       set_debug(bool);
        const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
        unsigned   get_queue_length() const { return queue.size(); }
        void       open(const std::string &);
        Command    &command(const std::string &);
+
        void       add_turnout(Turnout &);
        Turnout    &get_turnout(unsigned) const;
        void       add_locomotive(Locomotive &);
        Locomotive &get_locomotive(unsigned) const;
        void       add_sensor(Sensor &);
        Sensor     &get_sensor(unsigned) const;
+
        void       tick();
        Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
-       ~Control();
 private:
        void read_all(int, char *, int);
        std::string read_reply(Cmd);
index 9dee86ef949b7d4de481e46ddf8faacf118920c4..4b0afc23f2b9fdc1672e2b814c7bf2e24542755e 100644 (file)
@@ -7,7 +7,7 @@ namespace Marklin {
 
 struct Point
 {
-       float x,y,z;
+       float x, y, z;
 
        Point(): x(0), y(0), z(0) { }
        Point(float x_, float y_, float z_): x(x_), y(y_), z(z_) { }
index 28d2eeb862ad85862e8cd45baab8291061d9261a..a197b35af596002a4ed7a202a24a77ea54537c10 100644 (file)
@@ -14,6 +14,12 @@ Layout::Layout(Catalogue &c):
        catalogue(c)
 { }
 
+Layout::~Layout()
+{
+       for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               delete *i;
+}
+
 void Layout::add_track(Track &t)
 {
        if(tracks.insert(&t).second)
@@ -63,7 +69,7 @@ int Layout::save(const string &fn)
 
        filename=fn;
 
-       if(base.size())
+       if(!base.empty())
                out<<"base \""<<base<<"\";\n";
        for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
        {
@@ -90,15 +96,6 @@ int Layout::save(const string &fn)
        return 0;
 }
 
-Layout::~Layout()
-{
-       for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               delete *i;
-}
-
-/*******************
-** Layout::Loader
-*/
 
 Layout::Loader::Loader(Layout &l):
        layout(l)
index d1844dee66bd5f387ff79fc7f2e1664c03536898..d984e1020398111cbe84ebbaff4dae137e2b3ede 100644 (file)
@@ -24,23 +24,26 @@ public:
                void track(unsigned);
        };
 
+private:
+       Catalogue   &catalogue;
+       std::string filename;
+       std::string base;
+       std::set<Track *> tracks;
+       //RouteSeq    routes;
+
+public:
        sigc::signal<void, Track &> signal_track_added;
        sigc::signal<void, Track &> signal_track_removed;
 
        Layout(Catalogue &);
+       ~Layout();
+
        const std::set<Track *> &get_tracks() const { return tracks; }
        void  add_track(Track &);
        void  remove_track(Track &);
        void  check_links();
        void  load(const std::string &);
        int   save(const std::string &);
-       ~Layout();
-private:
-       Catalogue   &catalogue;
-       std::string filename;
-       std::string base;
-       std::set<Track *> tracks;
-       //RouteSeq    routes;
 };
 
 } // namespace Marklin
index fe236a515f0fa783dbbb0f1e92022c9b86eb0ebb..0de0110f3cafd673ec55347ec3fb71c9e987cc74 100644 (file)
@@ -90,17 +90,17 @@ void Locomotive::send_command(bool setf)
                        if((funcs>>i)&2)
                                cmd[4]|=(1<<i);
        }
-       control.command(string(cmd,5));
+       control.command(string(cmd, 5));
 }
 
 void Locomotive::status_reply(Error err, const string &reply)
 {
        if(err==ERR_NO_ERROR)
        {
-               if((unsigned char)reply[0]<=1)
+               if(static_cast<unsigned char>(reply[0])<=1)
                        speed=0;
                else
-                       speed=(unsigned char)reply[0]*2/19+1;
+                       speed=static_cast<unsigned char>(reply[0])*2/19+1;
                reverse=(reply[1]&0x20)?false:true;
                funcs=(reply[1]&0xF)<<1;
                if(reply[1]&0x10)
index 4188df5e809dd3cbf756dbfc4b070700a900c8d3..eae99f57dddfdb66e5f7183fa3fa52356a540e97 100644 (file)
@@ -12,10 +12,18 @@ class Control;
 
 class Locomotive
 {
+private:
+       Control  &control;
+       unsigned addr;
+       unsigned speed;
+       bool     reverse;
+       unsigned funcs;
+
 public:
        sigc::signal<void, unsigned> signal_speed_changed;
 
        Locomotive(Control &, unsigned);
+
        void     set_speed(unsigned);
        void     set_reverse(bool);
        void     set_function(unsigned, bool);
@@ -25,12 +33,6 @@ public:
        bool     get_function(unsigned f) const { return (funcs>>f)&1; }
        void     refresh_status();
 private:
-       Control  &control;
-       unsigned addr;
-       unsigned speed;
-       bool     reverse;
-       unsigned funcs;
-
        void     send_command(bool);
        void     status_reply(Error, const std::string &);
        bool     reverse_timeout();
index 3fa82023117053e53dd275a613e240b5512b9d6b..6d2d71034d532fa55301bf619b033d8f31e29489 100644 (file)
@@ -14,8 +14,6 @@ class Turnout;
 class Route
 {
 public:
-       typedef std::map<unsigned, unsigned> TurnoutMap;
-
        Route();
        const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
        void add_track(Track *);
index d3db6367a2b7b40ed9d0a232906c2f23561b4513..9dbb23c2ffb5b8f26e9b1475b6388485f1581f04 100644 (file)
@@ -12,19 +12,21 @@ class Control;
 
 class Sensor
 {
+private:
+       Control  &control;
+       unsigned addr;
+       bool     state;
+       Msp::Time::TimeStamp off_timeout;
+
 public:
        sigc::signal<void, bool> signal_state_changed;
 
        Sensor(Control &, unsigned);
+
        unsigned get_address() const { return addr; }
        bool     get_state() const   { return state; }
        void     tick();
 private:
-       Control  &control;
-       unsigned addr;
-       bool     state;
-       Msp::Time::TimeStamp off_timeout;
-
        void sensor_event(unsigned, bool);
 };
 
index 092e586999bc75a26a7ba4c3f354157ac7509912..043dd0d0d78f71db2d7f0bcc37aab40b9080929d 100644 (file)
@@ -30,6 +30,7 @@ struct TrackPart
        bool     dead_end;
 
        TrackPart();
+
        void collect_endpoints(std::vector<Endpoint> &);
 };
 
index 096d675e8432aafbba37902cefa5200ecdcc7187..543c34a8cb1f5e637a15bbefa3062f49761a4f00 100644 (file)
@@ -31,9 +31,9 @@ TrafficManager::TrafficManager(Control &c, Layout &l):
                }
        }
 
-       for(BlockSeq::iterator i=blocks.begin(); i!=blocks.end(); ++i)
+       for(list<Block *>::iterator i=blocks.begin(); i!=blocks.end(); ++i)
        {
-               for(BlockSeq::iterator j=i; j!=blocks.end(); ++j)
+               for(list<Block *>::iterator j=i; j!=blocks.end(); ++j)
                        if(j!=i)
                                (*i)->check_link(**j);
                (*i)->print_debug();
@@ -42,15 +42,15 @@ TrafficManager::TrafficManager(Control &c, Layout &l):
 
 TrafficManager::~TrafficManager()
 {
-       for(BlockSeq::iterator i=blocks.begin(); i!=blocks.end(); ++i)
+       for(list<Block *>::iterator i=blocks.begin(); i!=blocks.end(); ++i)
                delete *i;
-       for(TrainSeq::iterator i=trains.begin(); i!=trains.end(); ++i)
+       for(list<Train *>::iterator i=trains.begin(); i!=trains.end(); ++i)
                delete *i;
 }
 
 Block &TrafficManager::get_block_by_track(const Track &t) const
 {
-       for(BlockSeq::const_iterator i=blocks.begin(); i!=blocks.end(); ++i)
+       for(list<Block *>::const_iterator i=blocks.begin(); i!=blocks.end(); ++i)
        {
                const set<Track *> &tracks=(*i)->get_tracks();
                if(tracks.count(const_cast<Track *>(&t)))
index 2707e098fb6caad5f339cfa57f805c8caeec9d3e..2ef4bc9e9346a2d17a729c4660c1c9f3c3f90888 100644 (file)
@@ -12,6 +12,12 @@ class Turnout;
 
 class TrafficManager
 {
+private:
+       Control &control;
+       Layout &layout;
+       std::list<Block *> blocks;
+       std::list<Train *> trains;
+
 public:
        sigc::signal<void, const Block &, const Train *> signal_block_reserved;
 
@@ -20,15 +26,10 @@ public:
 
        Control &get_control() const { return control; }
        Block &get_block_by_track(const Track &) const;
-       const TrainSeq &get_trains() const { return trains; }
+       const std::list<Train *> &get_trains() const { return trains; }
        void add_train(Train *);
        void tick();
 private:
-       Control &control;
-       Layout &layout;
-       std::list<Block *> blocks;
-       std::list<Train *> trains;
-
        void turnout_route_changed(unsigned, Turnout *);
 };
 
index c42448176e814f0032e2810732aadf5a3f216bc5..1644802008ae4b575c62d052f6a6e41ba94d306e 100644 (file)
@@ -128,7 +128,7 @@ void Train::sensor_event(bool state, Sensor *sensor)
                                ++i;
                                for(list<BlockRef>::iterator j=cur_blocks.begin(); j!=i; ++j)
                                        j->block->reserve(0);
-                               cout<<"  "<<distance(cur_blocks.begin(),)<<" blocks freed, ";
+                               cout<<"  "<<distance(cur_blocks.begin(), i)<<" blocks freed, ";
                                cur_blocks.erase(cur_blocks.begin(), i);
                                cout<<cur_blocks.size()<<" cur_blocks\n";
                        }
@@ -152,7 +152,7 @@ bool Train::reserve_more()
 
        bool result=false;
        unsigned size=rsv_blocks.size();
-       while(size<2)
+       while(size<3)
        {
                int exit=last->block->traverse(last->entry);
                if(exit>=0) 
index 117211244cea2984eacfe1600ec488a268075cee..815a9e9305f2baab23a506f98a886ccb497c51d5 100644 (file)
@@ -35,6 +35,7 @@ public:
        sigc::signal<void, const std::string &> signal_name_changed;
 
        Train(TrafficManager &, Locomotive &);
+
        void set_name(const std::string &);
        void set_speed(unsigned);
        const std::string &get_name() const { return name; }
@@ -46,7 +47,6 @@ private:
        void sensor_event(bool, Sensor *);
        bool reserve_more();
 };
-typedef std::list<Train *> TrainSeq;
 
 } // namespace Marklin
 
index a6e3f2d171739734e3a412cfb6ac9ec4436689a3..6f90d47fe1d904182e73284ef0e80662acb3c6e3 100644 (file)
@@ -23,7 +23,7 @@ Turnout::Turnout(Control &c, unsigned a):
        cmd[0]=CMD_TURNOUT_STATUS;
        cmd[1]=addr&0xFF;
        cmd[2]=(addr>>8)&0xFF;
-       control.command(string(cmd,3)).signal_done.connect(sigc::mem_fun(this, &Turnout::status_reply));
+       control.command(string(cmd, 3)).signal_done.connect(sigc::mem_fun(this, &Turnout::status_reply));
 }
 
 void Turnout::set_route(unsigned r)
@@ -46,7 +46,7 @@ void Turnout::command(bool on)
                cmd[2]|=0x40;
        if(route==0)
                cmd[2]|=0x80;
-       control.command(string(cmd,3));
+       control.command(string(cmd, 3));
 }
 
 void Turnout::status_reply(Error err, const string &reply)
index 801772b711d73f14781542971ad9104829ae6a91..dbb689e5f8cfb00d67a011f135bcb034b1b31c49 100644 (file)
@@ -13,18 +13,20 @@ class Control;
 
 class Turnout
 {
+private:
+       Control  &control;
+       unsigned addr;
+       unsigned route;
+
 public:
        sigc::signal<void, unsigned> signal_route_changed;
 
        Turnout(Control &, unsigned);
+
        void     set_route(unsigned);
        unsigned get_address() const { return addr; }
        unsigned get_route() const   { return route; }
 private:
-       Control  &control;
-       unsigned addr;
-       unsigned route;
-
        void command(bool);
        void status_reply(Error, const std::string &);
        bool switch_timeout();
index 5f88780a7c02e937ca4fcfe4bc7cc36fcfa84f54..7a4f3bab822f9496b3c8736022b1f08a8f29c718 100644 (file)
@@ -33,10 +33,8 @@ private:
                void track(unsigned);
        };
 
-       typedef map<unsigned, unsigned> TrackMap;
-
-       TrackMap inventory;
-       TrackMap layout;
+       map<unsigned, unsigned> inventory;
+       map<unsigned, unsigned> layout;
 
        void load_inventory(const string &);
        void load_layout(const string &);
@@ -79,9 +77,9 @@ void ShoppingList::load_layout(const string &fn)
 void ShoppingList::print(ostream &out)
 {
        out<<"// Need to get:\n";
-       for(TrackMap::iterator i=layout.begin(); i!=layout.end(); ++i)
+       for(map<unsigned, unsigned>::iterator i=layout.begin(); i!=layout.end(); ++i)
        {
-               TrackMap::iterator j=inventory.find(i->first);
+               map<unsigned, unsigned>::iterator j=inventory.find(i->first);
                if(j!=inventory.end())
                {
                        if(j->second<i->second)
@@ -92,17 +90,17 @@ void ShoppingList::print(ostream &out)
        }
 
        out<<"// Pre-existing:\n";
-       for(TrackMap::iterator i=layout.begin(); i!=layout.end(); ++i)
+       for(map<unsigned, unsigned>::iterator i=layout.begin(); i!=layout.end(); ++i)
        {
-               TrackMap::iterator j=inventory.find(i->first);
+               map<unsigned, unsigned>::iterator j=inventory.find(i->first);
                if(j!=inventory.end())
                        out<<"track "<<i->first<<' '<<min(i->second,j->second)<<";\n";
        }
 
        out<<"// Unused:\n";
-       for(TrackMap::iterator i=inventory.begin(); i!=inventory.end(); ++i)
+       for(map<unsigned, unsigned>::iterator i=inventory.begin(); i!=inventory.end(); ++i)
        {
-               TrackMap::iterator j=layout.find(i->first);
+               map<unsigned, unsigned>::iterator j=layout.find(i->first);
                if(j!=layout.end())
                {
                        if(j->second<i->second)