Shaka Packager SDK
Loading...
Searching...
No Matches
flag_saver.h
1// Copyright 2022 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_FLAG_SAVER_H_
8#define PACKAGER_FLAG_SAVER_H_
9
10#include <absl/flags/flag.h>
11
12namespace shaka {
13
18template <typename T>
19class FlagSaver {
20 public:
21 FlagSaver(absl::Flag<T>* flag)
22 : flag_(flag), original_value_(absl::GetFlag(*flag)) {}
23
24 ~FlagSaver() { absl::SetFlag(flag_, original_value_); }
25
26 private:
27 absl::Flag<T>* flag_; // unowned
28 T original_value_;
29};
30
31} // namespace shaka
32
33#endif // PACKAGER_FLAG_SAVER_H_
All the methods that are virtual are virtual for mocking.