The MV(C) paradigm: the view class

This demonstates a Model/View example based on a simple counter. See "Principles of Object-Oriented Sostware Development" by Anton Eliens, page 237.

jrvosse@cs.vu.nl
  #ifndef _VIEW_H_
  #define _VIEW_H_


  #include<hush/event.h>
  #include<widgets/label.h>

  #include model.h

  class view: public label {
  public:
    view(const counter* c, const widget* w, const char* path, const char* opt="")
      :_model(c), label(w, path, opt) {}
    int operator()() {
      const int argc = _event->argc();
      if (argc == 1 && _event->arg(0) == "counter") {
          text(_model->value());  // update text of label
          tk->update();           // update screen
      }
    }
  private:
    const counter* _model;
  };

  #endif