Skip to main content

TimePosition

TimePosition

Position in time with clock identity. More…

#include <TimeFrame.hpp>

Public Functions

Name
TimePosition() =default
TimePosition(TimeFrameIndex idx, std::shared_ptr< TimeFrame > tf)
TimePosition(int64_t idx, std::shared_ptr< TimeFrame > tf =[nullptr])
bool sameClock(TimePosition const & other) const
Check if two positions are on the same clock (pointer comparison).
bool sameClock(TimeFrame const * other) const
Check against a raw TimeFrame pointer (e.g., from data->getTimeFrame().get()).
bool sameClock(std::shared_ptr< TimeFrame > const & other) const
Check against a shared_ptr (e.g., from data->getTimeFrame()).
TimeFrameIndex convertTo(TimeFrame const * target) const
Convert this position to a different timeframe.
TimeFrameIndex convertTo(std::shared_ptr< TimeFrame > const & target) const
Convert to a shared_ptr timeframe.
bool isValid() const
Check if this position has a valid TimeFrame.
bool operator==(TimePosition const & other) const
Equality (same clock AND same index).
bool operator!=(TimePosition const & other) const

Public Attributes

Name
TimeFrameIndex index
std::shared_ptr< TimeFrame > time_frame

Detailed Description

struct TimePosition;

Position in time with clock identity.

Note: Uses shared_ptr for signal safety (TimeFrame outlives async signals)

Combines a TimeFrameIndex with the TimeFrame it belongs to. This is the primary type for time change signals because it allows:

  • Pointer comparison to check if two positions are on the same clock
  • Direct index conversion between different TimeFrames
  • Safe passage through Qt signals (shared_ptr keeps TimeFrame alive)

Public Functions Documentation

function TimePosition

TimePosition() =default

function TimePosition

inline TimePosition(
    TimeFrameIndex idx,
    std::shared_ptr< TimeFrame > tf
)

function TimePosition

inline explicit TimePosition(
    int64_t idx,
    std::shared_ptr< TimeFrame > tf =nullptr
)

function sameClock

inline bool sameClock(
    TimePosition const & other
) const

Check if two positions are on the same clock (pointer comparison).

function sameClock

inline bool sameClock(
    TimeFrame const * other
) const

Check against a raw TimeFrame pointer (e.g., from data->getTimeFrame().get()).

function sameClock

inline bool sameClock(
    std::shared_ptr< TimeFrame > const & other
) const

Check against a shared_ptr (e.g., from data->getTimeFrame()).

function convertTo

inline TimeFrameIndex convertTo(
    TimeFrame const * target
) const

Convert this position to a different timeframe.

function convertTo

inline TimeFrameIndex convertTo(
    std::shared_ptr< TimeFrame > const & target
) const

Convert to a shared_ptr timeframe.

function isValid

inline bool isValid() const

Check if this position has a valid TimeFrame.

function operator==

inline bool operator==(
    TimePosition const & other
) const

Equality (same clock AND same index).

function operator!=

inline bool operator!=(
    TimePosition const & other
) const

Public Attributes Documentation

variable index

TimeFrameIndex index {0};

variable time_frame

std::shared_ptr< TimeFrame > time_frame;

Updated on 2026-11-13 at 20:25:39 +0000