Overhaul oiiotool internal idioms #2586
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
oiiotool dates from pre-C++11, and has grown by accretion. As a
result, the individual actions are implemented using multiple
different idioms, and there is a lot of complex boilerplate.
A recent PR added subimage selection widely to all commands that use
the idiom of an implementation that inherits from the OiiotoolOp
class. The convinced me that we want to migrate as many actions as
possible to this idiom. I also realized that the current use of
OiiotoolOp could be greatly simplified by using lambdas in most
cases, which weren't available in the pre-C++11 ancient times when
oiiotool was first being developed.
This patch:
Has the OiiotoolOp base class contain (and accept in its ctr) a
std::function for the meat of the impl() and setup() methods.
If init() and setup() are the only bits that need customization for
a particular action, they can just be passed as lambdas rather than
needing to subclass OiiotoolOp.
This eliminates a huge amount of per-action boilerplate, many helper
subclasses and macros.
In front of every action implemetation (however it is done), I
inserted a comment with the command line argument (e.g.,
--colormap
) which is an aid for me to quickly find theimplementation in this huge file.
This patch DOES NOT change any non-OiiotoolOp action idioms to
OiiotoolOp. That will come later, first I wanted to make these
improvements.
Signed-off-by: Larry Gritz lg@larrygritz.com