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

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

Issue 29384812: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 1 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Added missing license headers Created March 27, 2017, 8:47 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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 #pragma once
19
20 #include <vector>
21
22 #include "../filter/Filter.h"
23 #include "../String.h"
24 #include "../intrusive_ptr.h"
25 #include "../debug.h"
26
27 #define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \
28 private:\
29 type name;\
30 public:\
31 type EMSCRIPTEN_KEEPALIVE getter() const\
32 {\
33 return name;\
34 }\
35 void EMSCRIPTEN_KEEPALIVE setter(type value)\
36 {\
37 if (name != value)\
38 {\
39 type oldvalue = name;\
40 name = value;\
41 DependentString action(u"subscription."_str #name);\
42 EM_ASM_ARGS({\
43 var subscription = new (exports[Subscription_mapping[$2]])($1);\
44 FilterNotifier.triggerListeners(readString($0), subscription, $3, $4 );\
45 }, &action, this, mType, value, oldvalue);\
46 }\
47 }
48
49 #define SUBSCRIPTION_STRING_PROPERTY(name, getter, setter) \
50 private:\
51 OwnedString name;\
52 public:\
53 const String& EMSCRIPTEN_KEEPALIVE getter() const\
54 {\
55 return name;\
56 }\
57 void EMSCRIPTEN_KEEPALIVE setter(const String& value)\
58 {\
59 if (!name.equals(value))\
60 {\
61 OwnedString oldvalue(name);\
62 name = value;\
63 DependentString action(u"subscription."_str #name);\
64 EM_ASM_ARGS({\
65 var subscription = new (exports[Subscription_mapping[$2]])($1);\
66 FilterNotifier.triggerListeners(readString($0), subscription, readSt ring($3), readString($4));\
67 }, &action, this, mType, &value, &oldvalue);\
68 }\
69 }
70
71 class Subscription : public ref_counted
72 {
73 protected:
74 OwnedString mID;
75 std::vector<Filter> mFilters;
76
77 public:
78 enum Type
79 {
80 UNKNOWN = 0,
81 DOWNLOADABLE = 1,
82 USERDEFINED = 2
83 };
84
85 explicit Subscription(Type type, const String& id);
86 ~Subscription();
87
88 Type mType;
89
90 EMSCRIPTEN_KEEPALIVE const String& GetID() const
91 {
92 return mID;
93 }
94
95 SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle);
96 SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled);
97
98 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const;
99 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const;
100
101 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id);
102 };
103
104 typedef intrusive_ptr<Subscription> SubscriptionPtr;
OLDNEW
« no previous file with comments | « compiled/subscription/DownloadableSubscription.cpp ('k') | compiled/subscription/Subscription.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld