Efficiency is the name of the game
I have a set of data as input and I my apps should decode it. This data contain different record type and each record type has different way of decoding them,, At the beginning of the data is a frame wrapper which contain the info on what type of record is it .
Now, my question what is the best way to handle this? Here is what i i did. I have a class Frame which handles the decoding of what record type it is then I have a class SpecificFrame that handles decoding of that record type which inherits class Frame. In my app I assign my void* vFrame to a SpecificFrame accordingly . I don't know if am being efficient on this style.
What's your take guys,
baray98
Re: Efficiency is the name of the game
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:
Code:
AbstractDecoder *dec = null;
switch(decodingMethod)
{
case method1:
dec = new Method1Decoder();//here Method1Decoder is a subclass of AbstractDecoder that actually implements the decoding methods.
break;
...
}
Re: Efficiency is the name of the game
yes that would be cleaner (my master ) marcel and thank you but can you give me examples of how can i implement the qouted below:
Quote:
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).
by the way the dataframe provides the encoding type
you are really my mentor,
baray98
Re: Efficiency is the name of the game
sorry i havent read the code below your reply pardon me my master
Re: Efficiency is the name of the game
:)
Ok, don't call me that.
Re: Efficiency is the name of the game
Quote:
Originally Posted by
marcel
:)
Ok, don't call me that.
Maybe we should change your user title on the forum? :cool:
Re: Efficiency is the name of the game
Quote:
Maybe we should change your user title on the forum? :cool:
Please don't :).
"Master" sounds like what British butlers call their employers( read "masters") :).
Re: Efficiency is the name of the game
Yeah... or "Master" like in the master-slave architecture ;)