#include <iostream>
/* Acts as a base index class for indexing a collection of cells.
* Child classes can be made to derive an absolute placement in an array of cells.
* This can work for 1, 2, or even 3 dimensional grids.
* Example, if grid is 2D, 4 X 4 cells, the absolute index can
* be derived from (x,y) x * 4 + y
*/
class CellIndex
{
public:
/* @brief: Method that derives absolute index from multiple variables
* or values.
* @example: width = 3, length = 3, (1, 2) -> 1 * 3 + 2 -> 5 in array
* @note: Needs to be overloaded in child classes.
*/
virtual size_t absolute() const { return 0; }
};
/* @breif: Zero-indexed 1D child class of Cell Index, supports integral types
* @detail: For an (x) neighborhood, 0 is the first element, x - 1 i s the last.
*/
template<class IndexType = size_t>
class OneDimensionIndex : public CellIndex
{
private:
IndexType _x;
public:
OneDimensionIndex(IndexType i = 0): _x(i)
{}
~OneDimensionIndex()
{}
size_t absolute() const
{
return _x;
}
};
template<class CellType, unsigned dimensions>
class CellSequence
{
};
int main(int argc, char const *argv[])
{
OneDimensionIndex<> foo;
std::cout << foo.absolute() << " that is foo absolute\n";
return 0;
}