LuciadCPillar 2023.1.04
luciad::Feature::Builder Class Referencefinal

Allows the incremental creation of a Feature object. More...

#include <luciad/models/features/Feature.h>

Public Member Functions

 Builder (Builder &&other) noexcept
 
 Builder (const Builder &other)
 
 ~Builder ()
 
Feature build ()
 Build the feature using the settings configured. More...
 
BuilderdataType (DataType dataType)
 Configures the dataType of the feature being built. More...
 
Builderid (FeatureId id)
 Configures the id of the feature being built. More...
 
Builderoperator= (Builder other) noexcept
 
BuilderresetId ()
 Resets the id. More...
 
template<typename T >
BuilderresetValue (const DataPropertyPath &propertyPath)
 Resets the value associated with the given property. More...
 
template<typename T >
Buildervalue (const DataPropertyPath &propertyPath, T value)
 Sets the value associated with the given property. More...
 

Detailed Description

Allows the incremental creation of a Feature object.

Make sure to

Otherwise a LogicException will be thrown.

Constructor & Destructor Documentation

◆ Builder() [1/2]

luciad::Feature::Builder::Builder ( const Builder other)

◆ Builder() [2/2]

luciad::Feature::Builder::Builder ( Builder &&  other)
noexcept

◆ ~Builder()

luciad::Feature::Builder::~Builder ( )

Member Function Documentation

◆ build()

Feature luciad::Feature::Builder::build ( )

Build the feature using the settings configured.

After this method is invoked once, this builder can no longer be used.

Returns
the feature
Exceptions
LogicExceptionif the id or dataType are not configured

◆ dataType()

Builder & luciad::Feature::Builder::dataType ( DataType  dataType)

Configures the dataType of the feature being built.

The DataType needs to be set before value() is called.

Parameters
dataTypethe data type
Returns
this builder

◆ id()

Builder & luciad::Feature::Builder::id ( FeatureId  id)

Configures the id of the feature being built.

A feature id should be unique across a model.

This method is not mandatory, though Features in a model must have an id. It is allowed to temporarily have features without id, for example during Feature creation. As soon as such a temporary Feature is added to a model, it must be assigned an id though.

When no id is set, Feature::getId will throw an exception.

Parameters
idthe id
Returns
this builder

◆ operator=()

Builder & luciad::Feature::Builder::operator= ( Builder  other)
noexcept

◆ resetId()

Builder & luciad::Feature::Builder::resetId ( )

Resets the id.

Calling this method will cause the built Feature to have no id, thus throwing an exception when calling Feature::getId.

Features in a model must have an id. It is allowed to temporarily have features without id, for example during Feature creation. As soon as such a temporary Feature is added to a model, it must be assigned an id though.

Note that for a newly created Feature::Builder using the Feature::newBuilder() method, the id will be empty by default. This method is less useful in that case. It is mainly useful when using the Feature::asBuilder() method.

Returns
this builder
Since
2023.1

◆ resetValue()

template<typename T >
Builder & luciad::Feature::Builder::resetValue ( const DataPropertyPath propertyPath)

Resets the value associated with the given property.

Calling this method will cause the built Feature to return an empty optional for the given property.

Note that for a newly created Feature::Builder using the Feature::newBuilder() method, all values will be empty by default. This method is less useful in that case. It is mainly useful when using the Feature::asBuilder() method.

Template Parameters
Tthe supported types are bool, int32_t, int64_t, float, double, std::string and std::shared_ptr<luciad::Geometry>
Parameters
propertyPaththe property for which to reset the value
Returns
this builder
Exceptions
InvalidArgumentExceptionwhen the dataType has not been configured yet, the property is not of a known type, or if it doesn't exist in the DataType.
Since
2020.1

◆ value()

template<typename T >
Builder & luciad::Feature::Builder::value ( const DataPropertyPath propertyPath,
value 
)

Sets the value associated with the given property.

Example

featureBuilder.value<bool>(boolPropertyPath, boolValue);
featureBuilder.value<int32_t>(intPropertyPath, intValue);
featureBuilder.value<int64_t>(longPropertyPath, longValue);
featureBuilder.value<float>(floatPropertyPath, floatValue);
featureBuilder.value<double>(doublePropertyPath, doubleValue);
featureBuilder.value<std::string>(stringPropertyPath, stringValue);
featureBuilder.value<std::shared_ptr<Geometry>>(geometryPropertyPath, geometryValue);
Template Parameters
Tthe supported types are bool, int32_t, int64_t, float, double, std::string and std::shared_ptr<luciad::Geometry>
Parameters
propertyPaththe property for which to set the value
valuethe value
Returns
this builder
Exceptions
InvalidArgumentExceptionwhen the dataType has not been configured yet, the property is not of a known type, or if it doesn't exist in the DataType.