Results 1 to 8 of 8

Thread: Efficiency is the name of the game

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    28
    Thanked 2 Times in 2 Posts

    Default 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

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default 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:
    Qt Code:
    1. AbstractDecoder *dec = null;
    2. switch(decodingMethod)
    3. {
    4. case method1:
    5. dec = new Method1Decoder();//here Method1Decoder is a subclass of AbstractDecoder that actually implements the decoding methods.
    6. break;
    7.  
    8. ...
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to marcel for this useful post:

    baray98 (19th September 2007)

  4. #3
    Join Date
    Aug 2007
    Posts
    275
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    28
    Thanked 2 Times in 2 Posts

    Default 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:

    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

  5. #4
    Join Date
    Aug 2007
    Posts
    275
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    28
    Thanked 2 Times in 2 Posts

    Default Re: Efficiency is the name of the game

    sorry i havent read the code below your reply pardon me my master

  6. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Efficiency is the name of the game


    Ok, don't call me that.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Efficiency is the name of the game

    Quote Originally Posted by marcel View Post

    Ok, don't call me that.
    Maybe we should change your user title on the forum?

  8. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Efficiency is the name of the game

    Maybe we should change your user title on the forum?
    Please don't .
    "Master" sounds like what British butlers call their employers( read "masters") .

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Efficiency is the name of the game

    Yeah... or "Master" like in the master-slave architecture

Similar Threads

  1. Just for fun game
    By vermarajeev in forum Qt-based Software
    Replies: 6
    Last Post: 13th December 2007, 21:52
  2. A small 2D game
    By Nyphel in forum Newbie
    Replies: 3
    Last Post: 1st May 2007, 17:16
  3. Game mouse movement
    By chaosgeorge in forum Qt Programming
    Replies: 1
    Last Post: 2nd December 2006, 23:41
  4. Making 3D controls in QT, implementing a game loop in QT
    By smurrish in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2006, 04:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.