Results 1 to 4 of 4

Thread: Return Something to Signal Caller

  1. #1
    Serf
    Join Date
    Mar 2008
    Posts
    4

    Default Return Something to Signal Caller

    Maybe I missed it while looking through the docs but is there a way to return values from the slot calls back to the signal sender?

    Example:

    void signalcaller() {
    result = signalcall(stuff)
    }

    on_signal_call(stuff) {
    do stuff
    return result
    }

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    A signal can have multiple slots connected to it, so its by design difficult to return values.

  3. #3
    Serf
    Join Date
    Mar 2008
    Posts
    4

    Default

    Yup, I figured. I can't remember what library I was using, or even what language (Though I would swear it was c++) that returned a map object that used an ID number as the index and connected to a Result object. I was just hoping Clanlib had a similar, if undocumented, system.

    Thanks for the help.

  4. #4
    Master Sorcerer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    ClanLib's signals do not support return values. However, you can effectively do the same by passing parameters by reference. For example, if you want your map with ids:

    std::map<std::string, bool> return_values;
    signal->invoke(return_values);
    examine_return_values(return_values);

    slot function:

    void SomeClass::some_slot(std::map<int, bool> &out_result)
    {
    out_result["SomeClass"] = true;
    }

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •