Tanguy Krotoff wrote:

Vadim Lebedev wrote:

I'd suggest to have a Presentation laye subsribe to Control layer events..... This way when new call is created the presentatution layer which want to be notifed about it will subscribe to call object creation event. Then the PL's Call Object will subscrive to CallState chanes events for trhe Control Layr CallState objects This way the Control Layer will not need to manage explcitly multiple Presentation layers.. which is always better


Something like this I if understand well:

class CWengoPhone {
  static Event<CWengoPhone & sender> createdEvent;

  CWengoPhone () {
    createdEvent(*this);
  }
  ...
};

class CPhoneCall {
  static Event<CPhoneCall & sender> createdEvent;

  CPhoneCall() {
    createdEvent(*this);
  }
  ...
};

main() {
  new QtFactory();
  new DBusFactory();
  ...
}

class QtFactory : public PFactory {
  QtFactory() {
    CWengoPhone::createdEvent += createPWengoPhone();
    CPhoneCall::createdEvent += createPPhoneCall();
  }

  virtual void createPWengoPhone(CWengoPhone & cWengoPhone) {
    _qtWengoPhone = new QtWengoPhone(cWengoPhone);
  }

  virtual void createPPhoneCall(CPhoneCall & cPhoneCall) {
    _qtPhoneCall = new QtPhoneCall(cPhoneCall, _qtWengoPhone);
  }

  virtual postEvent(ThreadEvent * event) {
    ...
  }
  ...
};

So no more PPhoneCall, PWengoPhone...
Code inside main() can be improved by loading factories dynamically

2 problems
- Events (boost::bind) everywhere in the presentation layer!

This is not big problem IMO, but if you really wish it could be easily Avoided with following Idiom:

class CWengoPhone {
 static Event<CWengoPhone & sender> createdEvent;

 CWengoPhone () {
   createdEvent(*this);
 }

static void hookCreatedEvent(void *p, void (*pfnCreatedEvent)(void *p, CWengoPhone &sender));
 ...
};


class QtFactory : public PFactory {
 QtFactory() {
   CWengoPhone::hookCreatedEvent(this, onCreateWengoPhone);
 }


 static void onCreateWengoPhone(void *p,  CWengoPhone & cWengoPhone)
{
    ((QTFactory *)p)->createPWengoPhone(cWengoPhone)
}
}



- how do you manage thread-safety?? It should be handled inside the control layer thus your need to call PFactory::postEvent(). This means you need a
MultiFactory::postEvent() {
  foreach i in _list {
    _list[i]->postEvent();
  }
}
I don't see how to handle the tread-safety problem from the control layer...

I don't see any issue with thread safety....
Let's make a mental experiment:
Assume we don't have problems wth PL thread safety, so the only problem to fix is thread safety in CL... How do you do it now? with postEvent? if so continue to do it.

Now come back to PL... In case of QT we need to translate all event in QT events anyway and QT
do handle thread safety issues as far as i know... or doesn't it?


Vadim






_______________________________________________
Wengophone-devel mailing list
[email protected]
http://dev.openwengo.com/mailman/listinfo/wengophone-devel

Reply via email to