HomeWildfire Games

Use variadic template for RecurseObject from rP31 and move it from GUIutil to…

Description

Use variadic template for RecurseObject from rP31 and move it from GUIutil to IGUIObject.

Unifies the four copies of the function while making it more versatile.
Supersede the hardcoded GUIRR enum and CheckIfRestricted function with a flexible member function pointer.
Replace the custom IGUIObject iterator with a casually iterable GetChildren getter, so that it is more obvious what it iterates on.
Implement TODO from rP141, i.e. RecurseObject not iterating over the base object.

Differential Revision: https://code.wildfiregames.com/D2204
Tested on: gcc 9.1.0, clang 8.0.1, VS2015

Event Timeline

vladislavbelov added inline comments.
/ps/trunk/source/gui/CRadioButton.cpp
38

const& is useless here and it misleads a reader a bit.

/ps/trunk/source/gui/IGUIObject.h
135

I don't see a strong reason to use it as a non-const.

154

Should be const. GetSetting accepts const IGUIObject*.

159

Should be const.

elexis added inline comments.Aug 23 2019, 12:45 AM
/ps/trunk/source/gui/CRadioButton.cpp
38

I've removed it first too, then I added it back to highlight that I only changed the right hand side.

/ps/trunk/source/gui/IGUIObject.h
135

I see a strong reason to use it as const, because if something would insert or remove an object, the CGUI needs to rebuild the pointer map AddToPointersMap, AddChild.
So thanks for the hint.

154

The problem is if you make this const then all functions that RecurseObject consumes have to be const.
I can add that restriction because there wont be non-const functions likely.

vladislavbelov added inline comments.Aug 23 2019, 1:05 PM
/ps/trunk/source/gui/IGUIObject.h
154

It's possible (not sure for the current implementation) to use const and non-const functions in RecurseObject.