#pragma once
#include "IxWidget.h"
#include "QxOrm.h"

#include <memory>
#include <qwidget.h>


class IxWidgetFactory
{
public:
    IxWidgetFactory() = default;

    virtual ~IxWidgetFactory() = default;

    virtual void create(qx::IxDataMember *dataMember, QWidget *parent) = 0;

    virtual QString type() const = 0;

    virtual QWidget* getWidget() const = 0;

    virtual IxWidget* getIxWidget() const = 0;

    qx::any invokeStatic(const qx::IxDataMember *dataMember, const QString &method, const QString &param = QString())
    {
        qx::IxFunctionX *funcs = dataMember->getParent()->getClass()->getFctStaticX();
        qx::any any;
        if (funcs->exist(method))
        {
            funcs->getByKey(method)->invoke(param, &any);
        }
        return any;
    }
};
typedef std::shared_ptr<IxWidgetFactory>  IxWidgetFactory_ptr;
