pygplates.PropertyValueVisitor

class pygplates.PropertyValueVisitor

Bases: Boost.Python.instance

The base class inherited by all derived property value visitor classes. A property value visitor is used to visit a property value and discover its derived property value class type. Note that there is no common interface shared by all property value types, hence the visitor pattern provides one way to find out which type of property value is being visited. A property value instance is visited by passing an instance of a visitor to the property value’s PropertyValue.accept_visitor() method. Typically you create your own class that inherits from PropertyValueVisitor and implement some of the visit methods. All visit methods default to doing nothing.

The following example demonstrates how to implement a simple visitor class by inheriting PropertyValueVisitor and implementing only those visit methods related to the GpmlPlateId property value type (note that plate ids can be time-dependent in some contexts so we also use GpmlConstantValue in case the plate id property value is wrapped in a constant value wrapper). This example retrieves the integer plate id from a (possibly nested) GpmlPlateId property value, or None if the visited property value is of a different type.
class GetPlateIdVisitor(pygplates.PropertyValueVisitor):
    def __init__(self):
        # NOTE: You must call base class '__init__' otherwise you will
        # get a 'Boost.Python.ArgumentError' exception.
        super(GetPlateIdVisitor, self).__init__()
        self.plate_id = None

    # Returns the plate id from the visited GpmlPlateId property value,
    # or None if property value was a different type.
    def get_plate_id(self):
        return self.plate_id

    def visit_gpml_constant_value(self, gpml_constant_value):
        # Visit the GpmlConstantValue's nested property value.
        gpml_constant_value.get_value().accept_visitor(self)

    def visit_gpml_plate_id(self, gpml_plate_id):
        self.plate_id = gpml_plate_id.get_plate_id()

# Visitor can extract plate id from this...
property_value1 = pygplates.GpmlPlateId(701)
# Visitor cannot extract plate id from this...
property_value2 = pygplates.XsInteger(701)

plate_id_visitor = GetPlateIdVisitor()
property_value1.accept_visitor(plate_id_visitor)
plate_id = plate_id_visitor.get_plate_id()

# If we found a 'GpmlPlateId' then print its plate id.
if plate_id is not None:
    print 'plate id: %d' % plate_id

Warning

You must call the base class __init__ method otherwise you will get a Boost.Python.ArgumentError exception. Note that if you do not define an __init__ method in your derived class then Python will call the base class __init__ (so you don’t have to do anything). However if you do define __init__ in your derived class then it must explicitly call the base class __init__.

__init__()

Default constructor - must be explicitly called by derived class.

Methods

__init__()

Default constructor - must be explicitly called by derived class.

visit_enumeration(enumeration)

Visits a Enumeration property value.

visit_gml_data_block(gml_data_block)

Visits a GmlDataBlock property value.

visit_gml_line_string(gml_line_string)

Visits a GmlLineString property value.

visit_gml_multi_point(gml_multi_point)

Visits a GmlMultiPoint property value.

visit_gml_orientable_curve(gml_orientable_curve)

Visits a GmlOrientableCurve property value.

visit_gml_point(gml_point)

Visits a GmlPoint property value.

visit_gml_polygon(gml_polygon)

Visits a GmlPolygon property value.

visit_gml_time_instant(gml_time_instant)

Visits a GmlTimeInstant property value.

visit_gml_time_period(gml_time_period)

Visits a GmlTimePeriod property value.

visit_gpml_array(gpml_array)

Visits a GpmlArray property value.

visit_gpml_constant_value(gpml_constant_value)

Visits a GpmlConstantValue property value.

visit_gpml_finite_rotation(ppml_finite_rotation)

Visits a GpmlFiniteRotation property value.

visit_gpml_irregular_sampling(...)

Visits a GpmlIrregularSampling property value.

visit_gpml_key_value_dictionary(...)

Visits a GpmlKeyValueDictionary property value.

visit_gpml_old_plates_header(...)

Visits a GpmlOldPlatesHeader property value.

visit_gpml_piecewise_aggregation(...)

Visits a GpmlPiecewiseAggregation property value.

visit_gpml_plate_id(gpml_plate_id)

Visits a GpmlPlateId property value.

visit_gpml_polarity_chron_id(...)

Visits a GpmlPolarityChronId property value.

visit_gpml_property_delegate(...)

Visits a GpmlPropertyDelegate property value.

visit_gpml_topological_line(...)

Visits a GpmlTopologicalLine property value.

visit_gpml_topological_line_section(...)

Visits a GpmlTopologicalLineSection property value.

visit_gpml_topological_network(...)

Visits a GpmlTopologicalNetwork property value.

visit_gpml_topological_point(...)

Visits a GpmlTopologicalPoint property value.

visit_gpml_topological_polygon(...)

Visits a GpmlTopologicalPolygon property value.

visit_xs_boolean(xs_boolean)

Visits a XsBoolean property value.

visit_xs_double(xs_double)

Visits a XsDouble property value.

visit_xs_integer(xs_integer)

Visits a XsInteger property value.

visit_xs_string(xs_string)

Visits a XsString property value.

visit_enumeration(enumeration)

Visits a Enumeration property value.

visit_enumeration(enumeration)

Visits a Enumeration property value.

visit_gml_data_block(gml_data_block)

Visits a GmlDataBlock property value.

visit_gml_data_block(gml_data_block)

