kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #22212
[PATCH 3/5] Move container functionality
The "set of pin numbers" functionality is also useful outside the pin table
dialog, so create a wrapper class that exposes the relevant interfaces.
---
eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 2 +-
eeschema/pin_number.h | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
index 2145403..68a66ca 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
@@ -387,7 +387,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue( wxVariant& aValu
}
else
{
- std::set<wxString, PinNumbers::less> values;
+ PinNumbers values;
for( std::list<Pin*>::const_iterator i = m_Members.begin(); i != m_Members.end(); ++i )
{
diff --git a/eeschema/pin_number.h b/eeschema/pin_number.h
index d3fb6f2..d1e9c6f 100644
--- a/eeschema/pin_number.h
+++ b/eeschema/pin_number.h
@@ -27,6 +27,8 @@
#include <wx/string.h>
+#include <set>
+
typedef wxString PinNumber;
class PinNumbers
@@ -34,6 +36,7 @@ class PinNumbers
public:
static int Compare( PinNumber const &lhs, PinNumber const &rhs );
+private:
struct less
{
bool operator()( PinNumber const &lhs, PinNumber const &rhs ) const
@@ -41,6 +44,24 @@ public:
return Compare( lhs, rhs ) < 0;
}
};
+
+ typedef std::set< PinNumber, less > container_type;
+
+public:
+ typedef container_type::value_type value_type;
+ typedef container_type::iterator iterator;
+ typedef container_type::const_iterator const_iterator;
+
+ void insert( value_type const &v ) { pins.insert( v ); }
+ container_type::size_type size() const { return pins.size(); }
+
+ iterator begin() { return pins.begin(); }
+ iterator end() { return pins.end(); }
+ const_iterator begin() const { return pins.begin(); }
+ const_iterator end() const { return pins.end(); }
+
+private:
+ container_type pins;
};
#endif
Follow ups
References