5

I have a class that inherits from boost::statechart library. I need to use this class in Python script, I am wondering if I need to write wrapper codes (.def s) for all boost::statechart library just because my class inherited from it? Or the boost.python will not need any wrapper code to see the definitions (it handles other boost libraries automatically to call in python)?

cmh
  • 10,612
  • 5
  • 30
  • 40

1 Answers1

0

Boost.Python does not have any special handling for Boost classes. If you want to use inherited functions (Boost class or not), you need to expose them to Python like you would do with your own code.

If you don't want to use any of the base class functions from your script, you need not do anything besides binding your own code.

You have two options if you need (some of) the base class interface available from Python:

  • You bind the base class separately and expose it as a base for your class. This is the most "complete" solution (as complete as you make it - you can choose to limit the number of exposed functions).
  • You don't bind the base class. Python does not have to know about the inheritance relationship. You can simply bind the functions you want to expose as all public functions are members of the derived class, too. This is simpler if you only need some of the base class functionality to be usable from Python.
Tamás Szelei
  • 23,169
  • 18
  • 105
  • 180