I currently have a class that exposes a signal but otherwise
hides its internals behind a firewall using the Pimpl idiom:
class Foo {
public:
boost::signal0<void> statusChanged;
private:
class Impl;
boost::scoped_ptr<Impl> const pimpl_;
};
Since all I want to do publicly is allow things to connect to
this signal:
Foo foo;
foo.statusChanged.connect(boost::bind(&X::bar, this));
it'd be nice to hide the signal too and replace it with a connect() method:
class Foo {
public:
boost::signals::connection connect(slot_type const &) const;
private:
class Impl;
boost::scoped_ptr<Impl> const pimpl_;
};
My problem is defining slot_type. If I have
boost::signals::connection
Foo::connect(boost::slot<void> const & slot) const
{
return statusChanged.connect(slot);
}
I get compiler warnings something like this (below).
As you can see, I'm having trouble decyphering the magic that is the
boost header files!
can someone please help!
Kind regards,
Angus
cxx: Error: ../../../devel/boost/boost/signals/slot.hpp, line 122: #250
reference to void is not allowed
detected during instantiation of class
"boost::slot<SlotFunction> [with SlotFunction=void]" at
line 171 of
"../../../devel/src/graphics/GraphicsCacheItem.C"
const SlotFunction& get_slot_function() const { return slot_function; }
----------------------^
cxx: Error: ../../../devel/boost/boost/signals/slot.hpp, line 128: #70
incomplete type is not allowed
detected during instantiation of class
"boost::slot<SlotFunction> [with SlotFunction=void]" at
line 171 of
"../../../devel/src/graphics/GraphicsCacheItem.C"
SlotFunction slot_function;
-----------------^
cxx: Error: ../../../devel/src/graphics/GraphicsCacheItem.C, line 171: #304 no
instance of overloaded function "boost::signal0