pygplates.PropertyValueVisitor
- class pygplates.PropertyValueVisitor
Bases:
instanceThe 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 fromPropertyValueVisitorand 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
PropertyValueVisitorand implementing only those visit methods related to theGpmlPlateIdproperty value type (note that plate ids can be time-dependent in some contexts so we also useGpmlConstantValuein case the plate id property value is wrapped in a constant value wrapper). This example retrieves the integer plate id from a (possibly nested)GpmlPlateIdproperty value, orNoneif 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
Enumerationproperty value.visit_gml_data_block(gml_data_block)Visits a
GmlDataBlockproperty value.visit_gml_line_string(gml_line_string)Visits a
GmlLineStringproperty value.visit_gml_multi_point(gml_multi_point)Visits a
GmlMultiPointproperty value.visit_gml_orientable_curve(gml_orientable_curve)Visits a
GmlOrientableCurveproperty value.visit_gml_point(gml_point)Visits a
GmlPointproperty value.visit_gml_polygon(gml_polygon)Visits a
GmlPolygonproperty value.visit_gml_time_instant(gml_time_instant)Visits a
GmlTimeInstantproperty value.visit_gml_time_period(gml_time_period)Visits a
GmlTimePeriodproperty value.visit_gpml_array(gpml_array)Visits a
GpmlArrayproperty value.visit_gpml_constant_value(gpml_constant_value)Visits a
GpmlConstantValueproperty value.visit_gpml_finite_rotation(ppml_finite_rotation)Visits a
GpmlFiniteRotationproperty value.Visits a
GpmlIrregularSamplingproperty value.Visits a
GpmlKeyValueDictionaryproperty value.Visits a
GpmlOldPlatesHeaderproperty value.Visits a
GpmlPiecewiseAggregationproperty value.visit_gpml_plate_id(gpml_plate_id)Visits a
GpmlPlateIdproperty value.Visits a
GpmlPolarityChronIdproperty value.Visits a
GpmlPropertyDelegateproperty value.Visits a
GpmlTopologicalLineproperty value.Visits a
GpmlTopologicalLineSectionproperty value.Visits a
GpmlTopologicalNetworkproperty value.Visits a
GpmlTopologicalPointproperty value.Visits a
GpmlTopologicalPolygonproperty value.visit_xs_boolean(xs_boolean)Visits a
XsBooleanproperty value.visit_xs_double(xs_double)Visits a
XsDoubleproperty value.visit_xs_integer(xs_integer)Visits a
XsIntegerproperty value.visit_xs_string(xs_string)Visits a
XsStringproperty value.- visit_enumeration(enumeration)
Visits a
Enumerationproperty value.- visit_enumeration(enumeration)
Visits a
Enumerationproperty value.
- visit_gml_data_block(gml_data_block)
Visits a
GmlDataBlockproperty value.- visit_gml_data_block(gml_data_block)
Visits a
GmlDataBlockproperty value.
- visit_gml_line_string(gml_line_string)
Visits a
GmlLineStringproperty value.- visit_gml_line_string(gml_line_string)
Visits a
GmlLineStringproperty value.- visit_gml_line_string(gml_line_string)
Visits a
GmlLineStringproperty value.- visit_gml_line_string(gml_line_string)
Visits a
GmlLineStringproperty value.
- visit_gml_multi_point(gml_multi_point)
Visits a
GmlMultiPointproperty value.- visit_gml_multi_point(gml_multi_point)
Visits a
GmlMultiPointproperty value.
- visit_gml_orientable_curve(gml_orientable_curve)
Visits a
GmlOrientableCurveproperty value.- visit_gml_orientable_curve(gml_orientable_curve)
Visits a
GmlOrientableCurveproperty value.
- visit_gml_point(gml_point)
Visits a
GmlPointproperty value.- visit_gml_point(gml_point)
Visits a
GmlPointproperty value.
- visit_gml_polygon(gml_polygon)
Visits a
GmlPolygonproperty value.- visit_gml_polygon(gml_polygon)
Visits a
GmlPolygonproperty value.
- visit_gml_time_instant(gml_time_instant)
Visits a
GmlTimeInstantproperty value.- visit_gml_time_instant(gml_time_instant)
Visits a
GmlTimeInstantproperty value.
- visit_gml_time_period(gml_time_period)
Visits a
GmlTimePeriodproperty value.- visit_gml_time_period(gml_time_period)
Visits a
GmlTimePeriodproperty value.
- visit_gpml_array(gpml_array)
Visits a
GpmlArrayproperty value.- visit_gpml_array(gpml_array)
Visits a
GpmlArrayproperty value.
- visit_gpml_constant_value(gpml_constant_value)
Visits a
GpmlConstantValueproperty value.- visit_gpml_constant_value(gpml_constant_value)
Visits a
GpmlConstantValueproperty value.
- visit_gpml_finite_rotation(ppml_finite_rotation)
Visits a
GpmlFiniteRotationproperty value.- visit_gpml_finite_rotation(ppml_finite_rotation)
Visits a
GpmlFiniteRotationproperty value.
- visit_gpml_irregular_sampling(gpml_irregular_sampling)
Visits a
GpmlIrregularSamplingproperty value.- visit_gpml_irregular_sampling(gpml_irregular_sampling)
Visits a
GpmlIrregularSamplingproperty value.
- visit_gpml_key_value_dictionary(gpml_key_value_dictionary)
Visits a
GpmlKeyValueDictionaryproperty value.- visit_gpml_key_value_dictionary(gpml_key_value_dictionary)
Visits a
GpmlKeyValueDictionaryproperty value.
- visit_gpml_old_plates_header(gpml_old_plates_header)
Visits a
GpmlOldPlatesHeaderproperty value.- visit_gpml_old_plates_header(gpml_old_plates_header)
Visits a
GpmlOldPlatesHeaderproperty value.
- visit_gpml_piecewise_aggregation(gpml_piecewise_aggregation)
Visits a
GpmlPiecewiseAggregationproperty value.- visit_gpml_piecewise_aggregation(gpml_piecewise_aggregation)
Visits a
GpmlPiecewiseAggregationproperty value.
- visit_gpml_plate_id(gpml_plate_id)
Visits a
GpmlPlateIdproperty value.- visit_gpml_plate_id(gpml_plate_id)
Visits a
GpmlPlateIdproperty value.
- visit_gpml_polarity_chron_id(gpml_polarity_chron_id)
Visits a
GpmlPolarityChronIdproperty value.- visit_gpml_polarity_chron_id(gpml_polarity_chron_id)
Visits a
GpmlPolarityChronIdproperty value.
- visit_gpml_property_delegate(gpml_property_delegate)
Visits a
GpmlPropertyDelegateproperty value.- visit_gpml_property_delegate(gpml_property_delegate)
Visits a
GpmlPropertyDelegateproperty value.
- visit_gpml_topological_line(gpml_topological_line)
Visits a
GpmlTopologicalLineproperty value.- visit_gpml_topological_line(gpml_topological_line)
Visits a
GpmlTopologicalLineproperty value.
- visit_gpml_topological_line_section(gpml_topological_line_section)
Visits a
GpmlTopologicalLineSectionproperty value.- visit_gpml_topological_line_section(gpml_topological_line_section)
Visits a
GpmlTopologicalLineSectionproperty value.
- visit_gpml_topological_network(gpml_topological_network)
Visits a
GpmlTopologicalNetworkproperty value.- visit_gpml_topological_network(gpml_topological_network)
Visits a
GpmlTopologicalNetworkproperty value.
- visit_gpml_topological_point(gpml_topological_point)
Visits a
GpmlTopologicalPointproperty value.- visit_gpml_topological_point(gpml_topological_point)
Visits a
GpmlTopologicalPointproperty value.
- visit_gpml_topological_polygon(gpml_topological_polygon)
Visits a
GpmlTopologicalPolygonproperty value.- visit_gpml_topological_polygon(gpml_topological_polygon)
Visits a
GpmlTopologicalPolygonproperty value.
- visit_xs_boolean(xs_boolean)
Visits a
XsBooleanproperty value.- visit_xs_boolean(xs_boolean)
Visits a
XsBooleanproperty value.
- visit_xs_double(xs_double)
Visits a
XsDoubleproperty value.- visit_xs_double(xs_double)
Visits a
XsDoubleproperty value.
- The following example demonstrates how to implement a simple visitor class by inheriting