Notification with Data. More...

#include <rnotification.h>

Inheritance diagram for RNotificationData< T >:
[legend]
Collaboration diagram for RNotificationData< T >:
[legend]

Public Member Functions

 RNotificationData (const RCString &name, RObject *sender, T data)
 
 RNotificationData (hNotification handle, RObject *sender, T data)
 
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
 
RObjectGetSender (void) const
 
RObjectGetReceiver (void) const
 
virtual ~RNotification (void)
 

Private Attributes

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
TType 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");}
void Handle(const RNotification& notification)
{
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,
data 
)

Constructor of a notification.

Parameters
nameName of the notification.
senderObject sending the notification.
dataData associated.
RNotificationData ( hNotification  handle,
RObject sender,
data 
)

Constructor of a notification.

Parameters
handleHandle of the notification.
senderObject sending the notification.
dataData associated.

Member Function Documentation

T Get ( void  ) const

Get the data of the notification.

Field Documentation

T Data
private

Data associated with the notification.