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 / Creating Static Methods

IDL

Creating Static Methods

Creating Static Methods

IDL object classes can have both instance methods and static methods.

When you create a method on a class, by default the method is an "instance" method. Instance methods can only be called on an actual "instance" of that class. Within an instance method, you have access to the self variable and the object's instance data.

However, you can also mark a method as "static" by using the compile_opt static directive at the top of the routine. When a static method is called, the normal object lifecycle is bypassed: the ::Init and ::Cleanup methods are not called, and the self variable will be set to a null object.

Note: Marking a method as "static" just means that you are allowed to call that method as a static method. You can also call the same method on an instance of that object. In that case, just like any other object, the self variable will be defined and will contain the object's instance data. If a method is not marked with the compile_opt static directive , then trying to call it as a static method will result in a runtime error.

Terminology: The term "static method" refers to a method on an IDL object class that can be called on the class itself. The term "static class method" refers to a method on one of IDL's built-in data types.

Defining Static Methods


Static method routines are defined in the same way as other IDL methods, with the addition of the compile_opt static directive. For example:

PRO ClassName::Method, Arg1, Arg2, Keyword=kw
  compile_opt idl2, static
  IDL statements...
END

or

FUNCTION ClassName::Method, Arg1, Arg2, , Keyword=kw
  compile_opt idl2, static
  IDL statements...
  RETURN, value
END

See Also


Static Methods and Properties     



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