LEFT | RIGHT |
(no file at all) | |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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> | |
21 #include <vector> | 20 #include <vector> |
22 | 21 |
23 #include "../filter/Filter.h" | 22 #include "../filter/Filter.h" |
24 #include "../String.h" | 23 #include "../String.h" |
25 #include "../FilterNotifier.h" | 24 #include "../FilterNotifier.h" |
26 #include "../intrusive_ptr.h" | 25 #include "../intrusive_ptr.h" |
27 #include "../debug.h" | 26 #include "../debug.h" |
28 #include "../bindings/runtime.h" | 27 #include "../bindings/runtime.h" |
29 | 28 |
30 #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) \ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 92 } |
94 | 93 |
95 Filter* BINDINGS_EXPORTED FilterAt(Filters::size_type index); | 94 Filter* BINDINGS_EXPORTED FilterAt(Filters::size_type index); |
96 int BINDINGS_EXPORTED IndexOfFilter(const Filter& filter); | 95 int BINDINGS_EXPORTED IndexOfFilter(const Filter& filter); |
97 OwnedString BINDINGS_EXPORTED Serialize() const; | 96 OwnedString BINDINGS_EXPORTED Serialize() const; |
98 OwnedString BINDINGS_EXPORTED SerializeFilters() const; | 97 OwnedString BINDINGS_EXPORTED SerializeFilters() const; |
99 | 98 |
100 static Subscription* BINDINGS_EXPORTED FromID(const String& id); | 99 static Subscription* BINDINGS_EXPORTED FromID(const String& id); |
101 | 100 |
102 template<typename T> | 101 template<typename T> |
103 T* As(); | 102 T* As() |
| 103 { |
| 104 if (mType != T::classType) |
| 105 return nullptr; |
| 106 |
| 107 return static_cast<T*>(this); |
| 108 } |
| 109 |
| 110 template<typename T> |
| 111 const T* As() const |
| 112 { |
| 113 if (mType != T::classType) |
| 114 return nullptr; |
| 115 |
| 116 return static_cast<const T*>(this); |
| 117 } |
104 }; | 118 }; |
105 | 119 |
106 typedef intrusive_ptr<Subscription> SubscriptionPtr; | 120 typedef intrusive_ptr<Subscription> SubscriptionPtr; |
LEFT | RIGHT |