I am not sure if I understand you correctly, but why don't you create an abstract class that provides a basic interface for decoding records?
Assuming that there can be multiple ways of decoding multiple records, you should create as many subclasses of that abstract class as needed, one for each different decoding method.
As for the frame, you should have another class which contains the decoder classes. This class should parse a frame and instantiate decoder classes based on the decoding method needed(assuming the data in the frame provides info on the encoding type).
So, it should be pretty clean. No need to fiddle around with void pointers.
EDIT: in the class that handles the frame you should have only one member of the abstract class type. Then you could do:
AbstractDecoder *dec = null;
switch(decodingMethod)
{
case method1:
dec = new Method1Decoder();//here Method1Decoder is a subclass of AbstractDecoder that actually implements the decoding methods.
break;
...
}
AbstractDecoder *dec = null;
switch(decodingMethod)
{
case method1:
dec = new Method1Decoder();//here Method1Decoder is a subclass of AbstractDecoder that actually implements the decoding methods.
break;
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks