/*
**==============================================================================
**
** CAUTION: This file generated by KonkretCMPI. Please do not edit.
**
**==============================================================================
*/

#ifndef _konkrete_Widget_h
#define _konkrete_Widget_h

#include <konkret/konkret.h>

/*
**==============================================================================
**
** struct WidgetRef 
**
**==============================================================================
*/

/* classname=KC_Widget */
typedef struct _WidgetRef
{
    KBase __base;
    /* KC_Widget features */
    const KString Id;
}
WidgetRef;

static const unsigned char __WidgetRef_sig[] =
{
    0x09,0x4b,0x43,0x5f,0x57,0x69,0x64,0x67,0x65,0x74,0x00,0x01,0x4c,0x02,0x49,
    0x64,0x00,
};

KINLINE void WidgetRef_Init(
    WidgetRef* self,
    const CMPIBroker* cb,
    const char* ns)
{
    const unsigned char* sig = __WidgetRef_sig;
    KBase_Init(&self->__base, cb, sizeof(*self), sig, ns);
}

KINLINE CMPIStatus WidgetRef_InitFromInstance(
    WidgetRef* self,
    const CMPIBroker* cb,
    const CMPIInstance* x)
{
    WidgetRef_Init(self, cb, NULL);
    return KBase_FromInstance(&self->__base, x);
}

KINLINE CMPIStatus WidgetRef_InitFromObjectPath(
    WidgetRef* self,
    const CMPIBroker* cb,
    const CMPIObjectPath* x)
{
    WidgetRef_Init(self, cb, NULL);
    return KBase_FromObjectPath(&self->__base, x);
}

KINLINE void WidgetRef_Print(
    const WidgetRef* self,
    FILE* os)
{
    KBase_Print(os, &self->__base, 'r');
}

KINLINE CMPIInstance* WidgetRef_ToInstance(
    const WidgetRef* self,
    CMPIStatus* status)
{
    return KBase_ToInstance(&self->__base, status);
}

KINLINE CMPIObjectPath* WidgetRef_ToObjectPath(
    const WidgetRef* self,
    CMPIStatus* status)
{
    return KBase_ToObjectPath(&self->__base, status);
}

KINLINE const char* WidgetRef_NameSpace(
    WidgetRef* self)
{
    if (self && self->__base.magic == KMAGIC)
        return self->__base.ns ? KChars(self->__base.ns) : NULL;
    return NULL;
}

KINLINE void WidgetRef_SetString_Id(
    WidgetRef* self,
    CMPIString* x)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_SetString(field, x);
    }
}

KINLINE void WidgetRef_Set_Id(
    WidgetRef* self,
    const char* s)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_Set(field, self->__base.cb, s);
    }
}

KINLINE void WidgetRef_Null_Id(
    WidgetRef* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_Null(field);
    }
}

KINLINE void WidgetRef_Clr_Id(
    WidgetRef* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_Clr(field);
    }
}

/*
**==============================================================================
**
** struct Widget 
**
**==============================================================================
*/

/* classname=KC_Widget */
typedef struct _Widget
{
    KBase __base;
    /* KC_Widget features */
    const KString Id;
    const KString Color;
    const KUint32 Size;
}
Widget;

static const unsigned char __Widget_sig[] =
{
    0x09,0x4b,0x43,0x5f,0x57,0x69,0x64,0x67,0x65,0x74,0x00,0x03,0x4c,0x02,0x49,
    0x64,0x00,0x0c,0x05,0x43,0x6f,0x6c,0x6f,0x72,0x00,0x05,0x04,0x53,0x69,0x7a,
    0x65,0x00,
};

KINLINE void Widget_Init(
    Widget* self,
    const CMPIBroker* cb,
    const char* ns)
{
    const unsigned char* sig = __Widget_sig;
    KBase_Init(&self->__base, cb, sizeof(*self), sig, ns);
}

KINLINE CMPIStatus Widget_InitFromInstance(
    Widget* self,
    const CMPIBroker* cb,
    const CMPIInstance* x)
{
    Widget_Init(self, cb, NULL);
    return KBase_FromInstance(&self->__base, x);
}

KINLINE CMPIStatus Widget_InitFromObjectPath(
    Widget* self,
    const CMPIBroker* cb,
    const CMPIObjectPath* x)
{
    Widget_Init(self, cb, NULL);
    return KBase_FromObjectPath(&self->__base, x);
}

KINLINE void Widget_Print(
    const Widget* self,
    FILE* os)
{
    KBase_Print(os, &self->__base, 'i');
}

KINLINE CMPIInstance* Widget_ToInstance(
    const Widget* self,
    CMPIStatus* status)
{
    return KBase_ToInstance(&self->__base, status);
}

KINLINE CMPIObjectPath* Widget_ToObjectPath(
    const Widget* self,
    CMPIStatus* status)
{
    return KBase_ToObjectPath(&self->__base, status);
}

KINLINE const char* Widget_NameSpace(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
        return self->__base.ns ? KChars(self->__base.ns) : NULL;
    return NULL;
}

KINLINE void Widget_SetString_Id(
    Widget* self,
    CMPIString* x)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_SetString(field, x);
    }
}

KINLINE void Widget_Set_Id(
    Widget* self,
    const char* s)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_Set(field, self->__base.cb, s);
    }
}

KINLINE void Widget_Null_Id(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_Null(field);
    }
}

KINLINE void Widget_Clr_Id(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Id;
        KString_Clr(field);
    }
}

KINLINE void Widget_SetString_Color(
    Widget* self,
    CMPIString* x)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Color;
        KString_SetString(field, x);
    }
}

KINLINE void Widget_Set_Color(
    Widget* self,
    const char* s)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Color;
        KString_Set(field, self->__base.cb, s);
    }
}

KINLINE void Widget_Null_Color(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Color;
        KString_Null(field);
    }
}

KINLINE void Widget_Clr_Color(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KString* field = (KString*)&self->Color;
        KString_Clr(field);
    }
}

KINLINE void Widget_Set_Size(
    Widget* self,
    CMPIUint32 x)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KUint32* field = (KUint32*)&self->Size;
        KUint32_Set(field, x);
    }
}

KINLINE void Widget_Null_Size(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KUint32* field = (KUint32*)&self->Size;
        KUint32_Null(field);
    }
}

KINLINE void Widget_Clr_Size(
    Widget* self)
{
    if (self && self->__base.magic == KMAGIC)
    {
        KUint32* field = (KUint32*)&self->Size;
        KUint32_Clr(field);
    }
}

/* classname=KC_Widget */
typedef struct _Widget_Add_Args
{
    KBase __base;
    /* IN */
    KUint32 X;
    /* IN */
    KUint32 Y;
}
Widget_Add_Args;

static const unsigned char __Widget_Add_Args_sig[] =
{
    0x03,0x41,0x64,0x64,0x00,0x02,0x25,0x01,0x58,0x00,0x25,0x01,0x59,0x00,
};

KINLINE void Widget_Add_Args_Init(
    Widget_Add_Args* self,
    const CMPIBroker* cb)
{
    const unsigned char* sig = __Widget_Add_Args_sig;
    KBase_Init(&self->__base, cb, sizeof(*self), sig, NULL);
}

KINLINE CMPIStatus Widget_Add_Args_InitFromArgs(
    Widget_Add_Args* self,
    const CMPIBroker* cb,
    const CMPIArgs* x,
    CMPIBoolean in,
    CMPIBoolean out)
{
    Widget_Add_Args_Init(self, cb);
    return KBase_FromArgs(&self->__base, x, in, out);
}

KINLINE CMPIArgs* Widget_Add_Args_ToArgs(
    const Widget_Add_Args* self,
    CMPIBoolean in,
    CMPIBoolean out,
    CMPIStatus* status)
{
    return KBase_ToArgs(&self->__base, in, out, status);
}

KINLINE CMPIStatus Widget_Add_Args_SetArgs(
    const Widget_Add_Args* self,
    CMPIBoolean in,
    CMPIBoolean out,
    CMPIArgs* ca)
{
    return KBase_SetToArgs(&self->__base, in, out, ca);
}

KINLINE void Widget_Add_Args_Print(
    const Widget_Add_Args* self,
    FILE* os)
{
    KBase_Print(os, &self->__base, 'a');
}

/*
**==============================================================================
**
** Widget methods
**
**==============================================================================
*/

KEXTERN KUint32 Widget_Add(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* context,
    const KUint32* X,
    const KUint32* Y,
    CMPIStatus* status);

KINLINE CMPIStatus Widget_DispatchMethod(
    const CMPIBroker* cb,
    CMPIMethodMI* mi,
    const CMPIContext* cc,
    const CMPIResult* cr,
    const CMPIObjectPath* cop,
    const char* meth,
    const CMPIArgs* in,
    CMPIArgs* out)
{
    WidgetRef self;

    KReturnIf(WidgetRef_InitFromObjectPath(&self, cb, cop));

    if (strcasecmp(meth, "Add") == 0)
    {
        CMPIStatus st = KSTATUS_INIT;
        Widget_Add_Args args;
        KUint32 r;

        KReturnIf(Widget_Add_Args_InitFromArgs(
            &args, cb, in, 1, 0));

        r = Widget_Add(
            cb,
            mi,
            cc,
            &args.X,
            &args.Y,
            &st);

        if (!KOkay(st))
            return st;

        if (!r.exists)
            KReturn(ERR_FAILED);

        KReturnIf(Widget_Add_Args_SetArgs(
            &args, 0, 1, out));
        KReturnUint32Data(cr, &r);
        CMReturnDone(cr);

        KReturn(OK);
    }

    KReturn(ERR_METHOD_NOT_FOUND);
}

#define Widget_ClassName "KC_Widget"

#endif /* _konkrete_Widget_h */
