OLD | NEW |
(Empty) | |
| 1 #pragma once |
| 2 |
| 3 #include <vector> |
| 4 |
| 5 #include "../filter/Filter.h" |
| 6 #include "../String.h" |
| 7 #include "../intrusive_ptr.h" |
| 8 #include "../debug.h" |
| 9 |
| 10 #define SUBSCRIPTION_PROPERTY(type, name, getter, setter) \ |
| 11 private:\ |
| 12 type name;\ |
| 13 public:\ |
| 14 type EMSCRIPTEN_KEEPALIVE getter() const\ |
| 15 {\ |
| 16 return name;\ |
| 17 }\ |
| 18 void EMSCRIPTEN_KEEPALIVE setter(type value)\ |
| 19 {\ |
| 20 if (name != value)\ |
| 21 {\ |
| 22 type oldvalue = name;\ |
| 23 name = value;\ |
| 24 DependentString action(u"subscription."_str #name);\ |
| 25 EM_ASM_ARGS({\ |
| 26 var subscription = new (exports[Subscription_mapping[$2]])($1);\ |
| 27 FilterNotifier.triggerListeners(readString($0), subscription, $3, $4
);\ |
| 28 }, &action, this, mType, value, oldvalue);\ |
| 29 }\ |
| 30 } |
| 31 |
| 32 #define SUBSCRIPTION_STRING_PROPERTY(name, getter, setter) \ |
| 33 private:\ |
| 34 OwnedString name;\ |
| 35 public:\ |
| 36 const String& EMSCRIPTEN_KEEPALIVE getter() const\ |
| 37 {\ |
| 38 return name;\ |
| 39 }\ |
| 40 void EMSCRIPTEN_KEEPALIVE setter(const String& value)\ |
| 41 {\ |
| 42 if (!name.equals(value))\ |
| 43 {\ |
| 44 OwnedString oldvalue(name);\ |
| 45 name = value;\ |
| 46 DependentString action(u"subscription."_str #name);\ |
| 47 EM_ASM_ARGS({\ |
| 48 var subscription = new (exports[Subscription_mapping[$2]])($1);\ |
| 49 FilterNotifier.triggerListeners(readString($0), subscription, readSt
ring($3), readString($4));\ |
| 50 }, &action, this, mType, &value, &oldvalue);\ |
| 51 }\ |
| 52 } |
| 53 |
| 54 class Subscription : public ref_counted |
| 55 { |
| 56 protected: |
| 57 OwnedString mID; |
| 58 std::vector<Filter> mFilters; |
| 59 |
| 60 public: |
| 61 enum Type |
| 62 { |
| 63 UNKNOWN = 0, |
| 64 DOWNLOADABLE = 1, |
| 65 USERDEFINED = 2 |
| 66 }; |
| 67 |
| 68 explicit Subscription(Type type, const String& id); |
| 69 ~Subscription(); |
| 70 |
| 71 Type mType; |
| 72 |
| 73 EMSCRIPTEN_KEEPALIVE const String& GetID() const |
| 74 { |
| 75 return mID; |
| 76 } |
| 77 |
| 78 SUBSCRIPTION_STRING_PROPERTY(mTitle, GetTitle, SetTitle); |
| 79 SUBSCRIPTION_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); |
| 80 |
| 81 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; |
| 82 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const; |
| 83 |
| 84 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id); |
| 85 }; |
| 86 |
| 87 typedef intrusive_ptr<Subscription> SubscriptionPtr; |
OLD | NEW |