I have a base class named "SensorData", for which different implementations exist. The base class does more, but for the sake of simplicity, let's say I only want the implementations to return a constant, implementation-specific value "maxRange". The obvious way to implement this would be:
Base class:
class SensorData {
virtual float getMaxRange() = 0;
virtual ~SensorData();
};
Example implementations would look like this:
class Velo64 : public SensorData {
inline float getMaxRange() { return 120.0f;}
};
class Velo16 : public SensorData {
inline float getMaxRange() { return 90.0f;}
};
Additionally, I have a factory that returns a pointer to an implementation.
My question is: Does inlining work here? AFAIK, inlining means the compiler replaces all function calls with the actual function. Since the actual function is not defined at compile time (but instead determined at runtime, depending on which implementation is used?), can the function even be inlined?
I am asking this because the function (and others like it) will be called millions of times per second in a performance-critical application. Alternatively, is there any better way to go? For example, using variables instead of a get-function?