Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-10-02 12:15:57


Taneli R.:

> I'm converting pipes and filters architecture made with raw pointers to
> use
> shared_ptrs. My Pipe class has a static counter, which gives unique pipeID
> to every pipe. Since Pipe class has pure virtual functions, the pipes in
> my
> architecture are instances of derived classes.
>
> Pipe class looks like this:
>
> class Pipe
> {
> public:
> Pipe() : pipeID(++pipeCount) {}
> virtual bool lay(boost::shared_ptr<Pipeable>& source, string&
> sourceTag, boost::shared_ptr<Pipeable>& destination, string& destTag) = 0;
> /*...other pure virtual functions here...*/
> protected:
> int pipeID;
> static int pipeCount;
> }
>
> My problem is that when I try to make a new pipe between source and
> destination, the pipe is made twice (with different pipeID-numbers), which
> is a problem because there should be only one pipe connecting my
> components.
> I believe it is a result from using "this"-pointer directly without
> enabling
> "shared_from_this". I know that I should use it somehow but the same time
> I
> should maintain the unique pipeID.

I see no potential uses of enable_shared_from_this in the code you posted...
your problem is likely elsewhere. Can you post a complete program that
demonstrates it?


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