Visits a GmlDataBlock property value.

visit_gml_line_string(gml_line_string)

Visits a GmlLineString property value.

visit_gml_line_string(gml_line_string)

Visits a GmlLineString property value.

visit_gml_line_string(gml_line_string)

Visits a GmlLineString property value.

visit_gml_line_string(gml_line_string)

Visits a GmlLineString property value.

visit_gml_multi_point(gml_multi_point)

Visits a GmlMultiPoint property value.

visit_gml_multi_point(gml_multi_point)

Visits a GmlMultiPoint property value.

visit_gml_orientable_curve(gml_orientable_curve)

Visits a GmlOrientableCurve property value.

visit_gml_orientable_curve(gml_orientable_curve)

Visits a GmlOrientableCurve property value.

visit_gml_point(gml_point)

Visits a GmlPoint property value.

visit_gml_point(gml_point)

Visits a GmlPoint property value.

visit_gml_polygon(gml_polygon)

Visits a GmlPolygon property value.

visit_gml_polygon(gml_polygon)

Visits a GmlPolygon property value.

visit_gml_time_instant(gml_time_instant)

Visits a GmlTimeInstant property value.

visit_gml_time_instant(gml_time_instant)

Visits a GmlTimeInstant property value.

visit_gml_time_period(gml_time_period)

Visits a GmlTimePeriod property value.

visit_gml_time_period(gml_time_period)

Visits a GmlTimePeriod property value.

visit_gpml_array(gpml_array)

Visits a GpmlArray property value.

visit_gpml_array(gpml_array)

Visits a GpmlArray property value.

visit_gpml_constant_value(gpml_constant_value)

Visits a GpmlConstantValue property value.

visit_gpml_constant_value(gpml_constant_value)

Visits a GpmlConstantValue property value.

visit_gpml_finite_rotation(ppml_finite_rotation)

Visits a GpmlFiniteRotation property value.

visit_gpml_finite_rotation(ppml_finite_rotation)

Visits a GpmlFiniteRotation property value.

visit_gpml_irregular_sampling(gpml_irregular_sampling)

Visits a GpmlIrregularSampling property value.

visit_gpml_irregular_sampling(gpml_irregular_sampling)

Visits a GpmlIrregularSampling property value.

visit_gpml_key_value_dictionary(gpml_key_value_dictionary)

Visits a GpmlKeyValueDictionary property value.

visit_gpml_key_value_dictionary(gpml_key_value_dictionary)

Visits a GpmlKeyValueDictionary property value.

visit_gpml_old_plates_header(gpml_old_plates_header)

Visits a GpmlOldPlatesHeader property value.

visit_gpml_old_plates_header(gpml_old_plates_header)

Visits a GpmlOldPlatesHeader property value.

visit_gpml_piecewise_aggregation(gpml_piecewise_aggregation)

Visits a GpmlPiecewiseAggregation property value.

visit_gpml_piecewise_aggregation(gpml_piecewise_aggregation)

Visits a GpmlPiecewiseAggregation property value.

visit_gpml_plate_id(gpml_plate_id)

Visits a GpmlPlateId property value.

visit_gpml_plate_id(gpml_plate_id)

Visits a GpmlPlateId property value.

visit_gpml_polarity_chron_id(gpml_polarity_chron_id)

Visits a GpmlPolarityChronId property value.

visit_gpml_polarity_chron_id(gpml_polarity_chron_id)

Visits a GpmlPolarityChronId property value.

visit_gpml_property_delegate(gpml_property_delegate)

Visits a GpmlPropertyDelegate property value.

visit_gpml_property_delegate(gpml_property_delegate)

Visits a GpmlPropertyDelegate property value.

visit_gpml_topological_line(gpml_topological_line)

Visits a GpmlTopologicalLine property value.

visit_gpml_topological_line(gpml_topological_line)

Visits a GpmlTopologicalLine property value.

visit_gpml_topological_line_section(gpml_topological_line_section)

Visits a GpmlTopologicalLineSection property value.

visit_gpml_topological_line_section(gpml_topological_line_section)

Visits a GpmlTopologicalLineSection property value.

visit_gpml_topological_network(gpml_topological_network)

Visits a GpmlTopologicalNetwork property value.

visit_gpml_topological_network(gpml_topological_network)

Visits a GpmlTopologicalNetwork property value.

visit_gpml_topological_point(gpml_topological_point)

Visits a GpmlTopologicalPoint property value.

visit_gpml_topological_point(gpml_topological_point)

Visits a GpmlTopologicalPoint property value.

visit_gpml_topological_polygon(gpml_topological_polygon)

Visits a GpmlTopologicalPolygon property value.

visit_gpml_topological_polygon(gpml_topological_polygon)

Visits a GpmlTopologicalPolygon property value.

visit_xs_boolean(xs_boolean)

Visits a XsBoolean property value.

visit_xs_boolean(xs_boolean)

Visits a XsBoolean property value.

visit_xs_double(xs_double)

Visits a XsDouble property value.

visit_xs_double(xs_double)

Visits a XsDouble property value.

visit_xs_integer(xs_integer)

Visits a XsInteger property value.

visit_xs_integer(xs_integer)

Visits a XsInteger property value.

visit_xs_string(xs_string)

Visits a XsString property value.

visit_xs_string(xs_string)

Visits a XsString property value.