Index: compiled/storage/FilterStorage.cpp |
=================================================================== |
--- a/compiled/storage/FilterStorage.cpp |
+++ b/compiled/storage/FilterStorage.cpp |
@@ -33,25 +33,25 @@ Subscription* FilterStorage::Subscriptio |
{ |
if (index >= mSubscriptions.size()) |
return nullptr; |
SubscriptionPtr result(mSubscriptions[index]); |
return result.release(); |
} |
-int FilterStorage::IndexOfSubscription(const Subscription* subscription) const |
+int FilterStorage::IndexOfSubscription(const Subscription& subscription) const |
{ |
for (Subscriptions::size_type i = 0; i < mSubscriptions.size(); i++) |
- if (mSubscriptions[i] == subscription) |
+ if (mSubscriptions[i] == &subscription) |
return i; |
return -1; |
} |
-Subscription* FilterStorage::GetSubscriptionForFilter(const Filter* filter) const |
+Subscription* FilterStorage::GetSubscriptionForFilter(const Filter& filter) const |
{ |
SubscriptionPtr fallback; |
for (Subscriptions::size_type i = 0; i < mSubscriptions.size(); i++) |
{ |
SubscriptionPtr subscription(mSubscriptions[i]); |
UserDefinedSubscription* userDefinedSubscription = |
subscription->As<UserDefinedSubscription>(); |
@@ -66,82 +66,74 @@ Subscription* FilterStorage::GetSubscrip |
{ |
fallback = subscription; |
} |
} |
return fallback.release(); |
} |
-bool FilterStorage::AddSubscription(Subscription* subscription) |
+bool FilterStorage::AddSubscription(Subscription& subscription) |
{ |
- assert(subscription, u"Attempt to add a null subscription"_str); |
- |
- if (!subscription || subscription->GetListed()) |
+ if (subscription.GetListed()) |
return false; |
- mSubscriptions.emplace_back(subscription); |
- subscription->SetListed(true); |
+ mSubscriptions.emplace_back(&subscription); |
+ subscription.SetListed(true); |
FilterNotifier::SubscriptionChange( |
FilterNotifier::Topic::SUBSCRIPTION_ADDED, |
subscription |
); |
return true; |
} |
-bool FilterStorage::RemoveSubscription(Subscription* subscription) |
+bool FilterStorage::RemoveSubscription(Subscription& subscription) |
{ |
- assert(subscription, u"Attempt to remove a null subscription"_str); |
- |
- if (!subscription || !subscription->GetListed()) |
+ if (!subscription.GetListed()) |
return false; |
for (auto it = mSubscriptions.begin(); it != mSubscriptions.end(); ++it) |
{ |
- if (*it == subscription) |
+ if (*it == &subscription) |
{ |
mSubscriptions.erase(it); |
break; |
} |
} |
- subscription->SetListed(false); |
+ subscription.SetListed(false); |
FilterNotifier::SubscriptionChange( |
FilterNotifier::Topic::SUBSCRIPTION_REMOVED, |
subscription |
); |
return true; |
} |
-bool FilterStorage::MoveSubscription(Subscription* subscription, |
+bool FilterStorage::MoveSubscription(Subscription& subscription, |
const Subscription* insertBefore) |
{ |
- assert(subscription, u"Attempt to move a null subscription"_str); |
- |
int oldPos = IndexOfSubscription(subscription); |
+ assert(oldPos >= 0, u"Attempt to move a subscription that is not in the list"_str); |
if (oldPos == -1) |
- { |
- assert(subscription, u"Attempt to move a subscription that is not in the list"_str); |
return false; |
- } |
int newPos = -1; |
if (insertBefore) |
- newPos = IndexOfSubscription(insertBefore); |
+ newPos = IndexOfSubscription(*insertBefore); |
if (newPos == -1) |
newPos = mSubscriptions.size(); |
if (newPos > oldPos) |
newPos--; |
if (newPos == oldPos) |
return false; |
mSubscriptions.erase(mSubscriptions.begin() + oldPos); |
- mSubscriptions.emplace(mSubscriptions.begin() + newPos, subscription); |
+ mSubscriptions.emplace(mSubscriptions.begin() + newPos, &subscription); |
FilterNotifier::SubscriptionChange( |
FilterNotifier::Topic::SUBSCRIPTION_MOVED, |
subscription |
); |
return true; |
} |