]> git.tdb.fi Git - r2c2.git/commitdiff
Code reformatting:
authorMikko Rasa <tdb@tdb.fi>
Sat, 23 May 2009 07:11:51 +0000 (07:11 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 23 May 2009 07:11:51 +0000 (07:11 +0000)
- Remove alignment from variable and function declarations
- Reorder and group class members

28 files changed:
source/3d/layout.h
source/3d/track.cpp
source/3d/track.h
source/designer/designer.cpp
source/designer/designer.h
source/designer/input.h
source/designer/manipulator.h
source/designer/measure.h
source/designer/selection.h
source/engineer/engineer.cpp
source/engineer/engineer.h
source/engineer/trainproperties.h
source/libmarklin/block.h
source/libmarklin/command.h
source/libmarklin/control.cpp
source/libmarklin/control.h
source/libmarklin/layout.cpp
source/libmarklin/layout.h
source/libmarklin/locomotive.h
source/libmarklin/route.h
source/libmarklin/sensor.h
source/libmarklin/track.cpp
source/libmarklin/track.h
source/libmarklin/trackpart.h
source/libmarklin/tracktype.h
source/libmarklin/trafficmanager.h
source/libmarklin/train.h
source/libmarklin/turnout.h

index c2faa46344f1869f45be94c7f4ecbda65a4824de..208ddacacba28254f267b6d121e44190f0f15d46 100644 (file)
@@ -16,9 +16,9 @@ namespace Marklin {
 class Layout3D
 {
 private:
-       Layout     &layout;
+       Layout &layout;
        std::list<Track3D *> tracks;
-       unsigned   quality;
+       unsigned quality;
 
 public:
        Layout3D(Layout &);
@@ -26,7 +26,7 @@ public:
 
        void set_quality(unsigned);
        const std::list<Track3D *> &get_tracks() const { return tracks; }
-       void  render(bool =false) const;
+       void render(bool =false) const;
        Track3D &get_track(const Track &) const;
        Track3D *pick_track(float, float, float) const;
 private:
index 5857e52d8813b8c29053e7dd107d882d7bf0f35c..f9b03ed00220fc78659ee591730cc6f2125e0414 100644 (file)
@@ -25,6 +25,11 @@ Track3D::Track3D(Track &t, unsigned q):
        build_object();
 }
 
+void Track3D::set_color(const Msp::GL::Color &c)
+{
+       color=c;
+}
+
 void Track3D::set_quality(unsigned q)
 {
        quality=q;
index 7131877de8174688e4fff8801d759bcf4c8b9a43..660d1cff5fca9105a5d7dc04e03164c9b6cc56b2 100644 (file)
@@ -20,7 +20,7 @@ namespace Marklin {
 class Track3D
 {
 private:
-       Track        &track;
+       Track &track;
        Msp::GL::Color color;
        std::vector<Point> border;
        Msp::GL::VertexArray varray;
@@ -32,10 +32,10 @@ private:
 public:
        Track3D(Track &, unsigned);
 
-       void set_color(const Msp::GL::Color &c)  { color=c; }
+       Track &get_track() const { return track; }
+       void set_color(const Msp::GL::Color &);
        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;
index f2c6fb8c00559fb463629205036c3dfd083a1ea7..c1bbc3ff17dfb4f56b7bd1fa15200ab9be6d4fb4 100644 (file)
@@ -30,12 +30,14 @@ using namespace std;
 using namespace Marklin;
 using namespace Msp;
 
+Application::RegApp<Designer> Designer::reg;
+
 Designer::Designer(int argc, char **argv):
        screen_w(1280),
        screen_h(960),
        base_mesh(0),
-       input(0),
        mode(SELECT),
+       input(0),
        cam_yaw(M_PI/2),
        cam_pitch(-M_PI/4),
        cam_pos(0, -0.5, 0.5),
@@ -691,5 +693,3 @@ void Designer::input_dismiss()
        input=0;
        mode=SELECT;
 }
-
-Application::RegApp<Designer> Designer::reg;
index 598c1aebd1baf7db5c26e342989874e16bfb1c81..8dbc9d44d03298b94a8c69384b4cb7299cf0828a 100644 (file)
@@ -41,46 +41,54 @@ private:
        Msp::Graphics::Display *dpy;
        Msp::Graphics::Window *wnd;
        Msp::Graphics::GLContext *glc;
-       unsigned       screen_w;
-       unsigned       screen_h;
-       Msp::GL::Font  *font;
+       unsigned screen_w;
+       unsigned screen_h;
+       Msp::GL::Font *font;
+
        Marklin::Catalogue catalogue;
-       Marklin::Layout    *layout;
-       Marklin::Layout3D  *layout_3d;
-       Marklin::Layout    *cat_layout;
-       Marklin::Layout3D  *cat_layout_3d;
-       Msp::GL::Mesh  *base_mesh;
-       Selection      *selection;
-       Manipulator    *manipulator;
-       Measure        *measure;
-       Input          *input;
-       Mode           mode;
-       float          cam_yaw;
-       float          cam_pitch;
+       Marklin::Layout *layout;
+       Marklin::Layout3D *layout_3d;
+       Marklin::Layout *cat_layout;
+       Marklin::Layout3D *cat_layout_3d;
+       Msp::GL::Mesh *base_mesh;
+
+       Mode mode;
+       Selection *selection;
+       Manipulator *manipulator;
+       Measure *measure;
+       Input *input;
+
+       float cam_yaw;
+       float cam_pitch;
        Marklin::Point cam_pos;
-       bool           shift;
-       int            move_x;
-       int            move_y;
-       int            zoom;
-       int            rotate;
-       int            pitch;
-       int            pointer_x;
-       int            pointer_y;
-       int            tooltip_x;
-       int            tooltip_y;
-       std::string    tooltip;
+
+       bool shift;
+       int move_x;
+       int move_y;
+       int zoom;
+       int rotate;
+       int pitch;
+       int pointer_x;
+       int pointer_y;
+
+       int tooltip_x;
+       int tooltip_y;
+       std::string tooltip;
        Msp::Time::TimeStamp tooltip_timeout;
+
        Msp::Time::TimeStamp last_tick;
 
+       static Msp::Application::RegApp<Designer> reg;
+
 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 &);
+       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);
@@ -100,8 +108,6 @@ private:
        void turnout_id_accept();
        void sensor_id_accept();
        void input_dismiss();
-
-       static Msp::Application::RegApp<Designer> reg;
 };
 
 #endif
index 3449e2b8cb1612d61322f7016d7ae901fab289a6..9a4dbccd565a4c8580b48e3d58a51774ac700840 100644 (file)
@@ -19,15 +19,17 @@ public:
        sigc::signal<void> signal_accept;
        sigc::signal<void> signal_cancel;
 
-       Input(Designer &, const std::string &, const std::string & ="");
-       const std::string &get_text() { return text; }
-       void key_press(unsigned, unsigned, wchar_t);
-       void render();
 private:
-       Designer    &designer;
+       Designer &designer;
        std::string title;
        std::string text;
-       unsigned    pos;
+       unsigned pos;
+
+public:
+       Input(Designer &, const std::string &, const std::string & =std::string());
+       const std::string &get_text() { return text; }
+       void key_press(unsigned, unsigned, wchar_t);
+       void render();
 };
 
 #endif
