123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- #ifndef _ATTRCB_H
- #define _ATTRCB_H
- #include "attribute.h"
- class AttrCallback {
- public:
-
- virtual ~AttrCallback() {}
-
-
- virtual void onValueChange(Attribute *attr)=0;
- };
- class int_attrCB : public AttrCallback {
- typedef void (*fnPtrType)(int);
- public:
-
- int_attrCB(fnPtrType _fn) { fnptr = _fn; }
-
-
- virtual void onValueChange(Attribute *attr) {
- ASSERT(attr->getAttributeType() == AttributeType::INT ||
- attr->getAttributeType() == AttributeType::BOOL);
- (*fnptr)(attr->getValueAsInt());
- }
- private:
- fnPtrType fnptr;
- };
- class string_attrCB : public AttrCallback {
- typedef void (*fnPtrType)(const wchar_t *);
- public:
-
- string_attrCB(fnPtrType _fn) { fnptr = _fn; }
-
-
- virtual void onValueChange(Attribute *attr)
- {
- ASSERT(attr->getAttributeType() == AttributeType::STRING);
- (*fnptr)(attr->getAttributeName());
- }
- private:
- fnPtrType fnptr;
- };
- #endif
|