[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c679655 19/46: Replace table_type_converter::
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c679655 19/46: Replace table_type_converter::get_all() with register_all() |
Date: |
Wed, 22 Jul 2020 11:05:12 -0400 (EDT) |
branch: master
commit c679655d670e11749d1bfebf8f27b19109b26989
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>
Replace table_type_converter::get_all() with register_all()
We don't really need to have a map with all the converters at all, all
we need is a way to register them and this can be done with a dedicated
function.
And this function can be implemented by simply registering all the
custom converters, there is no any need to create a map just to iterate
over it.
---
census_view.cpp | 43 +++++++++----------------------------------
1 file changed, 9 insertions(+), 34 deletions(-)
diff --git a/census_view.cpp b/census_view.cpp
index 1a0a811..ea27cd1 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1177,7 +1177,7 @@ class table_type_converter
virtual void register_data_type(wxGrid* grid) const = 0;
- static std::map<std::string, table_type_converter const*> const& get_all();
+ static void register_all(wxGrid* grid);
static table_type_converter const& get_by_value(any_member<Input> const&
value);
private:
@@ -1185,8 +1185,7 @@ class table_type_converter
static table_type_converter const& get_impl();
};
-// The base class for custom table type convertors which uses an own renderer
-// and an editor.
+// The base class for table type converters using custom renderer and editor.
class table_custom_type_converter : public table_type_converter
{
@@ -1384,33 +1383,12 @@ class table_string_converter : public
table_standard_type_converter
}
};
-std::map<std::string, table_type_converter const*> const&
-table_type_converter::get_all()
-{
- static std::map<std::string, table_type_converter const*> const all
- {{ get_impl<table_bool_converter>().type()
- ,&get_impl<table_bool_converter>()
- }
- ,{ get_impl<table_string_converter>().type()
- ,&get_impl<table_string_converter>()
- }
- ,{ get_impl<table_sequence_converter>().type()
- ,&get_impl<table_sequence_converter>()
- }
- ,{ get_impl<table_enum_converter>().type()
- ,&get_impl<table_enum_converter>()
- }
- ,{ get_impl<table_int_range_converter>().type()
- ,&get_impl<table_int_range_converter>()
- }
- ,{ get_impl<table_double_range_converter>().type()
- ,&get_impl<table_double_range_converter>()
- }
- ,{ get_impl<table_date_converter>().type()
- ,&get_impl<table_date_converter>()
- }
- };
- return all;
+void
+table_type_converter::register_all(wxGrid* grid)
+{
+ get_impl<table_sequence_converter>().register_data_type(grid);
+ get_impl<table_double_range_converter>().register_data_type(grid);
+ get_impl<table_date_converter>().register_data_type(grid);
}
table_type_converter const&
@@ -2043,10 +2021,7 @@ wxWindow* CensusGridView::CreateChildWindow()
grid_window_->DisableDragRowSize();
grid_window_->SelectRow(0);
- for(auto const& it : table_type_converter::get_all())
- {
- it.second->register_data_type(grid_window_);
- }
+ table_type_converter::register_all(grid_window_);
// Show headers.
document().Modify(false);
- [lmi-commits] [lmi] master 9f1cb2e 39/46: Only auto-size columns when they change, not after each update, (continued)
- [lmi-commits] [lmi] master 9f1cb2e 39/46: Only auto-size columns when they change, not after each update, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master b3ac65b 43/46: Allow wxGrid to compute census view column sizes more efficiently, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master ece93a0 17/46: Make check for Alt-Enter more obvious in the code, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master b57ed4a 18/46: Remove deleted DatumSequenceEditor copy-related methods, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 041ccfc 30/46: Optimize changing grid columns number too, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 53a288a 33/46: Restore "delete_cells" update UI handler for CensusDVCView, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 3c3d0c0 36/46: Explain grid customizations in the function creating it, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 337d81f 37/46: Make UponDeleteCells() more efficient for large censuses, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 2922db9 44/46: Disallow single cell operations when non-current row is selected, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master d337a22 45/46: Upgrade wx, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master c679655 19/46: Replace table_type_converter::get_all() with register_all(),
Greg Chicares <=
- [lmi-commits] [lmi] master 7dc508e 35/46: Don't select the first row initially in the grid census view, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 810de0a 26/46: Remove unnecessary wxGrid::IsCellEditControlEnabled() calls, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master adc4089 28/46: Optimize changing grid dimensions when pasting into the census, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master be4c2a4 32/46: Add a comment explaining why the first column is read-only, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master b7944ba 38/46: Resize only columns, not rows, in update_visible_columns(), Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master b399a7d 40/46: Remove automatic column auto-sizing in wxGrid-based census view, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master d4ad57b 42/46: Disallow "Edit/Run" cell when multiple grid rows are selected, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master d39ff1d 07/46: Use wxGridCellAttrPtr instead of manual reference counting, Greg Chicares, 2020/07/22