Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::PositionService Class Reference

Provides access to device and fused positioning. More...

Inheritance diagram for gem::PositionService:
Collaboration diagram for gem::PositionService:

Public Member Functions

 PositionService (const PositionService &)=delete
 PositionService (PositionService &&)=default
 Default move constructor noexcept is deduced.
PositionService & operator= (const PositionService &)=delete
 Copy assignment operator is deleted to prevent copying of this service.
PositionService & operator= (PositionService &&)=default
 Default move assignment operator.
void addListener (PositionListener listener, sense::EDataType type=sense::EDataType::Position) noexcept
 Registers a new listener for position updates.
void removeListener (PositionListener listener) noexcept
 Unregisters a previously registered position listener.
sense::EDataSourceType getSourceType () const
 Retrieves the method used to obtain the position data.
sense::PositionPtr getPosition (sense::EDataType type=sense::EDataType::Position) const noexcept
 Fetches the latest position data available.
sense::PlaybackPtr getPlayback () const noexcept
 Retrieves the data source playback interface, if available.
int setDataSource (sense::DataSourcePtr dataSource) noexcept
 Sets the current data source for obtaining position data.
sense::DataSourcePtr getDataSource () const noexcept
 Retrieves the current data source used for obtaining position data.
PositionPublishingPreferences getPositionPublishingPreferences () const noexcept
 Get the position publishing preferences.
int setPositionPublishingPreferences (const PositionPublishingPreferences &prefs) noexcept
 Set the position publishing preferences.
std::pair< sense::PositionPtr, TimegetLastPublishedPosition () noexcept
 Get the last published position.

Detailed Description

Provides access to device and fused positioning.

Implements share-read / write Api object over IPositionService.

This behaves like a singleton, i.e. all instances are shared behind the same API interface.

Supplies real-time location updates, including GPS and sensor fusion, for navigation and positioning features.

Member Function Documentation

◆ addListener()

void gem::PositionService::addListener ( PositionListener listener,
sense::EDataType type = sense::EDataType::Position )
inlinenoexcept

Registers a new listener for position updates.

The listener also receives updates when the availability state of the data type provider changes.

Parameters
[in]listenerThe listener to be registered; must not be empty.
[in]typeThe type of data the listener registers for, defaults to Position data type.

◆ getDataSource()

sense::DataSourcePtr gem::PositionService::getDataSource ( ) const
inlinenoexcept

Retrieves the current data source used for obtaining position data.

Returns
A pointer to the current data source.
Note
The returned pointer should be checked for validity.

◆ getLastPublishedPosition()

std::pair< sense::PositionPtr, Time > gem::PositionService::getLastPublishedPosition ( )
inlinenoexcept

Get the last published position.

Returns
A std::pair<position, publish time ( as universal time )>

◆ getPlayback()

sense::PlaybackPtr gem::PositionService::getPlayback ( ) const
inlinenoexcept

Retrieves the data source playback interface, if available.

Returns
A pointer to the playback interface; valid only if the current data source is of Playback type.
Note
The returned pointer should be checked for validity.

◆ getPosition()

sense::PositionPtr gem::PositionService::getPosition ( sense::EDataType type = sense::EDataType::Position) const
inlinenoexcept

Fetches the latest position data available.

The API user should check if the provided position is valid by using Position::isValid().

Parameters
[in]typeThe type of position data to fetch, defaults to Position data type.
Returns
A pointer to the position data, or nullptr if no data is available.

◆ getPositionPublishingPreferences()

PositionPublishingPreferences gem::PositionService::getPositionPublishingPreferences ( ) const
inlinenoexcept

Get the position publishing preferences.

Returns
The position publishing current preferences

◆ getSourceType()

sense::EDataSourceType gem::PositionService::getSourceType ( ) const
inline

Retrieves the method used to obtain the position data.

Returns
The data source type as an enum value from sense::EDataSourceType.

◆ operator=() [1/2]

PositionService & gem::PositionService::operator= ( const PositionService & )
delete

Copy assignment operator is deleted to prevent copying of this service.

Returns
PositionService& reference to this instance

◆ operator=() [2/2]

PositionService & gem::PositionService::operator= ( PositionService && )
default

Default move assignment operator.

Uses the compiler-generated default implementation for move assignment.

Note
noexcept is deduced.
Returns
PositionService& reference to this instance

◆ removeListener()

void gem::PositionService::removeListener ( PositionListener listener)
inlinenoexcept

Unregisters a previously registered position listener.

Parameters
[in]listenerThe listener to be unregistered.

◆ setDataSource()

int gem::PositionService::setDataSource ( sense::DataSourcePtr dataSource)
inlinenoexcept

Sets the current data source for obtaining position data.

Parameters
[in]dataSourceThe data source to be used for fetching position data.

If dataSource is an empty pointer, the current data source will be removed.

Returns
An integer indicating the success (0) or failure (non-zero) of the operation.

◆ setPositionPublishingPreferences()

int gem::PositionService::setPositionPublishingPreferences ( const PositionPublishingPreferences & prefs)
inlinenoexcept

Set the position publishing preferences.

Parameters
[in]prefsThe new preferences
Returns
The request error code