Boost logo

Boost Users :

Subject: [Boost-users] Change return type automatically
From: Surya Kiran Gullapalli (suryakiran.gullapalli_at_[hidden])
Date: 2009-10-26 20:51:10


Hello,

I've a class with multiple boost signals like this

class A
{
   private:
      boost::signal<void()> m_voidSignal ;
      boost::signal<void (const string&)> m_stringSignal ;
   public:
      boost::signal<void()>& voidSignal() { return m_voidSignal ; }
      boost::signal<void (const string&)>& stringSignal { return
m_stringSignal ; }
} ;

when i'm connecting signals to slots, I do some thing like this.

A a;
a.voidSignal().connect (...) ;

This works fine. But I've many signals with different signatures. what I
want to achieve is a single interface where I want to map every signal to
enums and access signal from the enums like this.

class A
{
   public:
      typedef enum {
         VoidSignal, StringSignal ... } ; SignalIds ;

      // return type should be deducted automatically from the enum
         ReturnType& getSignal (SignalId) ;
...
} ;

So that I can do some thing like this

A a;
a.getSignal (A::VoidSignal).connect (...) ;
a.getSignal (A::StringSignal).connect (...) ;

Basically with a single interface, I want to change the return type
automatically. Can I achieve something like this with any of the boost
libraries (mpl, fusion etc) ? Any pointers on this would be of great help.

Thanks,
Surya



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