ImFusion SDK 4.3
ThreadSafeInstrumentsBase Class Referenceabstractthreadsafe

#include <ImFusion/Stream/ThreadSafeInstruments.h>

Non-templated and fully abstract base class for ThreadSafeInstruments. More...

+ Inheritance diagram for ThreadSafeInstrumentsBase:

Detailed Description

Non-templated and fully abstract base class for ThreadSafeInstruments.

This type is intended for the use in TrackingStream implementations.

Provides a basic interface to manage a set of TrackingInstruments in a thread-safe way.

Note
Threadsafe class: Member functions can be called concurrently from any thread.

Public Member Functions

virtual std::vector< TrackingInstrumentinstruments () const =0
 Returns a vector of tracking instruments.
 
virtual std::optional< TrackingInstrumentmainInstrument () const =0
 Returns the main tracking instrument, if any.
 
virtual InstrumentUpdate setMain (unsigned int index)=0
 Sets the main tracking instrument by index.
 
virtual InstrumentUpdate setMainById (const std::string &id)=0
 Sets the main tracking instrument by tracking ID.
 
virtual unsigned int mainIndex () const =0
 Returns the index of the main tracking instrument.
 
virtual const std::stringmainId () const =0
 Returns the ID of the main tracking instrument.
 
virtual std::string mainName () const =0
 Returns the name of the main tracking instrument.
 
virtual void setActive (const std::string &id, bool active)=0
 Sets the active flag of an instrument.
 
virtual bool isActive (const std::string &id) const =0
 Returns whether a tracking instrument is active.
 
virtual InstrumentUpdate create (TrackerID trackerID, bool active=true)=0
 Creates a new instrument with the given TrackerID and active state.
 
virtual InstrumentUpdate createWithPrefix (const std::string &prefix, const std::string &name, const std::string &modelNum="", bool active=true)=0
 Creates a new instrument with the given name and optional model number and active state.
 
virtual InstrumentUpdate remove (const std::string &id)=0
 Removes the instrument with the given ID.
 
virtual InstrumentUpdate clear ()=0
 Clears the entire instrument list and resets the main instrument selection.
 
virtual InstrumentUpdate prepareUpdate (unsigned long long timestamp)=0
 Prepares a subsequent tracking update by setting the device timestamp, resetting the matrix to identity, and setting the quality and status flag to zero for all instruments.
 
virtual InstrumentUpdate update (const std::string &id, mat4 matrix, double quality, unsigned long long timestamp=0, int statusFlags=0x0)=0
 Updates the instrument with the specified ID to the new tracking matrix and quality, and an optional timestamp and status flag.
 
virtual InstrumentUpdate modify (const std::string &id, const std::function< void(const std::string &, TrackingInstrument &)> &fun)=0
 Accessor method to apply a function to a specific instrument with the given ID.
 
virtual InstrumentUpdate modifyAll (const std::function< void(const std::string &, TrackingInstrument &)> &fun)=0
 Accessor method to apply a function to all instruments.
 
virtual int size () const =0
 Returns the number of instruments.
 
virtual std::optional< TrackingInstrumentfind (const std::string &id) const =0
 Finds a specific tracking instrument by ID.
 

Member Function Documentation

◆ instruments()

◆ mainInstrument()

virtual std::optional< TrackingInstrument > mainInstrument ( ) const
pure virtual

◆ setMain()

virtual InstrumentUpdate setMain ( unsigned int index)
pure virtual

Sets the main tracking instrument by index.

Deprecated
"Identification by index is deprecated. Use the instrument ID instead"

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ setMainById()

virtual InstrumentUpdate setMainById ( const std::string & id)
pure virtual

◆ mainIndex()

virtual unsigned int mainIndex ( ) const
pure virtual

Returns the index of the main tracking instrument.

Deprecated
"Identification by index is deprecated. Use the instrument ID instead"

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ mainId()

virtual const std::string & mainId ( ) const
pure virtual

◆ mainName()

virtual std::string mainName ( ) const
pure virtual

◆ setActive()

virtual void setActive ( const std::string & id,
bool active )
pure virtual

◆ isActive()

virtual bool isActive ( const std::string & id) const
pure virtual

◆ create()

virtual InstrumentUpdate create ( TrackerID trackerID,
bool active = true )
pure virtual

◆ createWithPrefix()

virtual InstrumentUpdate createWithPrefix ( const std::string & prefix,
const std::string & name,
const std::string & modelNum = "",
bool active = true )
pure virtual

Creates a new instrument with the given name and optional model number and active state.

Auto-assigns a new unique ID based on a tracking stream-specific prefix. It assigns an ID of the form "prefix-<number>" with the smallest available positive number.

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ remove()

virtual InstrumentUpdate remove ( const std::string & id)
pure virtual

Removes the instrument with the given ID.

Updates the main instrument to the first instrument in the list if the removed instrument was the main instrument.

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ clear()

virtual InstrumentUpdate clear ( )
pure virtual

Clears the entire instrument list and resets the main instrument selection.

The main instrument ID is reset to "".

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ prepareUpdate()

virtual InstrumentUpdate prepareUpdate ( unsigned long long timestamp)
pure virtual

Prepares a subsequent tracking update by setting the device timestamp, resetting the matrix to identity, and setting the quality and status flag to zero for all instruments.

This is a convenience method intended to be used when the stream's tracking update iterates over received tracking data, where we cannot be sure that all tracking instruments are included.

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ update()

virtual InstrumentUpdate update ( const std::string & id,
mat4 matrix,
double quality,
unsigned long long timestamp = 0,
int statusFlags = 0x0 )
pure virtual

Updates the instrument with the specified ID to the new tracking matrix and quality, and an optional timestamp and status flag.

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ modify()

virtual InstrumentUpdate modify ( const std::string & id,
const std::function< void(const std::string &, TrackingInstrument &)> & fun )
pure virtual

Accessor method to apply a function to a specific instrument with the given ID.

Calls fun(id, ti) on the TrackingInstrument ti that has the identifier id. This method allows modification of the members of the TrackingInstrument beyond the provided default methods (e.g., update, prepareUpdate, setActive, etc.).

Example usage in a tracking stream class:

std::string newName = "New tracking instrument name";
auto renameTrackingInstrument = [&newName] (const std::string& id , TrackingInstrument& ti) {
ti.id.setName(newName);
};
m_instruments->modify("tracker-id", renameTrackingInstrument);
Class for information of a tracking instrument.
Definition TrackingInstrument.h:91

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ modifyAll()

virtual InstrumentUpdate modifyAll ( const std::function< void(const std::string &, TrackingInstrument &)> & fun)
pure virtual

Accessor method to apply a function to all instruments.

Calls fun(id, ti) on all the TrackingInstruments ti with identifier id.

Example usage in a tracking stream class:

auto setCustomStatus = [] (const std::string& id , TrackingInstrument& ti) {
ti.statusFlags = 1 << 3;
};
m_instruments->modifyAll(setCustomStatus);

Implemented in ThreadSafeInstruments< Special >, ThreadSafeInstruments< ImFusion::FakeTrackingStream::Device >, and ThreadSafeInstruments< ImFusion::NDITrackingInstrumentInfo >.

◆ size()

◆ find()


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close