Skip to content

Retrieve trackers Impl from session where it is stored#34

Merged
aristarkhovNV merged 6 commits intomainfrom
aaristarkhov/trackers_refactor
Jan 8, 2026
Merged

Retrieve trackers Impl from session where it is stored#34
aristarkhovNV merged 6 commits intomainfrom
aaristarkhov/trackers_refactor

Conversation

@aristarkhovNV
Copy link
Collaborator

@aristarkhovNV aristarkhovNV commented Jan 6, 2026

This PR makes a clear separation between Tracker definition and implementation. Tracker definition becomes a stateless immutable object that serves the following purposes:

  1. Descriptor that is used to configure the XR session
  2. Implementation factory
  3. Type-safe implementation accessor

Tracker::Impl is the implementation that contains session-specific state. Each DeviceIOSession session maintains its own list of session-specific data. Tracker accessor looks-up its implementation from the session object.

Impl life time is tied to the owning session. A live session must be explicitly passed to the tracker which enables the following:

  1. Relation mechanism - users are explicitly asked to initialize a session before they can start talking to trackers.
  2. Lifecycle mechanism - API enforces users to maintain a live session in order to talk to trackers.
  3. Relaxes 1:1 session to tracker relation that was implicitly assumed but wasn't intrinsic to the API. Now it is explicitly "one tracker, many sessions".

Copilot AI review requested due to automatic review settings January 6, 2026 01:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the device tracker architecture to retrieve tracker implementations from the session where they are stored, rather than caching them in individual tracker objects. The change moves from a weak pointer caching pattern in each tracker to a centralized lookup system in DeviceIOSession.

Key Changes:

  • Tracker query methods now require a DeviceIOSession parameter to retrieve their implementations
  • The initialize() method is renamed to create_tracker() to better reflect its purpose
  • Tracker implementations are stored in a map within DeviceIOSession instead of cached weak pointers in each tracker

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
deviceio_init.py Updated documentation to reflect new session parameter requirement
deviceio_bindings.cpp Added lambda wrappers to pass session to tracker methods and added native() accessor
tracker.hpp Renamed initialize() to create_tracker()
headtracker.hpp Added session parameter to get_head() and removed cached implementation pointer
handtracker.hpp Added session parameter to hand query methods and removed cached implementation pointer
deviceio_session.hpp Changed storage from vector to map and added get_tracker_impl() lookup method
controllertracker.hpp Added session parameter to get_controller_data() and removed cached implementation pointer
headtracker.cpp Implemented session-based lookup and removed constructor/destructor
handtracker.cpp Implemented session-based lookup and removed constructor/destructor
deviceio_session.cpp Updated to use map storage and iterate over map entries
controllertracker.cpp Implemented session-based lookup and removed constructor/destructor
Python examples Updated all tracker method calls to pass the session parameter
C++ examples Updated all tracker method calls to pass the session parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aristarkhovNV aristarkhovNV merged commit 65b668b into main Jan 8, 2026
4 checks passed
@aristarkhovNV aristarkhovNV deleted the aaristarkhov/trackers_refactor branch January 8, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants