1
#pragma once
2

            
3
#include "envoy/stream_info/uint32_accessor.h"
4

            
5
namespace Envoy {
6
namespace StreamInfo {
7

            
8
/*
9
 * A FilterState object that tracks a single uint32_t value.
10
 */
11
class UInt32AccessorImpl : public UInt32Accessor {
12
public:
13
186
  UInt32AccessorImpl(uint32_t value) : value_(value) {}
14

            
15
  // From FilterState::Object
16
3
  ProtobufTypes::MessagePtr serializeAsProto() const override {
17
3
    auto message = std::make_unique<Protobuf::UInt32Value>();
18
3
    message->set_value(value_);
19
3
    return message;
20
3
  }
21
3
  absl::optional<std::string> serializeAsString() const override { return absl::StrCat(value_); }
22

            
23
  // From UInt32Accessor.
24
160
  void increment() override { value_++; }
25
299
  uint32_t value() const override { return value_; }
26

            
27
private:
28
  uint32_t value_;
29
};
30

            
31
} // namespace StreamInfo
32
} // namespace Envoy