Rogue Wave Views 5.5.1 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
User interface class. More...
#include <ilviews/dataccess/datatype.h>
Protected Member Functions | |
IliPointerTypeClass (const char *name) | |
Constructs an IliPointerTypeClass data type. | |
virtual IlAny | lockAny (IlAny a) const |
Increments a reference count related to an object. | |
virtual void | unLockAny (IlAny) const |
Decrements a reference count related to an object. |
User interface class.
Library: dataccess
The IliPointerTypeClass
class can serve as a base class to implement custom data types. It works in conjunction with the IliValue::asAny
and IliValue::importAny
member functions. A custom data type manages objects of a given C++ type through IliValue
objects. Internally, the managed objects are represented as void
pointers by way of IlAny
. The lockAny
and unLockAny
member functions provide the conversion between IlAny
and the appropriate type and manage the object lifetime. A data type can specify what happens when an IliValue
object is copied into another object. One of the following can occur:
IliValue
objects. IliValue
object. The following example shows how the sharing policy can be implemented:
class BitmapTypeClass : public IliPointerTypeClass { public: BitmapTypeClass() : IliPointerTypeClass("MyBitmapType") { doRegister(); } virtual IlAny lockAny(IlAny any) const { IlvBitmap* bmp = (IlvBitmap*)any; if (bmp) bmp->lock(); return bmp; } virtual void unLockAny(IlAny any) const { IlvBitmap* bmp = (IlvBitmap*)any; if (bmp) bmp->unLock(); } }; BitmapTypeClass* BitmapType = new BitmapTypeClass(); IliValue toIliValue(IlvBitmap* bmp) { IliValue value(BitmapType); value.importAny(bmp); } IlvBitmap* toIlvBitmap(const IliValue& value) { if (value.getType() == BitmapType) return (IlvBitmap*)value.asAny(); return NULL; }
The following example shows how the copy policy can be implemented:
class RectTypeClass : public IliPointerTypeClass { public: RectTypeClass() : IliPointerTypeClass("MyRectType") { doRegister(); } virtual IlAny lockAny(IlAny any) const { IlvRect* pRect = (IlvRect*)any; if (pRect) return new IlvRect(*pRect); return NULL; } virtual void unLockAny(IlAny any) const { IlvRect* pRect = (IlvRect*)any; } }; RectTypeClass* RectType = new RectTypeClass(); IliValue toIliValue(const IlvRect& rect) { IliValue value(RectType); value.importAny(&rect); return value; } IlvRect toIlvRect(const IliValue& value) { if (value.getType() == RectType) return (IlvRect*)value.asAny(); return NULL; }
IliPointerTypeClass::IliPointerTypeClass | ( | const char * | name | ) | [protected] |
Constructs an IliPointerTypeClass
data type.
name | If the name is unique among all registered data types, it is possible to call IliDatatype::doRegister during construction to make the data type instance visible through IliDatatype::GetDatatypeByName and IliDatatype::GetDatatypeByPrettyName . |
Increments a reference count related to an object.
Depending on the sharing policy of the data type, this virtual member function should do one of the following:
any
itself. any
. If the object is NULL
, this member function should return NULL
.
any | A pointer to an object managed by this data type or NULL . |
NULL
. virtual void IliPointerTypeClass::unLockAny | ( | IlAny | ) | const [protected, virtual] |
Decrements a reference count related to an object.
Depending on the sharing policy of this data type, this virtual member function should do one of the following:
any | A pointer to an object managed by this data type. |
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.