Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / Using IDL / Replicating Non-Overloaded Behavior in Overloaded Operator Methods

IDL

Replicating Non-Overloaded Behavior in Overloaded Operator Methods

Replicating Non-Overloaded Behavior in Overloaded Operator Methods

The IDL_Object class includes standard object methods that implement default behavior for each operator that may be overloaded. These default methods are included to simplify your overload method code, and you are free to call them inside your operator overload method.

For example, imagine that you are overloading the relational equal (EQ) operator for your object. Under certain conditions the operator will behave in a custom manner, and the rest of the time the operator will simply test for equality. While you must implement the local object’s _overloadEQ method for the custom behavior, you could simply call the inherited IDL_Object::_overloadEQ method to handle generic equality.

Note: If your object subclasses from IDL_Object, but you don’t add a custom operator overload method for a given operator, the operator’s default method will be invoked.

For example, suppose you want custom behavior for the EQ operator only if both of the operands are instances of the overloaded class. Your class’ _overloadEQ method might contain code that looks like this:

IF OBJ_ISA(Left,'myClass') && OBJ_ISA(Right,'myClass') THEN BEGIN
... custom behavior here ...
ENDIF ELSE BEGIN
   RETURN, IDL_Object::_overloadEQ(Left, Right)
ENDELSE

Here Left and Right are the two operands passed to the EQ operator. If both are instances of the class myClass, the custom behavior is invoked. If one of the operands is not an instance of the class myClass, then the default behavior is invoked by explicitly calling the superclass (IDL_Object) _overloadEQ method.



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us