[
https://issues.apache.org/jira/browse/THRIFT-1712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Vogt updated THRIFT-1712:
--------------------------------
Attachment: 011_base_struct_rest_140619v2.patch
010_base_struct_gen_140619v3.patch
This is an updated patch. It now removes the id string,
because the same can be achieved with typeid(var/class).name().
(Not completely, the name is "ugly"/mangled, but for type casting
this is ok).
The patch is now nearly identical to the version in
https://issues.apache.org/jira/browse/THRIFT-2255
except:
a) its a compile time option
b) the base class can be configured/replaced at compile time
I would vote for "a" and "b" is only a feature which seems
to be useful for a base _service_ class, but not for a "struct".
I can prepare an update for a+b, in this case the patch _is_ identical to
"2255" except the different class names :)
> Add TBase class for c++
> -----------------------
>
> Key: THRIFT-1712
> URL: https://issues.apache.org/jira/browse/THRIFT-1712
> Project: Thrift
> Issue Type: New Feature
> Components: C++ - Compiler
> Affects Versions: 0.8
> Reporter: Martin Vogt
> Assignee: Ben Craig
> Priority: Minor
> Labels: base, c++, class
> Attachments: 010_base_struct_gen_140619v3.patch,
> 011_base_struct_rest_140619v2.patch
>
>
> The generated c++ classes for struct's do not have a common base class.
> The patch adds a "base_struct" option to the compiler:
> - thrift --gen cpp:base_struct
> this will use a TBaseStruct in the thrift installation.
> Another option allows to replace the baseclass with an arbitrary one:
> -thrift --gen cpp:base_struct=MyBase,base_struct_inc=\\</path/MyBase.h\\>\n"
> With this it's possible to extend the TBaseStruct class in the thrift
> installation.
> I like to use this TBase class in QT, as a signal, for example:
> {quote}
> signals:
> void update(const TBase& tBase);
> {quote}
> And in the receiver slot I then can check which kind of message was send:
> {quote}
> // compare static pointers
> if (tBase.ascii_fingerprint == User::ascii_fingerprint) \{
> User* user=(User*)&tBase;
> processUserMessage(user);
> \}
> {quote}
--
This message was sent by Atlassian JIRA
(v6.2#6252)