Archived

This forum has been archived. Please start a new discussion on GitHub.

Multiple observers through IceStorm

Hi,

I want to wrap icestorm in an observer pattern as described in by "45.6 Publishing to a Specific Subscriber". I would like to have clients be able to observe multiple updates to topics. From what the manual describes, i'd have to define an interface for each observer type (by topic).

I've tried searching the manual for overload rules, but i couldnt find anything. Does ICE support overloaded methods? Because if i had two similar observer interfaces for different types, would it be okay?
interface testObserver {
    void update(SomeType type);
};

interface otherTestObserver {
    void update(SomeOtherType type);
};

Or Is there a smarter way of going about it?

Also, i'm not sure i fully understand how the manual wants the implementation to be. How is data published through icestorm? If we take the example from the manual.vIs the idea that you create an implementation of List (see below) that creates a "List" topic in the icestorm topicmanager, and then publishes messages only to itself, forwarding these updates to any observer that has attached itself?
interface List {
    void add(Item i);
    void remove(Item i);

    void addObserver(ListObserver* lo);
    void removeObserver(ListObserver* lo);
};


Thanks for your insight!

Comments

  • (For some reason i couldn't edit the post, so i'll leave a reply instead, sorry!)

    As a side note, there's something else i'm not too sure about. The manual says that when an observer is added on the servant implementation we make a call to topic.subscribeAndGetPublisher(<observer proxy>).

    Does this mean that this call has no other effect than to allow the servant to call the "init()" method on this observer, and that all communication via publishing/notification is via The publisher / IceStorm, so that icestorm notifies the publisher that it's published something, and the publisher in turn decides whether or not to update its observers?

    Cheers!
  • matthew
    matthew NL, Canada
    With respect to overloading, you cannot have duplicate methods in an interface hierarchy. That is illegal.

    With respect to your other question I would suggest looking at the counter demo, which shows one way of using the subscribeAndGetPublisher method. If you still have questions after that, please let us know.
  • Hi matthew, thanks for your reply.

    There's no specific "counter" example in the demo solution that i can find. Are you thinking about the clock example?

    I guess i'm having trouble wrapping my mind around the implementation to a multi observer / icestorm solution, suggested by the manual. I realize that the proxy returned by subscribeAndGetPublisher can be utilized in this respect, but i'm having trouble understanding how subscribers receive updates from publisher objects through IceStorm, when it's wrapped in the classic observer pattern.

    In my eyes, i'm losing some of the QoS elements that icestorm provides, by allowing a publisher object to notifiy itself through icestorm, then notifying allits observers. But i think i may be approaching the problem in the wrong way.

    Thank you.
  • matthew
    matthew NL, Canada
    Ice 3.3.1 contains a demo cpp/demo/IceStorm/counter. The technique is to hide IceStorm from the subscribers. The stateful subscribers subscribe through a service, that initializes the current state in the subscriber by using the per-subscriber publisher object. It also manages pushing out state update events.
  • Hi matthew,

    I was generally looking at the c# samples, and there's no counter there, but it does indeed exist in the cpp folder. I'll have a look, thank you.