View Single Post
Posts: 222 | Thanked: 205 times | Joined on Jul 2009 @ Finland
#22
Originally Posted by dannym View Post
C++ and C&GObject, not so much. They're very similar, only GObject is more advanced because it came later and learnt from the silly mistakes C++ made (no reflection, no properties (and by that, no automatic notification or monitor pattern), no reference counting, broken virtual methods, making copies all over the place, no Variant datatype, no signals, ...)
Seems like you are trying to taste a food by reading a list of ingredients. Proof of the programming environment is in the pain of using it.

Here's a real world example with GObject (from libhildondesktop):

Code:
typedef struct _HDPluginLoader HDPluginLoader;
typedef struct _HDPluginLoaderClass HDPluginLoaderClass;
typedef struct _HDPluginLoaderPrivate HDPluginLoaderPrivate;


#define HD_TYPE_PLUGIN_LOADER            (hd_plugin_loader_get_type ())
#define HD_PLUGIN_LOADER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), HD_TYPE_PLUGIN_LOADER, HDPluginLoader))
#define HD_PLUGIN_LOADER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  HD_TYPE_PLUGIN_LOADER, HDPluginLoaderClass))
#define HD_IS_PLUGIN_LOADER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HD_TYPE_PLUGIN_LOADER))
#define HD_IS_PLUGIN_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  HD_TYPE_PLUGIN_LOADER))
#define HD_PLUGIN_LOADER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  HD_TYPE_PLUGIN_LOADER, HDPluginLoaderClass))

struct _HDPluginLoader 
{
  GObject gobject;

  HDPluginLoaderPrivate *priv;
};

struct _HDPluginLoaderClass 
{
  GObjectClass parent_class;

  GObject *(* load) (HDPluginLoader  *loader,
                     const gchar     *plugin_id,
                     GKeyFile        *keyfile,
                     GError         **error);
};

...
And here's the equivalent in C++:

Code:
class HDPluginLoader 
{
  QObject* load(...)

...
};
I rest my case.

EDIT: ...and Qt metaobject system gives you the dynamic, introspective features you want.
__________________
'QtDone'. Getting things done (GTD) was never this cheap!

'QmlReddit' reads Reddit!

Last edited by vivainio; 2010-09-04 at 14:57.