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?