Boost logo

Boost Users :

Subject: Re: [Boost-users] [dataflow] Filter with multiple slots
From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-09-10 12:03:09


On Wed, Sep 10, 2008 at 6:29 AM, Manuel Jung <gzahl_at_[hidden]> wrote:
> Hey,
>
> I want to define my own filter, which can take different signatures. It
> should take a Url (e.g. std::string, for me an unicode type) and use a
> difault timeout or it should take both.
>
> There is an tutorial for multiple slots, when using a consumer, but i need a
> filter and i am wondering how i should define the signature of the filter
> then? (overlaoding of the operator() method needs to be done of course.
>

If your filter still has only a single output, it would be like this:

class multi_input_filter
     : public signals::filter<
        multi_input_filter,
        // output signature
        void (const output_type &)>
{
public:
    void operator()(const std::string &url);
    void operator()(const std::string &url, double timeout);
};

If you want to enumerate the inputs (which is needed for using some
run-time aspects of the library, but otherwise not needed), then you
can do that like this:

class multi_input_filter
     : public signals::filter<
        multi_input_filter,
        // output signature
        void (const output_type &),
        // input signatures
        mpl::vector<void(const std::string &), void(const std::string
&, double)>
{
 //...same
};

Does that help?

Stjepan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net