Boost logo

Boost Users :

Subject: Re: [Boost-users] Trying to serialize observer pattern - both subjectand observers with pionters
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-09-07 20:14:37


Mikael Carlsson wrote:
> Dear list,
>
> I am using the observer pattern in a design and would like to make
> both subject and observers serializable. The subject hold a base
> class pointer to the observes and the observers holds a base class
> pointer to the subject.
>
> If I have understood the library correct I must register the class
> for base class pointers in order to serialize the class pointer.

Nope - you just have to indicate the base class for each class
that has one.
> This
> means that I must include the concrete subject in the concrete
> observers and vice versa.
> The means that I will run into circular
> dependencies.

Nope C++ doesn't permit a circular derived/base class structure

> I guess that I am missing something here, the observer
> pattern must be frequently used and be serialized.

You're confusing the class structure which cannot be circular
with a seqence of pointers which can be circular. The library
can handle circular pointer references with no problem.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net