[glom/modification: 31/33] Const correction to fix the build.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Subject: [glom/modification: 31/33] Const correction to fix the build.
- Date: Thu, 4 Jun 2009 17:01:56 -0400 (EDT)
commit b00646a988ef5a1c7b7e62006fe13ec5913a392e
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jun 4 19:22:29 2009 +0200
Const correction to fix the build.
---
glom/base_db.cc | 36 +++---------------------------------
glom/base_db.h | 33 ++++++++++++++++++++++++++++++++-
glom/base_db_table_data.cc | 4 ++--
3 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/glom/base_db.cc b/glom/base_db.cc
index e6abf5b..5e4f29c 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -1590,36 +1590,6 @@ Glib::RefPtr<Gnome::Gda::Connection> Base_DB::get_connection()
}
-/** A predicate for use with std::find_if() to find a std::pair whose
- * first item is the same field.
- */
-class predicate_pair_has_field
-{
-public:
- predicate_pair_has_field(const sharedptr<const Field>& field)
- {
- m_field = field;
- }
-
- template <class T_Second>
- bool operator() (const std::pair<sharedptr<Field>, T_Second>& element)
- {
- sharedptr<Field> field = element.first;
-
- if(!field && !m_field)
- return true;
-
- if(!field || !m_field)
- return false;
-
- //TODO: Check more than just the name:
- return (m_field->get_name() == field->get_name());
- }
-
-private:
- sharedptr<const Field> m_field;
-};
-
bool Base_DB::record_new(const Glib::ustring& table_name, const Gnome::Gda::Value& primary_key_value, const type_field_values& field_values)
{
sharedptr<const Field> fieldPrimaryKey = get_field_primary_key_for_table(table_name);
@@ -1633,7 +1603,7 @@ bool Base_DB::record_new(const Glib::ustring& table_name, const Gnome::Gda::Valu
for(type_vec_fields::const_iterator iter = all_fields.begin(); iter != all_fields.end(); ++iter)
{
//TODO: Search for the non-related field with the name, not just the field with the name:
- sharedptr<Field> field = *iter;
+ sharedptr<const Field> field = *iter;
type_field_values::const_iterator iterFind = std::find_if(field_values_plus_others.begin(), field_values_plus_others.end(), predicate_pair_has_field(field));
if(iterFind == field_values_plus_others.end())
{
@@ -1711,7 +1681,7 @@ bool Base_DB::record_new(const Glib::ustring& table_name, const Gnome::Gda::Valu
for(type_field_values::const_iterator iter = field_values_plus_others.begin(); iter != field_values_plus_others.end(); ++iter)
{
- sharedptr<Field> field = iter->first;
+ sharedptr<const Field> field = iter->first;
//sharedptr<LayoutItem_Field> layout_item = *iter;
const Glib::ustring field_name = field->get_name();
if(true) //!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by entering new data in a related field of the related record.
@@ -1797,7 +1767,7 @@ bool Base_DB::record_new(const Glib::ustring& table_name, const Gnome::Gda::Valu
const Gnome::Gda::Value& field_value = iter->second;
- sharedptr<Field> field = iter->first;
+ sharedptr<const Field> field = iter->first;
sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
layout_item->set_full_field_details(field);
LayoutFieldInRecord field_in_record(layout_item, table_name, fieldPrimaryKey, primary_key_value);
diff --git a/glom/base_db.h b/glom/base_db.h
index 5248ee6..cf4665e 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -114,7 +114,7 @@ public:
bool change_columns(const Glib::ustring& table_name, const type_vec_const_fields& old_fields, type_vec_fields& fields, Gtk::Window* parent_window) const;
#endif //GLOM_ENABLE_CLIENT_ONLY
- typedef std::pair< sharedptr<Field>, Gnome::Gda::Value> type_field_and_value;
+ typedef std::pair< sharedptr<const Field>, Gnome::Gda::Value> type_field_and_value;
typedef std::list<type_field_and_value> type_field_values;
/** Create a new record with all the specified field values.
@@ -429,6 +429,37 @@ private:
protected:
+/** A predicate for use with std::find_if() to find a std::pair whose
+ * first item is the same field.
+ */
+class predicate_pair_has_field
+{
+public:
+ predicate_pair_has_field(const sharedptr<const Field>& field)
+ {
+ m_field = field;
+ }
+
+ template <class T_Second>
+ bool operator() (const std::pair<sharedptr<const Field>, T_Second>& element)
+ {
+ sharedptr<const Field> field = element.first;
+
+ if(!field && !m_field)
+ return true;
+
+ if(!field || !m_field)
+ return false;
+
+ //TODO: Check more than just the name:
+ return (m_field->get_name() == field->get_name());
+ }
+
+private:
+ sharedptr<const Field> m_field;
+};
+
+
type_field_calcs m_FieldsCalculationInProgress; //Prevent circular calculations and recalculations.
//Extra creation/modification fields to set:
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index eec0e1e..433f687 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -75,12 +75,12 @@ bool Base_DB_Table_Data::record_new_with_entered_data(const Gnome::Gda::Value& p
//Add values for all fields that default to something, not just the shown ones:
//For instance, we must always add the primary key, and fields with default/calculated/lookup values:
const type_vecLayoutFields fieldsOnLayout = m_FieldsShown;
- for(type_vecLayoutFields::iterator iter = fieldsOnLayout.begin(); iter != fieldsOnLayout.end(); ++iter)
+ for(type_vecLayoutFields::const_iterator iter = fieldsOnLayout.begin(); iter != fieldsOnLayout.end(); ++iter)
{
//Check that we don't have a value for this field already:
//(This gives priority to specified fields values rather than entered field values.)
//TODO: Search for the non-related field with the name, not just the field with the name:
- type_field_values::const_iterator iterFind = std::find_if(field_values_plus_entered.begin(), field_values_plus_entered.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
+ type_field_values::const_iterator iterFind = std::find_if(field_values_plus_entered.begin(), field_values_plus_entered.end(), predicate_pair_has_field((*iter)->get_full_field_details()));
if(iterFind == field_values_plus_entered.end())
{
sharedptr<const LayoutItem_Field> layoutitem = *iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]