class Core::Portable::ViewBuilder

Overview

Build view tree from JSON files. More…

#include <coreviewbuilder.h>

class ViewBuilder: public Core::Portable::StaticSingleton
{
public:
    // typedefs

    typedef View* (*CreateViewFunc)();

    // structs

    struct AttributeModifier;
    struct ViewClass;
    struct ViewDescriptor;

    // fields

    Vector<ViewClass> classes;
    Vector<ViewDescriptor> descriptors;
    int delegateClassIndex;
    ViewController* currentController;

    // methods

    void addClass(CStringPtr name, CreateViewFunc createFunc);

    template <class Type>
    void addClass(CStringPtr name);

    int loadViews(FilePackage& package);
    void removeAll();
    const Attributes* findViewAttributes(CStringPtr name) const;
    View* createView(CStringPtr name, ViewController* controller) const;
    bool buildView(View& view, CStringPtr name, ViewController* controller) const;
    ViewController* getCurrentController() const;
    DEFINE_OBSERVER(ViewBuilderObserver);

    void preprocessViewAttributes(
        Attributes& viewAttributes,
        AttributeValue* viewValue
    );

    int getViewClassIndex(CStringPtr name) const;
    View* createViewInstance(int classIndex) const;
    const ViewDescriptor* findDescriptor(CStringPtr name) const;

    void buildView(
        View& view,
        const Attributes& data,
        ViewController* controller,
        AttributeModifier* modifier
    ) const;

    View* createSubView(
        CStringPtr name,
        const Attributes& outer,
        ViewController* controller,
        AttributeModifier* modifier
    ) const;
};

Inherited Members

public:
    // methods

    static T& instance();
    DeletableList& instance();

Detailed Documentation

Build view tree from JSON files.

Methods

void addClass(CStringPtr name, CreateViewFunc createFunc)

Register view class.

template <class Type>
void addClass(CStringPtr name)

Register view class.

int loadViews(FilePackage& package)

Load views from package defined in ‘views.json/.ubj’ file.

void removeAll()

Remove all loaded view descriptors.

const Attributes* findViewAttributes(CStringPtr name) const

Find view description by name.

View* createView(CStringPtr name, ViewController* controller) const

Create view by name.

bool buildView(View& view, CStringPtr name, ViewController* controller) const

Build view by name, use if outer view already exists.

ViewController* getCurrentController() const

Access to controller currently being used in buildView().