From: Sergey Sadovnikov (flex_ferrum_at_[hidden])
Date: 2008-04-22 10:22:39
There are many cases in the "real world" when developers need
something like 'moc' utility from the Qt distribution. For example,
such utility could add some extended RTTI into classes and
structures, add auto-generated serialization/initialization/
assignment/comparation code, defines something like properties, and so one.
I think it could be good idea to add something like 'moc' into boost
distribution and to make it standard development tool.
How could it works. Assume we have a code like this:
int SomeMethod2(int, double);
Here is 'MIG' (for example) is abbreviation of 'MetaInfo Generator'.
After preprocess with 'mig' following code could be generated (in separated .cpp):
// Retrieving members info for this class
const std::vector<__MemberInfo>& SomeClass::__GetMembersInfo()
static std::vector<__MemberInfo> members = InitMembersInfo<SomeClass>();
// Runtime method invocation
R SomeClass::__Invoke(const char* memberName)
// autogenerated methods invocation code
// __Invoke methods for another numbers of arguments
// Autogenerated assignment operation
void SomeClass::__Assign(const SomeClass& other)
Member1 = other.Member1;
Member2 = other.Member2;
Declaration of this methods in the class scope hides with macros
MIG_INFO (like Q_OBJECT in the QT). __MemberInfo is a struct wich
contains some information about class member. Such as member name,
member kind (method, data member), visibility (public, protected,
private) and so on. MIG_MEMBERS is a macro which indicate what
following members should be preprocessed by mig.
It's just an idea how to bring more "zero-cost" extended RTTI into
C++ with boost.
-- Best regards Sergey mailto:flex_ferrum_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk