diff mbox

[1/3] Introduce qobject header file

Message ID 1249566736-5020-2-git-send-email-lcapitulino@redhat.com
State Superseded
Headers show

Commit Message

Luiz Capitulino Aug. 6, 2009, 1:52 p.m. UTC
This file contains basic definitions for the QEMU Object Model,
all object implementions must include this file and add its
type code in qtype_t enum.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qobject.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 qobject.h

Comments

Avi Kivity Aug. 6, 2009, 2:02 p.m. UTC | #1
On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> This file contains basic definitions for the QEMU Object Model,
> all object implementions must include this file and add its
> type code in qtype_t enum.
>
>
> +
> +typedef enum {
> +    QTYPE_NONE,
> +} qtype_t;
> +
> +struct QObject;
> +
> +typedef struct QType {
> +    qtype_t code;
>    

Is this really needed?  You can check if an object is a particular type 
by checking its ->type agains whatever you're interested in.  Of course 
you should refrain from doing so unless there's no choice.
Luiz Capitulino Aug. 6, 2009, 2:07 p.m. UTC | #2
On Thu, 06 Aug 2009 17:02:48 +0300
Avi Kivity <avi@redhat.com> wrote:

> On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> > This file contains basic definitions for the QEMU Object Model,
> > all object implementions must include this file and add its
> > type code in qtype_t enum.
> >
> >
> > +
> > +typedef enum {
> > +    QTYPE_NONE,
> > +} qtype_t;
> > +
> > +struct QObject;
> > +
> > +typedef struct QType {
> > +    qtype_t code;
> >    
> 
> Is this really needed?  You can check if an object is a particular type 
> by checking its ->type agains whatever you're interested in.  Of course 
> you should refrain from doing so unless there's no choice.

 Each QType definition is private to each type's module, I would have
to make them public then.
malc Aug. 6, 2009, 3:54 p.m. UTC | #3
On Thu, 6 Aug 2009, Luiz Capitulino wrote:

> This file contains basic definitions for the QEMU Object Model,
> all object implementions must include this file and add its
> type code in qtype_t enum.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  qobject.h |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
>  create mode 100644 qobject.h
> 
> diff --git a/qobject.h b/qobject.h
> new file mode 100644
> index 0000000..b70e669
> --- /dev/null
> +++ b/qobject.h
> @@ -0,0 +1,33 @@
> +/*
> + * QEMU Object Model.
> + *
> + * Copyright (C) 2009 Red Hat Inc.
> + *
> + * Authors:
> + *  Luiz Capitulino <lcapitulino@redhat.com>
> + *
> + * Based on ideas by Avi Kivity <avi@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + */
> +#ifndef QOBJECT_H
> +#define QOBJECT_H
> +
> +typedef enum {
> +    QTYPE_NONE,
> +} qtype_t;

Please do not use _t suffix.

> +
> +struct QObject;
> +
> +typedef struct QType {
> +    qtype_t code;
> +    struct QObject *(*clone)(const struct QObject *);
> +    void (*destroy)(struct QObject *);
> +} QType;
> +
> +typedef struct QObject {
> +    QType *type;
> +} QObject;
> +
> +#endif /* QOBJECT_H */
>
diff mbox

Patch

diff --git a/qobject.h b/qobject.h
new file mode 100644
index 0000000..b70e669
--- /dev/null
+++ b/qobject.h
@@ -0,0 +1,33 @@ 
+/*
+ * QEMU Object Model.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ *  Luiz Capitulino <lcapitulino@redhat.com>
+ *
+ * Based on ideas by Avi Kivity <avi@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#ifndef QOBJECT_H
+#define QOBJECT_H
+
+typedef enum {
+    QTYPE_NONE,
+} qtype_t;
+
+struct QObject;
+
+typedef struct QType {
+    qtype_t code;
+    struct QObject *(*clone)(const struct QObject *);
+    void (*destroy)(struct QObject *);
+} QType;
+
+typedef struct QObject {
+    QType *type;
+} QObject;
+
+#endif /* QOBJECT_H */