Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions moxygen/MoQTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,89 @@ struct AbsoluteLocation {
}

std::string describe() const;

/**
* Get the successor location (next position in lexicographic order).
* Returns nullopt if this is kLocationMax.
*/
std::optional<AbsoluteLocation> next() const {
if (group == kEightByteLimit && object == kEightByteLimit) {
return std::nullopt;
}
if (object == kEightByteLimit) {
return AbsoluteLocation{group + 1, 0};
}
return AbsoluteLocation{group, object + 1};
}

/**
* Get the predecessor location.
* Returns nullopt if this is kLocationMin.
*/
std::optional<AbsoluteLocation> prev() const {
if (group == 0 && object == 0) {
return std::nullopt;
}
if (object == 0) {
return AbsoluteLocation{group - 1, kEightByteLimit};
}
return AbsoluteLocation{group, object - 1};
}

/**
* Get the next object within the same group.
* Returns nullopt if object is at max.
*/
std::optional<AbsoluteLocation> nextInGroup() const {
if (object == kEightByteLimit) {
return std::nullopt;
}
return AbsoluteLocation{group, object + 1};
}

/**
* Get the start of the next group {group+1, 0}.
* Returns nullopt if group is at max.
*/
std::optional<AbsoluteLocation> nextGroup() const {
if (group == kEightByteLimit) {
return std::nullopt;
}
return AbsoluteLocation{group + 1, 0};
}

/**
* Get the start of the previous group {group-1, 0}.
* Returns nullopt if group is 0.
*/
std::optional<AbsoluteLocation> prevGroup() const {
if (group == 0) {
return std::nullopt;
}
return AbsoluteLocation{group - 1, 0};
}

/**
* Get the last location in the previous group {group-1, MAX}.
* Returns nullopt if group is 0.
*/
std::optional<AbsoluteLocation> prevGroupEnd() const {
if (group == 0) {
return std::nullopt;
}
return AbsoluteLocation{group - 1, kEightByteLimit};
}

/**
* Get the previous object within the same group.
* Returns nullopt if object is 0.
*/
std::optional<AbsoluteLocation> prevInGroup() const {
if (object == 0) {
return std::nullopt;
}
return AbsoluteLocation{group, object - 1};
}
};

constexpr AbsoluteLocation kLocationMin;
Expand Down
1 change: 1 addition & 0 deletions moxygen/relay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ moxygen_add_library(moxygen_relay_moq_cache
SRCS
MoQCache.cpp
EXPORTED_DEPS
moxygen_util_location_interval_set
moxygen_moq
moxygen_moq_consumers
moxygen_moq_framer
Expand Down
Loading
Loading