Menu

How to use inherited methods in the new dispatcher?

2017-06-29
2017-06-29
  • Ivan Stepanov

    Ivan Stepanov - 2017-06-29

    Hi all,

    Currently I use owlnext 6.44, VS 2015

    Question about new dispatch solution. How to use inherited methods in the new dispatcher?
    For example, I have code like this, which was valid before :

    class TDlgText: public owl::TDialog
    {
      public:
    ...
        virtual void CmClear() {...}
        virtual void EvDestroy() {...}
    
      DECLARE_RESPONSE_TABLE(TDlgText);
    };
    //---
    class TByFormulaDlg: public TDlgText
    {
    ...
      DECLARE_RESPONSE_TABLE(TByFormulaDlg);
    };
    //---
    DEFINE_RESPONSE_TABLE1(TByFormulaDlg, TDlgText)
    ...
      EV_COMMAND( IDB_Clear,    CmClear),
    ...
      EV_WM_DESTROY,
    ...
    END_RESPONSE_TABLE;
    //---
    


    Now I got errors for both inherited methods:

    1> ...\d_refer.cpp(1108): error C2568: ',': unable to resolve function overload
    1> ...\d_refer.cpp(1108): note: could be 'owl::TResult owl::TDispatchCommand<273>::Decode(void *,owl::TParam1,owl::TParam2)'
    1> ...\d_refer.cpp(1112): error C2568: ',': unable to resolve function overload
    1> ...\d_refer.cpp(1112): note: could be 'owl::TResult owl::TDispatch<2>::Decode(void *,owl::TParam1,owl::TParam2)'
    


    Of course, I can redefine methods in derived class. Is there an option without overriding?

    Best,
    Ivan Stepanov


    Moderator: Formatted code.

     

    Last edit: Vidar Hasfjord 2017-06-29
  • Vidar Hasfjord

    Vidar Hasfjord - 2017-06-29

    Hi Ivan,

    This issue in 6.40, i.e. the new requirement for event handlers to be defined within the class owning the response table, is described in Upgrading from OWL | Changes in OWLNext | Message dispatch overhaul and in FAQ | "I get response table errors. Has something changed.". Like you suggest, you can resolve it by redefining the handler.

    Is there an option without overriding?

    Yes. You can give TDlgText a response table entry for the handler and remove the corresponding response table entry from TByFormulaDlg. An entry in the derived class is only necessary if you need to override functionality, or when you have multiple base classes and need to forward the dispatch to the correct base.

     
  • Ivan Stepanov

    Ivan Stepanov - 2017-06-29

    Hi Vidar,

    Thanks a lot.

     
  • Ognyan Chernokozhev

    Hi, Ivan,

    In a large project I am converting to OWLNext 6.4 there were quite a few places where I needed to forward the message handling to a particular base class (case with mutliple inheritance for example)

    So I wrote some new macros like these:

    #define OWL_DISPATCH_EX(dispatch, cls, method)\
      &dispatch<cls, &cls::method > 
    
    #define EV_MESSAGE_EX(message, cls, method)\
      {{message}, 0, OWL_DISPATCH_EX(::owl::DispatchRawArguments, cls, method)}
    
    #define OWL_ID_EV_EX(msgId, id, cls, method)\
      {{msgId}, id, OWL_DISPATCH_EX(::owl::TDispatch<msgId>::Decode, cls, method)}
    
    #define OWL_EV_EX(msgId, cls, method) OWL_ID_EV_EX(msgId, 0, cls, method)
    
    #define EV_WM_SIZE_EX(cls) OWL_EV_EX(WM_SIZE, cls, EvSize)
    
    #define EV_COMMAND_EX(id, cls, method) {{0}, id, OWL_DISPATCH_EX(::owl::DispatchCommand, cls, method)}
    

    Jogy

     

Anonymous
Anonymous

Add attachments
Cancel