mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #413 Removed one overload of CRange::findBy and one of CSequence::applyIf; they were never used and they caused a circular dependency.
Templatized another overload of applyIf to break a circular dependency.
This commit is contained in:
@@ -70,7 +70,7 @@ namespace BlackMiscTest
|
||||
// now Jane's time is over
|
||||
CPropertyIndexVariantMap anotherController;
|
||||
anotherController.addValue(CAtcStation::IndexController, CVariant::fromValue(CUser("445566", "Fuzzy")));
|
||||
atcList.applyIf(newController, anotherController);
|
||||
atcList.applyIf(BlackMisc::Predicates::Equals(newController), anotherController);
|
||||
|
||||
qDebug() << "-- after update via value map";
|
||||
qDebug() << atcList.toQString();
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define BLACKMISC_CONTAINERBASE_H
|
||||
|
||||
#include "range.h"
|
||||
#include "propertyindexvariantmap.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "predicates.h"
|
||||
#include "json.h"
|
||||
|
||||
@@ -14,20 +14,13 @@
|
||||
|
||||
#include "variant.h"
|
||||
#include "valueobject.h"
|
||||
#include "propertyindex.h"
|
||||
#include "propertyindexlist.h"
|
||||
#include "blackmiscexport.h"
|
||||
|
||||
// a) "propertyindex.h" needed for QMap below, despite forward declaration
|
||||
// b) "propertyindexlist.h" here causes circular dependencies
|
||||
|
||||
#include <QVariantMap>
|
||||
#include <QDBusArgument>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
// forward declaration
|
||||
class CPropertyIndex;
|
||||
class CPropertyIndexList;
|
||||
|
||||
/*!
|
||||
* Specialized value object compliant map for variants,
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#define BLACKMISC_RANGE_H
|
||||
|
||||
#include "blackmiscexport.h"
|
||||
#include "propertyindexvariantmap.h"
|
||||
#include "iterator.h"
|
||||
#include "predicates.h"
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
#include <iterator>
|
||||
@@ -71,12 +71,6 @@ namespace BlackMisc
|
||||
inline auto findBy(K0 k0, V0 v0, KeysValues... keysValues) const
|
||||
-> CRange<Iterators::ConditionalIterator<CIt, decltype(BlackMisc::Predicates::MemberEqual(k0, v0, keysValues...))>>;
|
||||
|
||||
/*!
|
||||
* \brief Return a copy containing only those elements matching a given value map.
|
||||
*/
|
||||
inline auto findBy(CPropertyIndexVariantMap valueMap) const
|
||||
-> CRange<Iterators::ConditionalIterator<CIt, decltype(BlackMisc::Predicates::Equals(std::move(valueMap)))>>;
|
||||
|
||||
/*!
|
||||
* \brief Return true if there is an element for which a given predicate returns true.
|
||||
*/
|
||||
@@ -268,13 +262,6 @@ namespace BlackMisc
|
||||
return findBy(BlackMisc::Predicates::MemberEqual(k0, v0, keysValues...));
|
||||
}
|
||||
|
||||
template <class Derived, class CIt>
|
||||
auto CRangeBase<Derived, CIt>::findBy(CPropertyIndexVariantMap valueMap) const
|
||||
-> CRange<Iterators::ConditionalIterator<CIt, decltype(BlackMisc::Predicates::Equals(std::move(valueMap)))>>
|
||||
{
|
||||
return findBy(BlackMisc::Predicates::Equals(std::move(valueMap)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -352,8 +352,8 @@ namespace BlackMisc
|
||||
* \brief Modify by applying a value map to each element for which a given predicate returns true.
|
||||
* \return The number of elements modified.
|
||||
*/
|
||||
template <class Predicate>
|
||||
int applyIf(Predicate p, const CPropertyIndexVariantMap &newValues, bool skipEqualValues = false)
|
||||
template <class Predicate, class VariantMap>
|
||||
int applyIf(Predicate p, const VariantMap &newValues, bool skipEqualValues = false)
|
||||
{
|
||||
int count = 0;
|
||||
for (auto &value : *this)
|
||||
@@ -371,21 +371,12 @@ namespace BlackMisc
|
||||
* \param skipEqualValues Equal values will not be updated
|
||||
* \return The number of elements modified.
|
||||
*/
|
||||
template <class K1, class V1>
|
||||
int applyIf(K1 key1, V1 value1, const CPropertyIndexVariantMap &newValues, bool skipEqualValues = false)
|
||||
template <class K1, class V1, class VariantMap>
|
||||
int applyIf(K1 key1, V1 value1, const VariantMap &newValues, bool skipEqualValues = false)
|
||||
{
|
||||
return applyIf(BlackMisc::Predicates::MemberEqual(key1, value1), newValues, skipEqualValues);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Modify by applying a value map to each element matching a given value map.
|
||||
* \return The number of elements modified.
|
||||
*/
|
||||
int applyIf(const CPropertyIndexVariantMap &pattern, const CPropertyIndexVariantMap &newValues, bool skipEqualValues = false)
|
||||
{
|
||||
return applyIf([ & ](const T & value) { return value == pattern; }, newValues, skipEqualValues);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Remove all elements equal to the given object, if it is contained.
|
||||
* \pre The sequence must be initialized.
|
||||
|
||||
Reference in New Issue
Block a user