index b482251294ee21f9242c68f7dbb1b708cffc25b7..9177f971b66d2d63011d69601306287b4dca1c8e 100644 (file)
@@ -50,8 +50,13 @@ private:
                float height;
        };
 
-       Designer   &designer;
-       Selection  *selection;
+public:
+       sigc::signal<void, const std::string &> signal_status;
+       sigc::signal<void, bool> signal_done;
+
+private:
+       Designer &designer;
+       Selection *selection;
        std::vector<MTrack> tracks;
        Marklin::Point center;
 
@@ -60,19 +65,16 @@ private:
        float wrap_rot;
 
        Marklin::Point gpointer;
-       int            pointer_y;
-       Mode           mode;
+       int pointer_y;
+       Mode mode;
        Marklin::Point move_origin;
-       float          angle;
-       float          rot_origin;
-       int            elev_origin;
+       float angle;
+       float rot_origin;
+       int elev_origin;
        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 *);
index e4f230f6b90c201de7c0222d20d4f17b47751ac2..f68178dcacaf2b2368a641c53d1fb0fd5426420a 100644 (file)
@@ -22,6 +22,11 @@ private:
                ACTIVE
        };
 
+public:
+       sigc::signal<void> signal_done;
+       sigc::signal<void> signal_changed;
+
+private:
        Designer &designer;
        Marklin::Point pointer;
        Marklin::Point spoint;
@@ -32,13 +37,10 @@ private:
        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_parallel_distance() const { return par_dist; }
        float get_perpendicular_distance() const { return perp_dist; }
-       float get_angle_difference() const       { return adiff; }
+       float get_angle_difference() const { return adiff; }
        void start();
        void button_press(int, int, float, float, unsigned);
        void pointer_motion(int, int, float, float);
