| LEFT | RIGHT | 
|---|
| 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 | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 14  * You should have received a copy of the GNU General Public License | 
| 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 #pragma once | 18 #pragma once | 
| 19 | 19 | 
|  | 20 #include <type_traits> | 
| 20 #include <vector> | 21 #include <vector> | 
| 21 | 22 | 
| 22 #include "../filter/Filter.h" | 23 #include "../filter/Filter.h" | 
| 23 #include "../String.h" | 24 #include "../String.h" | 
| 24 #include "../FilterNotifier.h" | 25 #include "../FilterNotifier.h" | 
| 25 #include "../intrusive_ptr.h" | 26 #include "../intrusive_ptr.h" | 
| 26 #include "../debug.h" | 27 #include "../debug.h" | 
| 27 | 28 | 
| 28 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett
    er, setter) \ | 29 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett
    er, setter) \ | 
| 29     private:\ | 30     private:\ | 
| 30       field_type name;\ | 31       field_type name;\ | 
| 31     public:\ | 32     public:\ | 
| 32       param_type EMSCRIPTEN_KEEPALIVE getter() const\ | 33       param_type EMSCRIPTEN_KEEPALIVE getter() const\ | 
| 33       {\ | 34       {\ | 
| 34         return name;\ | 35         return name;\ | 
| 35       }\ | 36       }\ | 
| 36       void EMSCRIPTEN_KEEPALIVE setter(param_type value)\ | 37       void EMSCRIPTEN_KEEPALIVE setter(param_type value)\ | 
| 37       {\ | 38       {\ | 
| 38         if (name != value)\ | 39         if (name != value)\ | 
| 39         {\ | 40         {\ | 
| 40           field_type oldvalue = name;\ |  | 
| 41           name = value;\ | 41           name = value;\ | 
| 42           if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ | 42           if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ | 
| 43           {\ | 43           {\ | 
| 44             FilterNotifier::PropertyChange(FilterNotifier::Topic::topic,\ | 44             FilterNotifier::SubscriptionChange(FilterNotifier::Topic::topic,\ | 
| 45                 this, value, oldvalue);\ | 45                 this);\ | 
| 46           }\ | 46           }\ | 
| 47         }\ | 47         }\ | 
| 48       } | 48       } | 
| 49 | 49 | 
| 50 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \ | 50 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \ | 
|  | 51     static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro 
    can only be used with arithmetic types");\ | 
| 51     SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter) | 52     SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter) | 
| 52 | 53 | 
| 53 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ | 54 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ | 
| 54     SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett
    er, setter) | 55     SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett
    er, setter) | 
| 55 | 56 | 
| 56 class Subscription : public ref_counted | 57 class Subscription : public ref_counted | 
| 57 { | 58 { | 
| 58 protected: | 59 protected: | 
| 59   OwnedString mID; | 60   OwnedString mID; | 
| 60   std::vector<FilterPtr> mFilters; | 61   std::vector<FilterPtr> mFilters; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 88 | 89 | 
| 89   EMSCRIPTEN_KEEPALIVE Filter* FilterAt(unsigned index); | 90   EMSCRIPTEN_KEEPALIVE Filter* FilterAt(unsigned index); | 
| 90   EMSCRIPTEN_KEEPALIVE int IndexOfFilter(Filter* filter); | 91   EMSCRIPTEN_KEEPALIVE int IndexOfFilter(Filter* filter); | 
| 91   EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; | 92   EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; | 
| 92   EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const; | 93   EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const; | 
| 93 | 94 | 
| 94   static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id); | 95   static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id); | 
| 95 }; | 96 }; | 
| 96 | 97 | 
| 97 typedef intrusive_ptr<Subscription> SubscriptionPtr; | 98 typedef intrusive_ptr<Subscription> SubscriptionPtr; | 
| LEFT | RIGHT | 
|---|