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