index 802c6f2b1d54e7b67f42fa1ceecb0b673ffe8d46..abae6832ccfe2cc75f2777be45bc0be4cc636ba3 100644 (file)
@@ -14,12 +14,13 @@ Distributed under the GPL
 
 class Selection
 {
+public:
+       sigc::signal<void> signal_changed;
+
 private:
        std::set<Marklin::Track *> tracks;
 
 public:
-       sigc::signal<void> signal_changed;
-
        const std::set<Marklin::Track *> &get_tracks() const { return tracks; }
        Marklin::Track *get_track() const;
        unsigned size() const { return tracks.size(); }
index 4b8ba70a1426940ecadffdd8d8c367959d2b5785..83827c142f61f023a04fb7a005a3012d0c37ad40 100644 (file)
@@ -37,16 +37,16 @@ Engineer::Engineer(int argc, char **argv):
        fullscreen(false),
        layout(catalogue),
        layout_3d(layout),
-       no_lighting(false),
+       train_prop(0),
+       train_prop_stale(false),
        placing_train(0),
        placing_block(0),
        placing_entry(0),
-       simulate(false),
-       train_prop(0),
-       train_prop_stale(false)
+       no_lighting(false),
+       simulate(false)
 {
        string res;
-       bool   debug=false;
+       bool debug=false;
        string device="/dev/ttyS0";
        unsigned quality=4;
 
@@ -267,13 +267,13 @@ void Engineer::tick()
                GL::Immediate imm((GL::COLOR4_UBYTE, GL::VERTEX2));
                imm.color(1.0f, 1.0f, 1.0f);
                imm.begin(GL::TRIANGLE_FAN);
-               imm.vertex(0.08,   0);
-               imm.vertex(0.05,   0.03);
-               imm.vertex(0.05,   0.01);
-               imm.vertex(0,      0.01);
-               imm.vertex(0,     -0.01);
-               imm.vertex(0.05,  -0.01);
-               imm.vertex(0.05,  -0.03);
+               imm.vertex(0.08,  0);
+               imm.vertex(0.05,  0.03);
+               imm.vertex(0.05,  0.01);
+               imm.vertex(0,     0.01);
+               imm.vertex(0,    -0.01);
+               imm.vertex(0.05, -0.01);
+               imm.vertex(0.05, -0.03);
                imm.end();
 
                GL::pop_matrix();
index 0c295bf43985623cb074403d0e57f888bfba4e32..ad4bbccec1d3e7ab6cb1971144844282145d4e38 100644 (file)
@@ -27,42 +27,46 @@ class TrainProperties;
 class Engineer: public Msp::Application
 {
 private:
-       Msp::Graphics::Display   *dpy;
-       Msp::Graphics::Window    *wnd;
+       Msp::Graphics::Display *dpy;
+       Msp::Graphics::Window *wnd;
        Msp::Graphics::GLContext *glc;
-       Msp::GLtk::Root          *root;
-       unsigned           screen_w;
-       unsigned           screen_h;
-       bool               fullscreen;
-       Marklin::Catalogue catalogue;
-       Marklin::Layout    layout;
-       Marklin::Layout3D  layout_3d;
-       Marklin::Control   control;
-       Marklin::Point     cam_pos;
-       float              cam_rot;
+       unsigned screen_w;
+       unsigned screen_h;
+       bool fullscreen;
        Msp::GLtk::Resources ui_res;
-       MainPanel          *main_panel;
-       std::list<TrainPanel *> train_panels;
-       bool               no_lighting;
+       Msp::GLtk::Root *root;
+
+       Marklin::Catalogue catalogue;
+       Marklin::Layout layout;
+       Marklin::Layout3D layout_3d;
+       Marklin::Control control;
        Marklin::TrafficManager *trfc_mgr;
-       Marklin::Train     *placing_train;
-       Marklin::Block     *placing_block;
-       unsigned           placing_entry;
-       bool               simulate;
-       TrainProperties    *train_prop;
-       bool               train_prop_stale;
+
+       Marklin::Point cam_pos;
+       float cam_rot;
+
+       MainPanel *main_panel;
+       std::list<TrainPanel *> train_panels;
+       TrainProperties *train_prop;
+       bool train_prop_stale;
+       Marklin::Train *placing_train;
+       Marklin::Block *placing_block;
+       unsigned placing_entry;
+
+       bool no_lighting;
+       bool simulate;
 
 public:
        Engineer(int argc, char **argv);
        ~Engineer();
 
        const Marklin::Catalogue &get_catalogue() const { return catalogue; }
-       Marklin::Control &get_control()    { return control; }
-       void             add_train();
-       Marklin::Train   *add_train(const Marklin::LocoType &, unsigned);
-       void     place_train(Marklin::Train &);
-       int      main();
-       void     quit() { exit(0); }
+       Marklin::Control &get_control() { return control; }
+       void add_train();
+       Marklin::Train *add_train(const Marklin::LocoType &, unsigned);
+       void place_train(Marklin::Train &);
+       int main();
+       void quit() { exit(0); }
 private:
        void tick();
        void key_press(unsigned, unsigned, wchar_t);
index 62dc85adaccc5b7a5b49f321c14586e074b176cb..0171cf59f64e3bf420f0f6a5cea45a5378b26c40 100644 (file)
@@ -17,6 +17,9 @@ class Engineer;
 
 class TrainProperties: public Msp::GLtk::Panel
 {
+public:
+       sigc::signal<void> signal_ok;
+
 private:
        Engineer &engineer;
        Marklin::Train *train;
@@ -25,8 +28,6 @@ private:
        Msp::GLtk::Entry *ent_name;
 
 public:
-       sigc::signal<void> signal_ok;
-
        TrainProperties(Engineer &, Msp::GLtk::Resources &, Marklin::Train *);
 private:
        void ok_clicked();
index 68c57b88e39c102f8d38e5f8b75f00c93fd51afd..770a3520289227830b37d40df45ce1d12ca83cc8 100644 (file)
@@ -22,9 +22,9 @@ class Block
 public:
        struct Endpoint
        {
-               Track    *track;
+               Track *track;
                unsigned track_ep;
-               Block    *link;
+               Block *link;
                unsigned routes;
 
                Endpoint(Track *, unsigned);
@@ -32,12 +32,12 @@ public:
 
 private:
        TrafficManager &trfc_mgr;
-       unsigned       id;
-       unsigned       sensor_id;
-       unsigned       turnout_id;
-       std::set<Track *>     tracks;
+       unsigned id;
+       unsigned sensor_id;
+       unsigned turnout_id;
+       std::set<Track *> tracks;
        std::vector<Endpoint> endpoints;
-       const Train    *train;
+       const Train *train;
 
 public:
        Block(TrafficManager &, Track &);
index a270be0af0083ca80e68f3225029a0bf4fc22c04..e6123c31b625390842c09b7aa22fea64065a18dc 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -19,6 +19,9 @@ class Reply;
 
 class Command
 {
+public:
+       sigc::signal<void, const Reply &> signal_done;
+
 private:
        Cmd cmd;
        unsigned char data[128];
@@ -26,12 +29,10 @@ private:
        bool sent;
 
 public:
-       sigc::signal<void, const Reply &> signal_done;
-
        Command(Cmd, const unsigned char *, unsigned);
 
        void send(int);
-       bool get_sent() const   { return sent; }
+       bool is_sent() const { return sent; }
        Cmd get_command() const { return cmd; }
 
        friend std::ostream &operator<<(std::ostream &, const Command &);
index 6c6ceb37da500e789d9a295ad68b1d0a53feb68f..3eab42ce57b4e90aa0ac6840aeec242fcb1ec1e7 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -39,22 +39,6 @@ Control::~Control()
        close(serial_fd);
 }
 
-void Control::set_power(bool p)
-{
-       power=p;
-       if(power)
-               command(CMD_POWER_ON);
-       else
-               command(CMD_POWER_OFF);
-
-       signal_power_event.emit(power);
-}
-
-void Control::set_debug(bool d)
-{
-       debug=d;
-}
-
 void Control::open(const string &dev)
 {
        serial_fd=::open(dev.c_str(), O_RDWR);
@@ -104,6 +88,22 @@ void Control::open(const string &dev)
        command(CMD_STATUS).signal_done.connect(sigc::mem_fun(this, &Control::status_done));
 }
 
+void Control::set_debug(bool d)
+{
+       debug=d;
+}
+
+void Control::set_power(bool p)
+{
+       power=p;
+       if(power)
+               command(CMD_POWER_ON);
+       else
+               command(CMD_POWER_OFF);
+
+       signal_power_event.emit(power);
+}
+
 Command &Control::command(Cmd cmd)
 {
        queue.push_back(Command(cmd, 0, 0));
@@ -191,7 +191,7 @@ void Control::tick()
                poll_sensors=false;
        }
 
-       if(!queue.empty() && queue.front().get_sent())
+       if(!queue.empty() && queue.front().is_sent())
        {
                pollfd pfd={serial_fd, POLLIN, 0};
                if(poll(&pfd, 1, 0)>0)
@@ -221,16 +221,6 @@ Time::Timer::Slot &Control::set_timer(const Time::TimeDelta &dt)
        return timer.add(dt);
 }
 
-void Control::read_all(int fd, char *buf, int size)
-{
-       int pos=0;
-       while(pos<size)
-       {
-               int len=read(fd, buf+pos, size-pos);
-               pos+=len;
-       }
-}
-
 void Control::status_done(const Reply &reply)
 {
        power=((reply.get_data()[0]&0x08)!=0);
index 1d19263fb93da651807d5b0abaaa3d0978166eb5..61469a8ea8c289f75316943e1404fa690a2c0d65 100644 (file)
@@ -24,8 +24,13 @@ class Reply;
 
 class Control
 {
+public:
+       sigc::signal<void, bool> signal_power_event;
+       sigc::signal<void, unsigned, bool> signal_turnout_event;
+       sigc::signal<void, unsigned, bool> signal_sensor_event;
+
 private:
-       int  serial_fd;
+       int serial_fd;
        bool power;
        std::list<Command> queue;
        std::map<unsigned, Turnout *> turnouts;
@@ -37,36 +42,30 @@ private:
        Msp::Time::Timer timer;
 
 public:
-       sigc::signal<void, bool> signal_power_event;
-       sigc::signal<void, unsigned, bool> signal_turnout_event;
-       sigc::signal<void, unsigned, bool> signal_sensor_event;
-
        Control();
        ~Control();
 
-       void       set_power(bool);
-       bool       get_power() const { return power; }
-       void       set_debug(bool);
-       const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
-       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(Cmd);
-       Command    &command(Cmd, unsigned char);
-       Command    &command(Cmd, const unsigned char *, unsigned);
+       void open(const std::string &);
+       void set_debug(bool);
+       void set_power(bool);
+       bool get_power() const { return power; }
+       Command &command(Cmd);
+       Command &command(Cmd, unsigned char);
+       Command &command(Cmd, const unsigned char *, unsigned);
+       unsigned get_queue_length() const { return queue.size(); }
 
-       void       add_turnout(Turnout &);
-       Turnout    &get_turnout(unsigned) const;
-       void       add_locomotive(Locomotive &);
+       void add_turnout(Turnout &);
+       Turnout &get_turnout(unsigned) const;
+       const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
+       void add_locomotive(Locomotive &);
        Locomotive &get_locomotive(unsigned) const;
-       void       add_sensor(Sensor &);
-       Sensor     &get_sensor(unsigned) const;
+       void add_sensor(Sensor &);
+       Sensor &get_sensor(unsigned) const;
+       const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
 
-       void       tick();
+       void tick();
        Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
 private:
-       void read_all(int, char *, int);
-       std::string read_reply(Cmd);
        void status_done(const Reply &);
        void event_query_done(const Reply &);
        void turnout_event_done(const Reply &);
index 50eba62ab6f096b04427c3feb09e093b7858f3ef..8cfb95fa5e1c4f2d11ae471704516b8537bc2085 100644 (file)
@@ -79,36 +79,6 @@ void Layout::save(const string &fn)
                (*i)->save(st.sub);
                writer.write(st);
        }
-       /*ofstream out(fn.c_str());
-       if(!out) return -1;
-
-       filename=fn;
-
-       if(!base.empty())
-               out<<"base \""<<base<<"\";\n";
-       for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
-       {
-               out<<"track "<<(*i)->get_type().get_article_number()<<"\n{\n";
-               const Point &p=(*i)->get_position();
-               out<<"\tposition "<<p.x<<' '<<p.y<<' '<<p.z<<";\n";
-               out<<"\trotation "<<(*i)->get_rotation()<<";\n";
-               out<<"\tslope "<<(*i)->get_slope()<<";\n";
-
-               unsigned id=(*i)->get_turnout_id();
-               if(id)
-                       out<<"\tturnout_id "<<id<<";\n";
-
-               id=(*i)->get_sensor_id();
-               if(id)
-                       out<<"\tsensor_id "<<id<<";\n";
-
-               if((*i)->get_flex())
-                       out<<"\tflex true;\n";
-
-               out<<"};\n";
-       }
-
-       return 0;*/
 }
 
 
index f603d39f2f0b8ad3e4262e9b583254c4e13dc6eb..dd139250cbc8b9b18feb9f7b872fad53f7559510 100644 (file)
@@ -29,26 +29,27 @@ public:
                void track(unsigned);
        };
 
+public:
+       sigc::signal<void, Track &> signal_track_added;
+       sigc::signal<void, Track &> signal_track_removed;
+
 private:
        const Catalogue &catalogue;
        std::string base;
        std::set<Track *> tracks;
-       //RouteSeq    routes;
+       //std::set<Route *> routes;
 
 public:
-       sigc::signal<void, Track &> signal_track_added;
-       sigc::signal<void, Track &> signal_track_removed;
-
        Layout(const Catalogue &);
        ~Layout();
 
        const Catalogue &get_catalogue() const { return catalogue; }
        const std::string &get_base() const { return base; }
        const std::set<Track *> &get_tracks() const { return tracks; }
-       void  add_track(Track &);
-       void  remove_track(Track &);
-       void  check_links();
-       void  save(const std::string &);
+       void add_track(Track &);
+       void remove_track(Track &);
+       void check_links();
+       void save(const std::string &);
 };
 
 } // namespace Marklin
index 89b275ecb0db2020cc635dc695c8853648bd1d02..9ebccdae5e3bff30814ecba38324e7f607e58914 100644 (file)
@@ -21,34 +21,35 @@ class Reply;
 
 class Locomotive
 {
+public:
+       sigc::signal<void, unsigned> signal_speed_changing;
+       sigc::signal<void, unsigned> signal_speed_changed;
+       sigc::signal<void, unsigned, bool> signal_function_changed;
+
 private:
        const LocoType &type;
-       Control  &control;
+       Control &control;
        unsigned addr;
        unsigned speed;
-       bool     reverse;
+       bool reverse;
        unsigned funcs;
 
 public:
-       sigc::signal<void, unsigned> signal_speed_changing;
-       sigc::signal<void, unsigned> signal_speed_changed;
-       sigc::signal<void, unsigned, bool> signal_function_changed;
-
        Locomotive(const LocoType &, Control &, unsigned);
 
        const LocoType &get_type() const { return type; }
-       void     set_speed(unsigned);
-       void     set_reverse(bool);
-       void     set_function(unsigned, bool);
-       unsigned get_address() const   { return addr; }
-       unsigned get_speed() const     { return speed; }
-       bool     get_reverse() const   { return reverse; }
-       bool     get_function(unsigned f) const { return (funcs>>f)&1; }
-       void     refresh_status();
+       unsigned get_address() const { return addr; }
+       void set_speed(unsigned);
+       void set_reverse(bool);
+       void set_function(unsigned, bool);
+       unsigned get_speed() const { return speed; }
+       bool get_reverse() const { return reverse; }
+       bool get_function(unsigned f) const { return (funcs>>f)&1; }
+       void refresh_status();
 private:
-       void     send_command(bool);
-       void     status_reply(const Reply &);
-       bool     reverse_timeout();
+       void send_command(bool);
+       void status_reply(const Reply &);
+       bool reverse_timeout();
 };
 
 } // namespace Marklin
index f1f3664daac74325a98fdbab6db982d7f4f29338..a8e220d5de1c91997eda62fb4680d974bf73affa 100644 (file)
@@ -1,14 +1,13 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
 #ifndef LIBMARKLIN_ROUTE_H_
 #define LIBMARKLIN_ROUTE_H_
 
-#include <list>
 #include <map>
 #include <set>
 #include <string>
@@ -20,15 +19,17 @@ class Turnout;
 
 class Route
 {
-public:
-       Route();
-       const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
-       void add_track(Track *);
-       ~Route();
 private:
        std::string name;
        std::set<Track *> tracks;
        std::map<unsigned, Turnout *> turnouts;
+
+public:
+       Route();
+       ~Route();
+
+       const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
+       void add_track(Track *);
 };
 
 } // namespace Marklin
