Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include/AdblockPlus/FilterEngine.h

Issue 29419623: Issue 5165 - Remove SubscriptionPtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added move assignment operator Created April 24, 2017, 7:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | shell/src/SubscriptionsCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 /** 84 /**
85 * Wrapper for a subscription object. 85 * Wrapper for a subscription object.
86 * There are no accessors for most 86 * There are no accessors for most
87 * [subscription properties](https://adblockplus.org/jsdoc/adblockpluscore/Sub scription.html), 87 * [subscription properties](https://adblockplus.org/jsdoc/adblockpluscore/Sub scription.html),
88 * use `GetProperty()` to retrieve them by name. 88 * use `GetProperty()` to retrieve them by name.
89 */ 89 */
90 class Subscription : public JsValue, 90 class Subscription : public JsValue,
91 public std::enable_shared_from_this<Subscription> 91 public std::enable_shared_from_this<Subscription>
92 { 92 {
93 friend class FilterEngine;
93 public: 94 public:
94 /** 95 /**
96 * Copy constructor
97 */
98 Subscription(const Subscription& src);
99
100 /**
101 * Move constructor
102 */
103 Subscription(Subscription&& src);
104
105 /**
106 * Assignment operator
107 */
108 Subscription& operator=(const Subscription& src);
109
110 /**
111 * Move assignment operator
112 */
113 Subscription& operator=(Subscription&& src);
114
115 /**
95 * Checks if this subscription has been added to the list of subscriptions. 116 * Checks if this subscription has been added to the list of subscriptions.
96 * @return `true` if this subscription has been added. 117 * @return `true` if this subscription has been added.
97 */ 118 */
98 bool IsListed() const; 119 bool IsListed() const;
99 120
100 /** 121 /**
101 * Adds this subscription to the list of subscriptions. 122 * Adds this subscription to the list of subscriptions.
102 */ 123 */
103 void AddToList(); 124 void AddToList();
104 125
(...skipping 15 matching lines...) Expand all
120 bool IsUpdating() const; 141 bool IsUpdating() const;
121 142
122 /** 143 /**
123 * Indicates whether the subscription is the Acceptable Ads subscription. 144 * Indicates whether the subscription is the Acceptable Ads subscription.
124 * @return `true` if this subscription is the Acceptable Ads subscription. 145 * @return `true` if this subscription is the Acceptable Ads subscription.
125 */ 146 */
126 bool IsAA() const; 147 bool IsAA() const;
127 148
128 bool operator==(const Subscription& subscription) const; 149 bool operator==(const Subscription& subscription) const;
129 150
151 protected:
130 /** 152 /**
131 * Creates a wrapper for an existing JavaScript subscription object. 153 * Creates a wrapper for an existing JavaScript subscription object.
132 * Normally you shouldn't call this directly, but use 154 * Normally you shouldn't call this directly, but use
133 * FilterEngine::GetSubscription() instead. 155 * FilterEngine::GetSubscription() instead.
134 * @param value JavaScript subscription object. 156 * @param value JavaScript subscription object.
135 */ 157 */
136 Subscription(JsValue&& value); 158 Subscription(JsValue&& value);
137 }; 159 };
138 160
139 /** 161 /**
140 * Shared smart pointer to a `Filter` instance. 162 * Shared smart pointer to a `Filter` instance.
141 */ 163 */
142 typedef std::unique_ptr<Filter> FilterPtr; 164 typedef std::unique_ptr<Filter> FilterPtr;
143 165
144 /** 166 /**
145 * Shared smart pointer to a `Subscription` instance.
146 */
147 typedef std::shared_ptr<Subscription> SubscriptionPtr;
148
149 /**
150 * Main component of libadblockplus. 167 * Main component of libadblockplus.
151 * It handles: 168 * It handles:
152 * - Filter management and matching. 169 * - Filter management and matching.
153 * - Subscription management and synchronization. 170 * - Subscription management and synchronization.
154 * - Update checks for the application. 171 * - Update checks for the application.
155 */ 172 */
156 class FilterEngine 173 class FilterEngine
157 { 174 {
158 public: 175 public:
159 // Make sure to keep ContentType in sync with FilterEngine::contentTypes 176 // Make sure to keep ContentType in sync with FilterEngine::contentTypes
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 * see https://adblockplus.org/en/filters. 302 * see https://adblockplus.org/en/filters.
286 * @return New `Filter` instance. 303 * @return New `Filter` instance.
287 */ 304 */
288 Filter GetFilter(const std::string& text) const; 305 Filter GetFilter(const std::string& text) const;
289 306
290 /** 307 /**
291 * Retrieves a subscription object for the supplied URL. 308 * Retrieves a subscription object for the supplied URL.
292 * @param url Subscription URL. 309 * @param url Subscription URL.
293 * @return New `Subscription` instance. 310 * @return New `Subscription` instance.
294 */ 311 */
295 SubscriptionPtr GetSubscription(const std::string& url) const; 312 Subscription GetSubscription(const std::string& url) const;
296 313
297 /** 314 /**
298 * Retrieves the list of custom filters. 315 * Retrieves the list of custom filters.
299 * @return List of custom filters. 316 * @return List of custom filters.
300 */ 317 */
301 std::vector<Filter> GetListedFilters() const; 318 std::vector<Filter> GetListedFilters() const;
302 319
303 /** 320 /**
304 * Retrieves all subscriptions. 321 * Retrieves all subscriptions.
305 * @return List of subscriptions. 322 * @return List of subscriptions.
306 */ 323 */
307 std::vector<SubscriptionPtr> GetListedSubscriptions() const; 324 std::vector<Subscription> GetListedSubscriptions() const;
308 325
309 /** 326 /**
310 * Retrieves all recommended subscriptions. 327 * Retrieves all recommended subscriptions.
311 * @return List of recommended subscriptions. 328 * @return List of recommended subscriptions.
312 */ 329 */
313 std::vector<SubscriptionPtr> FetchAvailableSubscriptions() const; 330 std::vector<Subscription> FetchAvailableSubscriptions() const;
314 331
315 /** 332 /**
316 * Ensures that the Acceptable Ads subscription is enabled or disabled. 333 * Ensures that the Acceptable Ads subscription is enabled or disabled.
317 * @param enabled 334 * @param enabled
318 * - if the value is `true` 335 * - if the value is `true`
319 * - ensure that the filter set includes an enabled AA subscription, 336 * - ensure that the filter set includes an enabled AA subscription,
320 * adding it if needed and enabling it if disabled. 337 * adding it if needed and enabling it if disabled.
321 * - if the value is `false` 338 * - if the value is `false`
322 * - if an AA subscription is present, disable it. 339 * - if an AA subscription is present, disable it.
323 * - if absent, do nothing. 340 * - if absent, do nothing.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 const JsValueList& param) const; 559 const JsValueList& param) const;
543 FilterPtr GetWhitelistingFilter(const std::string& url, 560 FilterPtr GetWhitelistingFilter(const std::string& url,
544 ContentTypeMask contentTypeMask, const std::string& documentUrl) const; 561 ContentTypeMask contentTypeMask, const std::string& documentUrl) const;
545 FilterPtr GetWhitelistingFilter(const std::string& url, 562 FilterPtr GetWhitelistingFilter(const std::string& url,
546 ContentTypeMask contentTypeMask, 563 ContentTypeMask contentTypeMask,
547 const std::vector<std::string>& documentUrls) const; 564 const std::vector<std::string>& documentUrls) const;
548 }; 565 };
549 } 566 }
550 567
551 #endif 568 #endif
OLDNEW
« no previous file with comments | « no previous file | shell/src/SubscriptionsCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld