[muscle] SV: Namespaces and QT's connect macro.

  • From: "David Svanberg" <ds@xxxxxxxxxxx>
  • To: <muscle@xxxxxxxxxxxxx>
  • Date: Wed, 15 Oct 2003 13:33:49 +0200

I figured out that I could use muscle in my own namespace, i.e.

namespace myFantasticLibrary { using namespace muscle; }

It seems to fix my frustration.


-----Opprinnelig melding-----
Fra: muscle-bounce@xxxxxxxxxxxxx [mailto:muscle-bounce@xxxxxxxxxxxxx]På;
vegne av David Svanberg
Sendt: 15. oktober 2003 12:55
Til: muscle mailing list
Emne: [muscle] Namespaces and QT's connect macro.

Hello folks.

Qt seems to have some limitations in its connect-macro. It can't handle
namespaces. Think of the following:

*** EXAMPLE 1 ***
QMessageTransceiverThread _mtt;
connect( &_mtt, SIGNAL( MessageReceived( MessageRef, const String& ) ),
SLOT( messageReceived( MessageRef, const String& ) ) );

This works just fine. But what happens if you write a library where you
don't want to make the namespace muscle public to everyone.

*** EXAMPLE 2 ***
QMessageTransceiverThread _mtt;
connect( &_mtt, SIGNAL( MessageReceived( muscle::MessageRef, const
muscle::String& ) ), SLOT( messageReceived( muscle::MessageRef, const
muscle::String& ) ) );

Since the MessageReecevied method in QMessageTransceiverThread.h is defined

void MessageReceived(MessageRef msg, const String & sessionID);

Qt will not understand that MessageRef and muscle::MessageRef is the same
class!!! It parses the string and compares "MessageRef" ==

Qt is in this case stupid. OK, this isn't the forum to blaim Qt, but I would
like to suggest a work-around in MUSCLE until Trolltech understands that
they sometimes are humans:

All signals in QMessageTransceiverThread should have fully qualified names.

What do you guys think of this? What does this approach destroy?

David Svanberg
Software Engineer  Poseidon Simulation AS
Naeringsparken, P.O.Box 89, N-8376 Leknes, Norway
Tel:+47 760 54 330  Fax:+47 760 82 006
E-mail:ds@xxxxxxxxxxx  www.poseidon.no

POSEIDON - your maritime training partner

Other related posts:

  • » [muscle] SV: Namespaces and QT's connect macro.