Exposing Multi-Level Inheritance with virtual functions
I've been looking around and I can find tons of information about how to wrap shallow inheritance hierarchys with virtual/pure virtual functions, but none of them show how to do multi level inheritance. I'm unsure if I'm supposed to inherit from the wrapper or the base class for the virtual functions. Essentially, I'm asking what the best way to wrap this, the various methods I've tried usually result in error messages about the wrapper not being available
I want to be able to create various types of screens in Python so obviously I need to expose/wrap all the base classes, but this is where I get a little unclear about if I should be inheriting from the wrappers or the base classes, and how I should be representing these clases in python. My initial attempt at wrapping looked something like this:
I cant export this wrapping because boost python won't let me have initializers for abstract classes. I attempted to fix this by changing all the pure virtual functions to virtual functions, and adding a Default method for each virtual function in the wrapper. I was able to compile like this, but python hits a runtime error saying a wrapper is unavailable for base class AnimatedDraw, so obviously my exports are sstill incorrect. I'm looking for advice on how to export this hierarchy. Can I keep these functions pure virtual and have initializers or will I need to add a default implementation? Further to that, should I be inheriting from the wrappers and not the base classes? I really just want this to work where I can inherit from Screen and implement Update, Draw and HandleKeys for each screen.
I had an additional question. How do you correctly implement a copy constructors on the wrapper classes?
I assume is incorrect since I'm not making a proper copy of the self pointer. What's the correct way to do this?
My last question is more a sylistic one. I've seen multiple ways to implement the virtual function override. I've chosen the call_method form:
void Update(const sf::Uint32 time, const float TimeScale = 1.0) override
call_method<void>(self, "Update", time, TimeScale);
just because that's what I'm used to. Is there a "better" or more correct way to do this? or is it a purely stylistic choice?
Sorry for the cluster of code, I hope my questions are clear. I can clean out some parts of the code that I don't think are relevant, but since the classes are fairly small to begin with, I figured it'd be okay.