Results 1 to 2 of 2

Thread: what is the best approach

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

    Default what is the best approach

    i have some compress data from some number of sensors and I want to decompress it and display it to the user, the dispaying (plotting ) an uncompressed data class is done ,now handling the compress data is my problem. how can i approach in an object oriented way ? here is what i think but i don't know how to implement it or is it possible to implement this architecture

    Class Sensor <--- base class of a sensor

    Class Samples <--- this should contain variable number of Sensor (class)

    Class Frame <-- this should contain a fix number of Samples (class)

    so when i use frame class ill give it pointer to my compressed data
    i.e.
    Qt Code:
    1. new Frame(&buffer);
    To copy to clipboard, switch view to plain text mode 
    the class sample will decode/uncompress his part of the buffer then the base class sensor will decode his part of the buffer

    is there any other good way to it ?

    baray98

  2. #2
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: what is the best approach

    I think adding compress() / uncompress() functions would be elegant, and providing the constructor you wrote as syntactic sugar is already the best practice. At least that is how I usually do it:

    Qt Code:
    1. class myclass
    2. {
    3. public:
    4. MyClass();
    5. ~MyClass():
    6.  
    7. MyClass(CompressedData& data);
    8.  
    9. compress(CompressedData& data) const; // or serialize() ... or save() ...
    10. uncompress(CompressedData& data);
    11.  
    12. // ...
    13. };
    To copy to clipboard, switch view to plain text mode 
    "If you lie to the compiler, it will get its revenge." - Henry Spencer

Similar Threads

  1. How to create Custom Slot upon widgets
    By ashukla in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2007, 14:07
  2. Create "QGroupBoxCollapsible" - best approach?
    By irudkin in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 16:24
  3. help setting up qt4 ui from qt3
    By illuzioner in forum Qt Programming
    Replies: 3
    Last Post: 24th June 2007, 04:16
  4. Images/icons. It's not displayed
    By LMZ in forum Qt Tools
    Replies: 37
    Last Post: 18th May 2007, 14:55
  5. The single Inheritance Approach
    By raphaelf in forum Newbie
    Replies: 2
    Last Post: 2nd June 2006, 08:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.