posted 7 years ago
I want to design a library that takes as input arrays of varying dimension and variable type, then processes them in different pipelines according to a preferences file. The idea is that the switch method will choose one of these pipelines, and an overload will handle the varying types.
I have written some toy code that abstracts the problem. I think if I could get this code to work I would know how to design my project.
I have a base class Foo which takes an argument of either Float or Double type, and an integer for preferred pipeline. Here is the code I have written for this. Note it does not compile.
I then have two pipeline classes Bar1 and Bar2 . These both compile.
and
The desired output is
Bar 1 Double
Bar 1 Float
Bar 2 Double
Bar 2 Float
However the compiler isn't having any
I would really like to do this some more elegant way than casting the Object. Am I stuck casting the Object or is there a more elegant way to handle these cases?