Skip to content

Commit 6f68227

Browse files
committed
ADD: Add PUBLISHER_SPECIFIC flag
1 parent c86f297 commit 6f68227

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
## 0.41.0 - TBD
44

55
### Enhancements
6-
- Add static `Builder()` methods to the clients
7-
- Improve debug logging in live clients
6+
- Added static `Builder()` methods to the clients
7+
- Improved debug logging in live clients
8+
- Added `PUBLISHER_SPECIFIC` flag
89

910
### Breaking changes
1011
- Removed unused `Received` variant from `JobState` enum

include/databento/flag_set.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class FlagSet {
2424
static constexpr Repr kBadTsRecv = 1 << 3;
2525
// Indicates an unrecoverable gap was detected in the channel.
2626
static constexpr Repr kMaybeBadBook = 1 << 2;
27+
// Indicates a publisher-specific event.
28+
static constexpr Repr kPublisherSpecific = 1 << 1;
2729

2830
friend std::ostream& operator<<(std::ostream&, FlagSet);
2931

@@ -77,11 +79,16 @@ class FlagSet {
7779
bits_.maybe_bad_book = true;
7880
return *this;
7981
}
82+
constexpr bool IsPublisherSpecific() const { return bits_.publisher_specific; }
83+
FlagSet SetPublisherSpecific() {
84+
bits_.publisher_specific = true;
85+
return *this;
86+
}
8087

8188
private:
8289
struct BitFlags {
8390
bool reserved0 : 1;
84-
bool reserved1 : 1;
91+
bool publisher_specific : 1;
8592
bool maybe_bad_book : 1;
8693
bool bad_ts_recv : 1;
8794
bool mbp : 1;

src/flag_set.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
namespace databento {
88
std::ostream& operator<<(std::ostream& stream, FlagSet flag_set) {
9-
const std::array<std::pair<bool (FlagSet::*)() const, const char*>, 6>
9+
const std::array<std::pair<bool (FlagSet::*)() const, const char*>, 7>
1010
kFlagsAndNames = {{
1111
{&FlagSet::IsLast, "LAST"},
1212
{&FlagSet::IsTob, "TOB"},
1313
{&FlagSet::IsSnapshot, "SNAPSHOT"},
1414
{&FlagSet::IsMbp, "MBP"},
1515
{&FlagSet::IsBadTsRecv, "BAD_TS_RECV"},
1616
{&FlagSet::IsMaybeBadBook, "MAYBE_BAD_BOOK"},
17+
{&FlagSet::IsPublisherSpecific, "PUBLISHER_SPECIFIC"},
1718
}};
1819

1920
bool has_written_flag = false;

tests/src/flag_set_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ TEST(FlagSetTests, ToStringThreeSet) {
4646
TEST(FlagSetTests, ToStringReservedSet) {
4747
constexpr FlagSet kTarget{255};
4848
ASSERT_EQ(ToString(kTarget),
49-
"LAST | TOB | SNAPSHOT | MBP | BAD_TS_RECV | MAYBE_BAD_BOOK (255)");
49+
"LAST | TOB | SNAPSHOT | MBP | BAD_TS_RECV | MAYBE_BAD_BOOK | "
50+
"PUBLISHER_SPECIFIC (255)");
5051
}
5152

5253
TEST(FlagSetTests, ConstantBitFieldEquivalence) {

0 commit comments

Comments
 (0)