I have a singleton (from boost::serialization):
class LogManager : public boost::serialization::singleton<LogManager> { ... };
And wrapper for getting instance:
inline LogManager &logManager() { return LogManager::get_mutable_instance(); }
What's the right way to bind this into boost.python module?
I tried:
class_< LogManager, boost::serialization::singleton<LogManager> >("LogManager", no_init)
...
;
As a result - a lot of ugly error text in console. What's wrong?
In addition to using bases<...> in the second argument as Autopulated pointed out, I think you also want to specifiy boost::noncopyable as the third template argument, e.g.
bp::class_<LogManager, bp::bases<boost::serialization::singleton<LogManager> >, boost::noncopyable>("LogManager", bp::no_init)
Edit: Also, you need have a class declaration for any base classes listed, e.g.
bp::class_<boost::serialization::singleton<LogManager>, boost::noncopyable>("Singleton", bp::no_init)
Or, if you don't need access to the base class and won't be exporting any other children of boost::serialization::singleton<LogManager>, then you can omit specifying the base classes in the first place. That is, the following declaration is just fine if all you want to do is expose the LogManager class:
bp::class_<LogManager, boost::noncopyable>("LogManager", bp::no_init)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With