Request for additional accessors

I finished implementing pickling (saving/loading of the world state -- yay) in Python, and in order to recreate inputs from their factory outputs, I needed to add a few more getters to the C++ end of things. Would you consider adding these to the trunk?

I can't see any negative impact for other users. If you feel the need to change the names of some of them, I understand.

Also, I noticed something missing from b2Controllers -- the fact that you cannot tell what type the created controller is (unless, of course, you know beforehand). Keeping with the structure of the other types, I added:
Code:
enum b2ControllerType
{
   e_unknownController = -1,
   e_buoyancyController,
   e_constantAccelController,
   e_constantForceController,
   e_gravityController,
   e_tensorDampingController,
};
Thanks!
It was actually (semi-) deliberate to not include such an enum.
I was trying to structure controllers such that they could be included or not independantly, without having to touch any other part of Box2D. Basically, every time you might use an enum and switch statement, I used a virtual method instead.
But this obviously doesn't generalize very well, as you cannot add extra methods like serialization without changing the contract required of b2Controller. So I guess it was a failed experiment.

I'm still surprised you cannot use the virtual table pointer to determine the class of something at runtime, but it doesn't seem that is possible, and C++'s RTTI is apparently evil.
I can understand your reservations at not wanting to put the enum in. In my excitement about pickling, I failed to pick up on the reason why you hadn't added one. 🙂

Anyway, I can't see a solution around it without storing extra information somewhere, so I'll just maintain that portion separately from the main distribution.
It's not really a problem. Keep the enum. People can always add controllers under e_unknownController, in which case your pickler will rightly declare it cannot do it.

Perhaps a more robust solution than enums would be to return a unique string or GUID?
A GUID would definitely work. I guess if no one else sees the need for it on the C++-end it doesn't really matter.

I guess it's a bit selfish of me to try to push things to the SVN just so I don't have to deal with merging sources.
Interestingly, I also added a similar enum, (as well as a userData field - which I explained the reasons for elsewhere) for my language binding.
It's very useful to have *something* which identifies a particular type uniquely.

Original thread: https://box2d.org/forum/viewtopic.php?t=2041