c++ - MVP Passive View approach with FLTK -


i have basic problem, trying use fltk mvp passive view described here. managed it, doesn´t feel right way i´m doing it.

i´m having fl_window, containing widgets , fl_gl_window opengl functionality. know, can add widgets , stuff fl_window between begin() , end(). , seems have instantiate when add directly in between these calls, got that:

(please @ small "story" in comments beside code, because explains i´m doing , want know if fine in case, or maybe can point me way better solution, because feels wrong.)

main.cpp

int main(/*arguments*/) {     model* model = new model();     ipresenter* presenter = new presenter(model); //presenter knows model @ point     iview* view = new view(presenter);           //view gets reference presenter... } 

view.h

class view : public fl_window { public:     view(ipresenter* presenter);     virtual ~view(); private:     iview* gl_window;     ipresenter* presenter; }; 

view.cpp

view::view(ipresenter* presenter) :fl_window(/*arguments*/) {     this->presenter = presenter;     begin();     //add widgets     gl_window = new glwindow(this->presenter,/*more arguments*/); //...instantiates glwindow , passes received reference it...     end();     show();     fl::run(); } 

glwindow.h

glwindow::glwindow(ipresenter* presenter, /* more arguments*/) :     fl_gl_window(/*arguments*/), iview() {     //initialisations     this->presenter = presenter;      //...which glwindow uses communication and...     this->presenter->setview(this);   //...to set reference presenter                                       //same view } 

ipresenter.h

class iview;   //forward declaration because ipresenter includes iview , vice versa  class ipresenter { public:     //pure virtual methods }; 

iview.h looks same ipresenter.h.

because want mvp, both windows views (one view containing another). every view needs communicate presenter , shown in sequence diagram fowler, view needs hold reference presenter , vice versa. used forward declaration in interface headers.

as mentioned, want know, if there better way this. maybe it´s somehow possible add fl_gl_window without having instantiate @ point. or maybe mvp passive view approach incorrect.

i hope explanation understandable. in advance help!


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -