GLib/GObject+C as the lingua franca?

nf2 nf2 at scheinwelt.at
Sun Jul 27 20:43:43 BST 2008


koos vriezen wrote:
> 2008/7/27 nf2 <nf2 at scheinwelt.at>:
>
>   
>> I thought of really lightweight wrapping. Very minimalistic. See the example
>> below. Mainly that you can put GObjects into C++ containers and for garbage
>> collection...
>>     
>
> But you also need to add a copy constructor then and think about
> either implicit sharing the GFile object or copying ... GFile doesn't
> seem to have ref counting only g_file_dup, so for sharing you must do
> your own ref counting.
>   
GFile inherits from GObject. Therefore it does have ref-counting.

> But if you can easily track the file objects, why not simply store the
> pointers in the C++ containers.
>
>
>   

Again - garbage collection.

The attached example implements the "GO" template class and tests it a 
little - valgrind reports 0 leaks :-)
A bit like a C++ class with QExplicitlySharedDataPointer.

Norbert


-------------- next part --------------
A non-text attachment was scrubbed...
Name: gotest.cpp
Type: text/x-c++src
Size: 1327 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080727/9286b261/attachment.cpp>


More information about the kde-core-devel mailing list