Notification with Data. More...
#include <rnotification.h>
Inheritance diagram for RNotificationData< T >:
Collaboration diagram for RNotificationData< T >:
Public Member Functions | |
RNotificationData (const RCString &name, RObject *sender, T data) | |
RNotificationData (hNotification handle, RObject *sender, T data) | |
T | Get (void) const |
Public Member Functions inherited from RNotification | |
RNotification (const RCString &name, RObject *sender) | |
RNotification (const hNotification handle, RObject *sender) | |
RCString | GetName (void) const |
hNotification | GetHandle (void) const |
RObject * | GetSender (void) const |
RObject * | GetReceiver (void) const |
virtual | ~RNotification (void) |
Private Attributes | |
T | Data |
Detailed Description
template<class T>
class R::RNotificationData< T >
Notification with Data.
The RNotificationData provides a representation for a notification that can be send by an object with a specific data.
- Template Parameters
-
T Type of the parameter.
The type used for template is very important. For example, the following code generates an exception since the default type of 3 is int:
class MyObject : public RObject
{
public:
MyObject(const RString& name) : RObject(name)
{
InsertObserver(HANDLER(MyObject::Handle),"Example");
}
virtual RCString GetClassName(void) const {return("MyObject");}
{
cout<<"From "<<notification.GetName()<<" : "<<GetData<long>(msg)<<endl;
}
};
int main(int argc, char *argv[])
{
MyObject Obj1("Object 1");
MyObject Obj2("Object 2");
}
To be sure that PostNotification calls the right handlers, it is always better to explicitly cast the parameter when sending.
Constructor & Destructor Documentation
RNotificationData | ( | const RCString & | name, |
RObject * | sender, | ||
T | data | ||
) |
Constructor of a notification.
- Parameters
-
name Name of the notification. sender Object sending the notification. data Data associated.
RNotificationData | ( | hNotification | handle, |
RObject * | sender, | ||
T | data | ||
) |
Constructor of a notification.
- Parameters
-
handle Handle of the notification. sender Object sending the notification. data Data associated.
Member Function Documentation
T Get | ( | void | ) | const |
Get the data of the notification.
Field Documentation
|
private |
Data associated with the notification.