| Index: compiled/subscription/Subscription.h |
| diff --git a/compiled/subscription/Subscription.h b/compiled/subscription/Subscription.h |
| index acbe864a0fd4bac98f22a9a7dfd4c42fd5af1e18..fe4b4051c635a5e67996320cfc1c7db3e3a0d8dd 100644 |
| --- a/compiled/subscription/Subscription.h |
| +++ b/compiled/subscription/Subscription.h |
| @@ -55,6 +55,9 @@ |
| #define SUBSCRIPTION_STRING_PROPERTY(name, topic, getter, setter) \ |
| SUBSCRIPTION_PROPERTY_INTERNAL(OwnedString, const String&, name, topic, getter, setter) |
| +class Subscription; |
| +typedef intrusive_ptr<Subscription> SubscriptionPtr; |
| + |
| class Subscription : public ref_counted |
| { |
| public: |
| @@ -72,7 +75,15 @@ public: |
| USERDEFINED = 2 |
| }; |
| - explicit Subscription(Type type, const String& id); |
| + typedef std::pair<OwnedString, OwnedString> KeyValue; |
| + typedef std::vector<KeyValue> KeyValues; |
| + |
| + static Subscription* BINDINGS_EXPORTED FromID(const String& id) |
| + { |
| + return FromProperties(id, KeyValues()).release(); |
| + } |
| + static SubscriptionPtr FromProperties(const KeyValues& properties); |
| + |
| ~Subscription(); |
| Type mType; |
| @@ -94,13 +105,32 @@ public: |
| Filter* BINDINGS_EXPORTED FilterAt(Filters::size_type index); |
| int BINDINGS_EXPORTED IndexOfFilter(const Filter& filter); |
| - OwnedString BINDINGS_EXPORTED Serialize() const; |
| - OwnedString BINDINGS_EXPORTED SerializeFilters() const; |
| - |
| - static Subscription* BINDINGS_EXPORTED FromID(const String& id); |
| + void AddFilter(Filter& filter); |
| + const Filters& GetFilters() const |
| + { |
| + return mFilters; |
| + } |
| + // behaves similar to virtual function |
| + OwnedString SerializeProperties() const; |
| template<typename T> |
| T* As(); |
| -}; |
| -typedef intrusive_ptr<Subscription> SubscriptionPtr; |
| + template<typename T> |
| + const T* As() const |
| + { |
| + return const_cast<Subscription*>(this)->As<T>(); |
| + } |
| +protected: |
| + OwnedString DoSerializeProperties() const; |
|
Wladimir Palant
2017/12/21 10:30:38
Why is this method called DoSerializeProperties()
|
| + explicit Subscription(Type type, const String& id, const KeyValues& properties); |
| + static const String* findPropertyValue(const Subscription::KeyValues& properties, const String& propertyName); |
| + template<typename Member> |
| + static void parseProperty(const KeyValues& properties, Member& member, const String& key) |
| + { |
| + if (auto strPropValue = findPropertyValue(properties, key)) |
| + member = AdaptValue<Member>(*strPropValue); |
| + } |
| +private: |
| + static SubscriptionPtr FromProperties(const String& id, const KeyValues& properties); |
| +}; |