index 930b15fff890be651f82cbe1a0453cfb19f7be1a..45749ea28c142fe338436c378681b94a41fd0735 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2008  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -19,20 +19,21 @@ class Control;
 
 class Sensor
 {
+public:
+       sigc::signal<void, bool> signal_state_changed;
+
 private:
-       Control  &control;
+       Control &control;
        unsigned addr;
-       bool     state;
+       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();
+       bool get_state() const { return state; }
+       void tick();
 private:
        void sensor_event(unsigned, bool);
 };
index b6674aec0a2ea86e8242cc5fd8053a86a8fb57ab..73674ee8c39f340cf7665e153ff3908544a33b29 100644 (file)
@@ -55,6 +55,34 @@ void Track::set_flex(bool f)
        flex=f;
 }
 
+void Track::check_slope()
+{
+       if(links.size()!=2)
+               return;
+
+       if(links[0] && links[1])
+       {
+               Point epp0=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
+               Point epp1=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
+               pos.z=epp0.z;
+               slope=epp1.z-pos.z;
+       }
+       else
+       {
+               slope=0;
+               if(links[0])
+               {
+                       Point epp=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
+                       pos.z=epp.z;
+               }
+               else if(links[1])
+               {
+                       Point epp=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
+                       pos.z=epp.z;
+               }
+       }
+}
+
 void Track::set_turnout_id(unsigned i)
 {
        turnout_id=i;
@@ -190,34 +218,6 @@ Track *Track::get_link(unsigned i) const
        return links[i];
 }
 
