Results 1 to 6 of 6

Thread: A method that return a struct

  1. #1
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default A method that return a struct

    Hi,

    I've got a class MatrixModule and a method of this class that has to return 3 values.
    Where is the best place to put the definition of the structure that stores the 3 values? Inside the class definition like enum definition?
    Or is it a better idea use a class to store that values?

    Also I use Doxygen for documenting my class. I've got some problem to documents a enum type that is a record of the structure.

    Can anyone suggests me the right code?

    header.h
    Qt Code:
    1. class MatrixModule : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6.  
    7. /*!
    8.   \enum AddressingMode
    9.   \brief Type of addressing mode available
    10.   */
    11. enum AddressingMode
    12. {
    13. Short = 0, //!< Short Addressing
    14. Long //!< Long Addressing
    15. };
    16.  
    17. /*!
    18.   \struct Address
    19.   \brief Structure that stores the address
    20.  
    21.   This structure stores the Address (Short or Long) and also the Adressing Mode
    22.   */
    23. typedef struct
    24. {
    25. AddressingMode type; //!< Addressing Mode: Short or Long
    26.  
    27. quint64 Long; //!< Transceiver Long Address
    28. quint16 Short; //!< Transceiver Short Address
    29.  
    30. bool valid; //!< Flag: valid address
    31. } Address;
    32.  
    33. [...]
    34.  
    35. Address queryTransceiverAddress();
    36.  
    37. [...]
    38. };
    To copy to clipboard, switch view to plain text mode 

    code.cpp
    Qt Code:
    1. /*!
    2.   \brief Query Transceiver Address
    3.  
    4.   Query Transceiver Address (Host -> RF Transceiver)
    5.  
    6.   \return A structure with the address
    7. */
    8. MatrixModule::Address MatrixModule::queryTransceiverAddress()
    9. {
    10. [...]
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: A method that return a struct

    i prefer making the struct defination outside the class

  3. #3
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A method that return a struct

    But in this way doxygen don't create the link on type to the enumerator AddressingMode.

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: A method that return a struct

    sorry i totally misunderstood the question

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: A method that return a struct

    I think you're letting doxygen too far if you let one link in the documentation affect the way you design your software. Besides, I'm pretty sure it's just a matter of finding the correct documentation syntax anyway.
    J-P Nurmi

  6. #6
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A method that return a struct

    I was in doubt whether to use a structure or a class and where to put them.
    Becouse the same tags of doxygen make a different html result, I think it was a problem in my design.

Similar Threads

  1. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 22:48
  2. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 11:25
  3. Replies: 16
    Last Post: 23rd May 2008, 11:12
  4. QTableView Repaint/Refresh
    By millsks in forum Newbie
    Replies: 9
    Last Post: 10th January 2008, 18:18
  5. Make error with Qt Jambi 4.3.2_01
    By pamalite in forum Installation and Deployment
    Replies: 0
    Last Post: 22nd November 2007, 13:05

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.