Skip to content
Snippets Groups Projects
Commit 08c28d55 authored by Oliver Sander's avatar Oliver Sander
Browse files

Introduce method 'fixedSize', which does the same as 'fixedsize', but has camel-case naming

The CommDataHandleIF interface class has a member 'fixedsize'.  This is one
of the few in dune-grid that does not comply with the official naming rules:
the name should be 'fixedSize'.  This patch introduces a new method 'fixedSize',
to allow a gradual transition from the old spelling to the new one.
The make the transition as painless as possible, but methods implement the
following behavior (remember that CommDataHandleIF is the base class in a
CRTP pattern):

- If the derived/implementation class has a method 'fixedSize', then that
  method is called.
- Otherwise, the method 'fixedsize' is called.

This approach allows both implementors of grids and implementors of data
handles to switch their code from 'fixedsize' to 'fixedSize' at their
convenience.

Finally, I have come across a usecase for CRTP. :-)
parent 07269e47
Branches
Tags
1 merge request!82CommDataHandleIF: Introduce method 'fixedSize', which does the same as 'fixedsize', but has camel-case naming
......@@ -95,11 +95,38 @@ namespace Dune
returns true if size of data per entity of given dim and codim is a constant
@param dim valid dimension (i.e. the grids dimension)
@param codim valid codimension of the entity set for which data should be communicated
This method calls 'fixedSize' (with a capital S) of the derived class,
if it exists in the derived class. Otherwise, it calls 'fixedsize'.
*/
bool fixedsize (int dim, int codim) const
{
CHECK_INTERFACE_IMPLEMENTATION((asImp().fixedsize(dim,codim)));
return asImp().fixedsize(dim,codim);
auto basePtr = &CommDataHandleIF<DataHandleImp,DataTypeImp>::fixedSize;
auto derPtr = &DataHandleImp::fixedSize;
bool hasOverwrittenFixedSize = basePtr != derPtr;
if (hasOverwrittenFixedSize)
return asImp().fixedSize(dim,codim);
else
return asImp().fixedsize(dim,codim);
}
/** @brief
returns true if size of data per entity of given dim and codim is a constant
@param dim valid dimension (i.e. the grids dimension)
@param codim valid codimension of the entity set for which data should be communicated
This method calls 'fixedSize' (with a capital S) of the derived class,
if it exists in the derived class. Otherwise, it calls 'fixedsize'.
*/
bool fixedSize (int dim, int codim) const
{
auto basePtr = &CommDataHandleIF<DataHandleImp,DataTypeImp>::fixedSize;
auto derPtr = &DataHandleImp::fixedSize;
bool hasOverwrittenFixedSize = basePtr != derPtr;
if (hasOverwrittenFixedSize)
return asImp().fixedSize(dim,codim);
else
return asImp().fixedsize(dim,codim);
}
/** @brief how many objects of type DataType have to be sent for a given entity
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment