Summary | Autogenerated SE types? |
Queue | gloox |
Queue Version | SVN |
Type | Enhancement |
State | Unconfirmed |
Priority | 2. Medium |
Owners | |
Requester | euroelessar (at) gmail (dot) com |
Created | 10/18/2009 (5165 days ago) |
Due | |
Updated | 10/22/2009 (5161 days ago) |
Assigned | |
Resolved |
New Attachment: regse[1].diff
stanzaextension.cpp, don't forget to add it to files list
New Attachment: regse.diff
State ⇒ Unconfirmed
Queue ⇒ gloox
Summary ⇒ Autogenerated SE types?
Type ⇒ Enhancement
Priority ⇒ 2. Medium
StanzaExtensionType), but it's boring and hard to use them, i.e.
"const VCardUpdate *vcard_update =
presence.findExtension<VCardUpdate>(ExtVCardUpdate);"
I tell to method info about SE both by template and enum. But just
imagine how simpler become our source if we will give to method all
info just by template!
"const VCardUpdate *vcard_update =
presence.findExtension<VCardUpdate>();" is easier, isn't it?
So, what are the ways for it?..
I think, it's possible to create some macro, like this one:
#define REGISTER_STANZA_EXTENSION(SEClass) \
template <> \
int stanzaExensionType<SEClass>(SEClass *t = 0) \
{ \
static int type = -1; \
if(type == -1) \
type = registerStanzaExtension(#SEClass); \
return type; \
}
both with functions:
template <typename T> int stanzaExensionType(T *t = 0) { return -1; }
GLOOX_API int registerStanzaExtension(const char *name);
second one should return positive unique integer value for different
name's and the same for equal ones. Invoking of method
stanzaExensionType<T>() is equal to guessing of correct enum. Also
macro should be used in this way:
REGISTER_STANZA_EXTENSION(gloox::VCardUpdate), namespace mustn't be skiped.
What do you think about it?..