On Wednesday, 21 de September de 2011 11.52.03, Peter Kuemmel wrote: > I still see a problem in making signals public, this > completely breaks encapsulation, and makes it possible > for everyone to emit any signal.
There's no way around it. Since we're using the function pointer (actually,
the PMF) to identify the signal, you must have C++ access to the signal
function. That means you must be able to call it.
Other template-based signal libraries have the same problem. It cannot be
avoided unless you have a way to identify the signal which doesn't include
access to the actual signal implementation.
One solution to that would be to have an enum of signals, instead of
identifying by an object or by a PMF. However, handling enums is not very
easy, since extending the range becomes cumbersome -- how do you add a new
signal to a class that has been derived from?
As the old adage says, "all problems in C++ can be solved with another level
of indirection". So we can create an indirection layer to the enums (the
numeric IDs) and map at runtime. The easiest way of doing that is to have a
string-based approach. However, C++ has no reflection mechanism, so either
you're forced to write the string-matching code yourself, or you have to use a
code generator.
And then we're right back where we started: moc and the current syntax.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
