From: Mikko Rasa Date: Sat, 21 May 2011 20:49:42 +0000 (+0000) Subject: Use a typedef for the function map in VehicleType X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=84f8ba5112467ef87c92953b40ef9b22a6fd28b5;p=r2c2.git Use a typedef for the function map in VehicleType --- diff --git a/source/engineer/trainpanel.cpp b/source/engineer/trainpanel.cpp index 51e7a88..10208bf 100644 --- a/source/engineer/trainpanel.cpp +++ b/source/engineer/trainpanel.cpp @@ -83,9 +83,9 @@ TrainPanel::TrainPanel(Engineer &e, Train &t): lbl_status->set_geometry(GLtk::Geometry(10, 60, geom.w-20, 20)); status.signal_changed.connect(sigc::mem_fun(this, &TrainPanel::train_status_changed)); - const map &funcs = train.get_locomotive_type().get_functions(); + const VehicleType::FunctionMap &funcs = train.get_locomotive_type().get_functions(); unsigned x = 10; - for(map::const_iterator i=funcs.begin(); i!=funcs.end(); ++i, x+=36) + for(VehicleType::FunctionMap::const_iterator i=funcs.begin(); i!=funcs.end(); ++i, x+=36) { string fname = i->second; fname[0] = toupper(fname[0]); diff --git a/source/libr2c2/vehicletype.h b/source/libr2c2/vehicletype.h index 33d7d65..949195d 100644 --- a/source/libr2c2/vehicletype.h +++ b/source/libr2c2/vehicletype.h @@ -129,11 +129,13 @@ public: typedef std::vector RodArray; + typedef std::map FunctionMap; + private: ArticleNumber art_nr; std::string name; bool locomotive; - std::map functions; + FunctionMap functions; bool swap_direction; float length; float width; @@ -150,7 +152,7 @@ public: const std::string &get_name() const { return name; } bool is_locomotive() const { return locomotive; } unsigned get_max_function() const; - const std::map &get_functions() const { return functions; } + const FunctionMap &get_functions() const { return functions; } bool get_swap_direction() const { return swap_direction; } float get_length() const { return length; } float get_width() const { return width; } diff --git a/source/remote/trainpanel.cpp b/source/remote/trainpanel.cpp index e0f2658..f0d6d14 100644 --- a/source/remote/trainpanel.cpp +++ b/source/remote/trainpanel.cpp @@ -44,8 +44,8 @@ TrainPanel::TrainPanel(Remote &r, R2C2::Client &c, R2C2::NetTrain &t): Gtk::HBox *func_box = new Gtk::HBox(false, 5); vbox->add(*manage(func_box)); - const std::map &funcs = train.get_loco_type().get_functions(); - for(std::map::const_iterator i=funcs.begin(); i!=funcs.end(); ++i) + const R2C2::VehicleType::FunctionMap &funcs = train.get_loco_type().get_functions(); + for(R2C2::VehicleType::FunctionMap::const_iterator i=funcs.begin(); i!=funcs.end(); ++i) { Gtk::CheckButton *&chk = chk_funcs[i->first]; chk = new Gtk::CheckButton(i->second);