#include <Slot.h>

Public Member Functions | |
| Slot () | |
| template<class T, typename Method> | |
| Slot (T *pT, Method pMethod) | |
| Slot (const Slot &slot) | |
| Slot & | operator= (const Slot &rhs) |
| bool | isValid () const |
| void | update (Subject &subject, const std::string &signal, const boost::any &data) const |
| void | callAttachMethod (Subject &subject, const std::string &signal) const |
| void | callDetachMethod (Subject &subject, const std::string &signal) const |
| bool | operator== (const Slot &rhs) const |
| const std::type_info & | getType () const |
| ~Slot () | |
Protected Attributes | |
| SlotWrapper * | mpSlot |
Classes | |
| class | SlotValue |
| class | SlotWrapper |
| This class provides an abstract interface that implements the details of the slot and hides the type information behind a generic interface. More... | |
Typically, only the constructors of this class will be used outside of the underlying implementation of the Subject class.
When a Subject calls 'notify' with a particular signal name, all slots that are attached to that signal on the Subject will have their update method called. The slot's update method will in turn call the method on the object provided via the slot's constructor. Slot methods need to have the following signature:
void T::method(Subject &subject, const std::string &signal, const boost::any &v);
When called, the arguments will be as follows: subject: the Subject notifying with the signal signal: the name of the signal the Subject notified v: data provided to the notify method by the Subject
When a Slot is attached to a signal on a Subject, if the slot method is on an object derived from Observer, the object's attached method will be called. Similarly, when a Slot is detached from an object derived from Observer, the object's detached method will be called.
Definition at line 59 of file Slot.h.
| Slot::Slot | ( | ) |
| Slot::Slot | ( | T * | pT, | |
| Method | pMethod | |||
| ) |
Creates a slot.
Creates a slot. Assuming neither of the input arguments is NULL, the Slot will return true from isValid and will test equal to other Slots created with the same arguments.
| pT | The object to call in Slot::update. | |
| pMethod | The method to call on the object in Slot::update. The method should not be virtual. Virtual slot methods may cause Subject::detach to fail. If a virtual slot is needed, make the slot method non-virtual and have it call a virtual method. On notify, the slot method will be called as follows: (pT->*pMethod)(subject, signal, v); T::method(Subject &subject, const std::string &signal, const boost::any &v); |
| Slot::Slot | ( | const Slot & | slot | ) |
| bool Slot::isValid | ( | ) | const |
| void Slot::update | ( | Subject & | subject, | |
| const std::string & | signal, | |||
| const boost::any & | data | |||
| ) | const |
| void Slot::callAttachMethod | ( | Subject & | subject, | |
| const std::string & | signal | |||
| ) | const |
Calls the attached method on the observer, if it derives from Observer.
This method is typically only called by Subject::attach.
| subject | The Subject that the slot is being attached to. | |
| signal | The name of the signal the Slot is being attached to. |
| void Slot::callDetachMethod | ( | Subject & | subject, | |
| const std::string & | signal | |||
| ) | const |
Calls the detached method on the observer, if it derives from Observer.
This method is typically only called by Subject::detach.
| subject | The Subject that the slot is being detached from. | |
| signal | The name of the signal the Slot is being detached from. |
| bool Slot::operator== | ( | const Slot & | rhs | ) | const |
| const std::type_info& Slot::getType | ( | ) | const |
SlotWrapper* Slot::mpSlot [protected] |