The coprocess API is a bit clunky
@acbauer There are a number of places where things could be made a little smoother, but I don't know what can be changed without totally breaking the API (your discretion).
They mostly basic handling:
- seems silly to pass all of string as
const char*
when the internals convert them back to a string for the mapping - where appropriate, we could have some non-void return values - to reduce duplicate calling
Here's a small wish-list to start:
-
vtkCPDataDescription
/// Add names for grids produced by the simulation. This allocates a new /// vtkCPInputDataDescription for that grid, if a grid by that name does not /// already exist. /// NOTE currently no guard against null or empty values /// \return pointer to new or existing input description vtkCPInputDataDescription* AddInput(const char* gridName); vtkCPInputDataDescription* AddInput(const std::string& gridName); /// Returns true if the grid is necessary, given the grid's name. bool GetIfGridIsNecessary(const char*) CONST; bool GetIfGridIsNecessary(const std::string& gridName) CONST; /// Returns true if any of the grids is necessary. bool GetIfAnyGridNecessary() CONST;
I used CONST to highlight a few places where const methods might be possible.
After the changes, it only saves a few lines, but IMO is considerably less ugly. Eg,
Simply vtkNew descrip; vtkCPInputDataDescription* cpInput = descrip->AddInput("input");
Or
const std::string inputName = "input";
vtkNew<vtkCPDataDescription> descrip;
vtkCPInputDataDescription* cpInput = descrip->AddInput(inputName);
Instead of this
const std::string inputName = "input";
vtkNew<vtkCPDataDescription> descrip;
descrip->AddInput(inputName.c_str());
vtkCPInputDataDescription* cpInput = descrip->GetInputDescriptionByName(inputName.c_str());