rwlogo
Rogue Wave Views 5.5.1

Rogue Wave Views
Data Access Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IliPointerTypeClass Class Reference

User interface class. More...

#include <ilviews/dataccess/datatype.h>

Inheritance diagram for IliPointerTypeClass:
IliDatatype IliRefCounted

List of all members.

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.

Detailed Description

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:

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;
 }

Constructor & Destructor Documentation

IliPointerTypeClass::IliPointerTypeClass ( const char *  name  )  [protected]

Constructs an IliPointerTypeClass data type.

Parameters:
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.

Member Function Documentation

virtual IlAny IliPointerTypeClass::lockAny ( IlAny  a  )  const [protected, virtual]

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:

  • Increment a reference count related to the object and return any itself.
  • Return a copy of any.

If the object is NULL, this member function should return NULL.

Parameters:
any A pointer to an object managed by this data type or NULL .
Returns:
The object or 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:

  • Decrement a reference count related to the object.
  • Delete the object.
Parameters:
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.