Maptitude GISDK Help

Virtual Properties

Regular properties are declared on GISDK objects by using the dot notation in GISDK classes. Once a property is declared on an object then client code outside the class can get and set the value of the property using the dot notation. For example:

 

Class "MyClass"

   init do

      self.Value = 5

      endItem

endClass

 

object = CreateObject("MyClass")

currentValue = object.Value

object.Value = 6

 

With the new functionality, virtual properties for objects can be defined by providing getter and/or setter methods in the class according to the following specification.

 

A method named according to the pattern _GetPropertyName will allow the value of the property to be queried by clients of the object using regular dot notation:

 

value = object.PropertyName

 

A method named according to the pattern _SetPropertyName(value) will allow the value of the property to be assigned by clients of the object using regular dot notation:

 

object.PropertyName = value

 

Reasons to expose properties in this way include allowing properties to be exposed for computed values and allowing code to be executed for the object when the value of a property is changed. For example:

 

class "Person" (firstName, lastName)

   init do

      self.FirstName = firstName

      self.LastName = lastName

      endItem

 

   Macro "_GetFullName" do

      Return(self.FirstName + " " + self.LastName

      endItem

 

   Macro "_SetFullName" (fullName) do

      parts = ParseString(fullName, " ")

      if parts.length = 2 then do

         self.FirstName = parts[1]

         self.LastName = parts[2]

         end

      endItem

endClass

 

person = CreateObject("Person", "John", "Doe")

name = person.FullName

//name == "John Doe"

person.FullName = "David Smith"

 

 

©2025 Caliper Corporation www.caliper.com