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

Side by Side Diff: compiled/subscription/Subscription.h

Issue 29613616: Issue 6064 - Put C++ code into a configurable namespace (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: rebase Created Feb. 6, 2018, 9:54 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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-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 <vector> 20 #include <vector>
21 21
22 #include "../base.h"
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 #include "../bindings/runtime.h" 28 #include "../bindings/runtime.h"
28 29
29 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett er, setter) \ 30 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett er, setter) \
30 private:\ 31 private:\
31 field_type name;\ 32 field_type name;\
32 public:\ 33 public:\
33 param_type BINDINGS_EXPORTED getter() const\ 34 param_type BINDINGS_EXPORTED getter() const\
34 {\ 35 {\
35 return name;\ 36 return name;\
36 }\ 37 }\
37 void BINDINGS_EXPORTED setter(param_type value)\ 38 void BINDINGS_EXPORTED setter(param_type value)\
38 {\ 39 {\
39 if (name != value)\ 40 if (name != value)\
40 {\ 41 {\
41 name = value;\ 42 name = value;\
42 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ 43 if (ABP_NS::FilterNotifier::Topic::topic != ABP_NS::FilterNotifier::To pic::NONE)\
43 {\ 44 {\
44 FilterNotifier::SubscriptionChange(FilterNotifier::Topic::topic,\ 45 ABP_NS::FilterNotifier::SubscriptionChange(ABP_NS::FilterNotifier::T opic::topic,\
45 *this);\ 46 *this);\
46 }\ 47 }\
47 }\ 48 }\
48 } 49 }
49 50
50 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \ 51 #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");\ 52 static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro can only be used with arithmetic types");\
52 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter) 53 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter)
53 54
54 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ 55 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \
55 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter) 56 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter)
56 57
58 ABP_NS_BEGIN
59
57 class Subscription : public ref_counted 60 class Subscription : public ref_counted
58 { 61 {
59 public: 62 public:
60 typedef std::vector<FilterPtr> Filters; 63 typedef std::vector<FilterPtr> Filters;
61 64
62 protected: 65 protected:
63 OwnedString mID; 66 OwnedString mID;
64 Filters mFilters; 67 Filters mFilters;
65 68
66 public: 69 public:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const T* As() const 114 const T* As() const
112 { 115 {
113 if (mType != T::classType) 116 if (mType != T::classType)
114 return nullptr; 117 return nullptr;
115 118
116 return static_cast<const T*>(this); 119 return static_cast<const T*>(this);
117 } 120 }
118 }; 121 };
119 122
120 typedef intrusive_ptr<Subscription> SubscriptionPtr; 123 typedef intrusive_ptr<Subscription> SubscriptionPtr;
124
125 ABP_NS_END
OLDNEW

Powered by Google App Engine
This is Rietveld