-void Track::check_slope()
-{
-       if(links.size()!=2)
-               return;
-
-       if(links[0] && links[1])
-       {
-               Point epp0=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
-               Point epp1=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
-               pos.z=epp0.z;
-               slope=epp1.z-pos.z;
-       }
-       else
-       {
-               slope=0;
-               if(links[0])
-               {
-                       Point epp=links[0]->get_endpoint_position(links[0]->get_endpoint_by_link(*this));
-                       pos.z=epp.z;
-               }
-               else if(links[1])
-               {
-                       Point epp=links[1]->get_endpoint_position(links[1]->get_endpoint_by_link(*this));
-                       pos.z=epp.z;
-               }
-       }
-}
-
 int Track::traverse(unsigned i, unsigned route) const
 {
        const vector<Endpoint> &eps=type.get_endpoints();
@@ -334,12 +334,12 @@ void Track::save(list<DataFile::Statement> &st) const
 Track::Loader::Loader(Track &t):
        DataFile::BasicLoader<Track>(t)
 {
-       add("position",    &Loader::position);
-       add("rotation",    &Track::rot);
-       add("slope",       &Track::slope);
-       add("turnout_id",  &Track::turnout_id);
-       add("sensor_id",   &Track::sensor_id);
-       add("flex",        &Track::flex);
+       add("position",   &Loader::position);
+       add("rotation",   &Track::rot);
+       add("slope",      &Track::slope);
+       add("turnout_id", &Track::turnout_id);
+       add("sensor_id",  &Track::sensor_id);
+       add("flex",       &Track::flex);
 }
 
 void Track::Loader::position(float x, float y, float z)
index 3c96a82d2cec51f6463c3e958d1b417c3ebb003a..b000e346bf0b4943fc96b5f66733c9c24f109a51 100644 (file)
@@ -30,43 +30,49 @@ public:
 
 private:
        const TrackType &type;
-       Point        pos;
-       float        rot;
-       float        slope;
-       bool         flex;
-       unsigned     turnout_id;
-       unsigned     sensor_id;
+       Point pos;
+       float rot;
+       float slope;
+       bool flex;
+       unsigned turnout_id;
+       unsigned sensor_id;
        std::vector<Track *> links;
 
+       // Direct copying not allowed due to links.  See the copy() function.
+       Track(const Track &);
+       Track &operator=(const Track &);
 public:
        Track(const TrackType &);
        ~Track();
 
        const TrackType &get_type() const { return type; }
-       void            set_position(const Point &);
-       const Point     &get_position() const      { return pos; }
-       void            set_rotation(float);
-       float           get_rotation() const       { return rot; }
-       void            set_slope(float);
-       float           get_slope() const          { return slope; }
-       void            set_flex(bool);
-       bool            get_flex() const           { return flex; }
-       void            set_turnout_id(unsigned);
-       unsigned        get_turnout_id() const     { return turnout_id; }
-       void            set_sensor_id(unsigned);
-       unsigned        get_sensor_id() const      { return sensor_id; }
-       int             get_endpoint_by_link(const Track &) const;
-       Point           get_endpoint_position(unsigned) const;
-       float           get_endpoint_direction(unsigned) const;
-       bool            snap_to(Track &, bool);
-       bool            snap(Point &, float &) const;
-       void            break_link(Track &);
-       void            break_links();
+
+       void set_position(const Point &);
+       void set_rotation(float);
+       void set_slope(float);
+       void set_flex(bool);
+       const Point &get_position() const { return pos; }
+       float get_rotation() const { return rot; }
+       float get_slope() const { return slope; }
+       bool get_flex() const { return flex; }
+       void check_slope();
+
+       void set_turnout_id(unsigned);
+       void set_sensor_id(unsigned);
+       unsigned get_turnout_id() const { return turnout_id; }
+       unsigned get_sensor_id() const { return sensor_id; }
+
+       int get_endpoint_by_link(const Track &) const;
+       Point get_endpoint_position(unsigned) const;
+       float get_endpoint_direction(unsigned) const;
+       bool snap_to(Track &, bool);
+       bool snap(Point &, float &) const;
+       void break_link(Track &);
+       void break_links();
        const std::vector<Track *> &get_links() const { return links; }
-       Track           *get_link(unsigned) const;
-       void            check_slope();
-       int             traverse(unsigned, unsigned) const;
-       Point           get_point(unsigned, unsigned, float) const;
+       Track *get_link(unsigned) const;
+       int traverse(unsigned, unsigned) const;
+       Point get_point(unsigned, unsigned, float) const;
 
        /**
        Creates a copy of the track.  The new track will be almost identical, but
@@ -75,11 +81,6 @@ public:
        Track *copy() const;
 
        void save(std::list<Msp::DataFile::Statement> &) const;
-private:
-
-       // Direct copying not allowed due to links.  See the copy() function.
-       Track(const Track &);
-       Track &operator=(const Track &);
 };
 
 } // namespace Marklin
index de449b3a59e05e5d4c6c873b9ff8400a3db66396..34605ca25461201781518d909aa533fd2cc832c5 100644 (file)
@@ -25,12 +25,12 @@ struct TrackPart
                void start(float, float, float);
        };
 
-       Point    pos;
-       float    dir;
-       float    length;
-       float    radius;
+       Point pos;
+       float dir;
+       float length;
+       float radius;
        unsigned route;
-       bool     dead_end;
+       bool dead_end;
 
        TrackPart();
 
index ba1b95ff6aee5148d5335f47648e9c2e5de84b00..65aa1f28d834942d9e8314c0e9a0dda554d6f7ed 100644 (file)
@@ -28,8 +28,8 @@ public:
        };
 
 private:
-       unsigned     art_nr;
-       std::string  description;
+       unsigned art_nr;
+       std::string description;
        std::vector<TrackPart> parts;
        std::vector<Endpoint> endpoints;
 
@@ -42,10 +42,10 @@ public:
        float get_route_length(int) const;
        unsigned get_n_routes() const;
        const std::vector<TrackPart> &get_parts() const { return parts; }
-       const std::vector<Endpoint>  &get_endpoints() const { return endpoints; }
+       const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
 
 private:
-       void  collect_endpoints();
+       void collect_endpoints();
 };
 
 } // namespace Marklin
index b09c500ff39fabf0ed18d7f0ac2e154ffdd4e5d5..d75bf3ae50b48cecca640c87cb4ac354e5e6867a 100644 (file)
@@ -28,6 +28,8 @@ public:
                void train(unsigned, unsigned);
        };
 
+       sigc::signal<void, const Block &, const Train *> signal_block_reserved;
+
 private:
        Control &control;
        Layout &layout;
@@ -36,8 +38,6 @@ private:
        Msp::Time::TimeStamp last_tick;
 
 public:
-       sigc::signal<void, const Block &, const Train *> signal_block_reserved;
-
        TrafficManager(Control &, Layout &);
        ~TrafficManager();
 
index d95d4c43ea50b3e152d85bdc545fcccab70572e7..a4e2b150a327647236ebfa9f1d47350df2b218a0 100644 (file)
@@ -28,6 +28,9 @@ public:
                Loader(Train &);
        };
 
+       sigc::signal<void, const std::string &> signal_name_changed;
+       sigc::signal<void, const std::string &> signal_status_changed;
+
 private:
        struct BlockRef
        {
@@ -59,9 +62,6 @@ private:
        Point pos;
 
 public:
-       sigc::signal<void, const std::string &> signal_name_changed;
-       sigc::signal<void, const std::string &> signal_status_changed;
-
        Train(TrafficManager &, Locomotive &);
 
        void set_name(const std::string &);
index 616a7fedb3bcabddef78cd9dc52c56ea0a6185b1..279571499e5ce0c2bb3f4e2ba64b31167fa60b19 100644 (file)
@@ -21,21 +21,22 @@ class Reply;
 
 class Turnout
 {
+public:
+       sigc::signal<void, unsigned> signal_route_changing;
+       sigc::signal<void, unsigned> signal_route_changed;
+
 private:
-       Control  &control;
+       Control &control;
        unsigned addr;
        unsigned route;
-       bool     dual;
+       bool dual;
 
 public:
-       sigc::signal<void, unsigned> signal_route_changing;
-       sigc::signal<void, unsigned> signal_route_changed;
-
        Turnout(Control &, unsigned, bool =false);
 
-       void     set_route(unsigned);
+       void set_route(unsigned);
        unsigned get_address() const { return addr; }
-       unsigned get_route() const   { return route; }
+       unsigned get_route() const { return route; }
 private:
        void command(bool);
        void status_reply(const Reply &, bool);