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: Fix debug.h to be aligned with assert2 (define vs function) and get rid of a warning in generator.cpp Created Nov. 21, 2017, 2:53 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
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 <type_traits> 20 #include <type_traits>
21 #include <vector> 21 #include <vector>
22 22
23 #include "../base.h"
23 #include "../filter/Filter.h" 24 #include "../filter/Filter.h"
24 #include "../String.h" 25 #include "../String.h"
25 #include "../FilterNotifier.h" 26 #include "../FilterNotifier.h"
26 #include "../intrusive_ptr.h" 27 #include "../intrusive_ptr.h"
27 #include "../debug.h" 28 #include "../debug.h"
28 #include "../bindings/runtime.h" 29 #include "../bindings/runtime.h"
29 30
30 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett er, setter) \ 31 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett er, setter) \
31 private:\ 32 private:\
32 field_type name;\ 33 field_type name;\
33 public:\ 34 public:\
34 param_type BINDINGS_EXPORTED getter() const\ 35 param_type BINDINGS_EXPORTED getter() const\
35 {\ 36 {\
36 return name;\ 37 return name;\
37 }\ 38 }\
38 void BINDINGS_EXPORTED setter(param_type value)\ 39 void BINDINGS_EXPORTED setter(param_type value)\
39 {\ 40 {\
40 if (name != value)\ 41 if (name != value)\
41 {\ 42 {\
42 name = value;\ 43 name = value;\
43 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ 44 if (ABP_NS::FilterNotifier::Topic::topic != ABP_NS::FilterNotifier::To pic::NONE)\
44 {\ 45 {\
45 FilterNotifier::SubscriptionChange(FilterNotifier::Topic::topic,\ 46 ABP_NS::FilterNotifier::SubscriptionChange(ABP_NS::FilterNotifier::T opic::topic,\
46 *this);\ 47 *this);\
47 }\ 48 }\
48 }\ 49 }\
49 } 50 }
50 51
51 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \ 52 #define SUBSCRIPTION_PROPERTY(type, name, topic, getter, setter) \
52 static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro can only be used with arithmetic types");\ 53 static_assert(std::is_arithmetic<type>::value, "SUBSCRIPTION_PROPERTY macro can only be used with arithmetic types");\
53 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter) 54 SUBSCRIPTION_PROPERTY_INTERNAL(type, type, name, topic, getter, setter)
54 55
55 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ 56 #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \
56 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter) 57 SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, gett er, setter)
57 58
59 ABP_NS_BEGIN
60
58 class Subscription : public ref_counted 61 class Subscription : public ref_counted
59 { 62 {
60 public: 63 public:
61 typedef std::vector<FilterPtr> Filters; 64 typedef std::vector<FilterPtr> Filters;
62 65
63 protected: 66 protected:
64 OwnedString mID; 67 OwnedString mID;
65 Filters mFilters; 68 Filters mFilters;
66 69
67 public: 70 public:
(...skipping 29 matching lines...) Expand all
97 OwnedString BINDINGS_EXPORTED Serialize() const; 100 OwnedString BINDINGS_EXPORTED Serialize() const;
98 OwnedString BINDINGS_EXPORTED SerializeFilters() const; 101 OwnedString BINDINGS_EXPORTED SerializeFilters() const;
99 102
100 static Subscription* BINDINGS_EXPORTED FromID(const String& id); 103 static Subscription* BINDINGS_EXPORTED FromID(const String& id);
101 104
102 template<typename T> 105 template<typename T>
103 T* As(); 106 T* As();
104 }; 107 };
105 108
106 typedef intrusive_ptr<Subscription> SubscriptionPtr; 109 typedef intrusive_ptr<Subscription> SubscriptionPtr;
110
111 ABP_NS_END
OLDNEW

Powered by Google App Engine
This is Rietveld