Commit 3a2d6a36 authored by Anton Likhtarov's avatar Anton Likhtarov Committed by Facebook Github Bot

Trivial: rename Type -> T

Summary: Makes further changes cleaner

Differential Revision: D9982335

fbshipit-source-id: 19268c8e3fc1b6aee589a8d3d38b0348db8c5a43
parent 50d93463
......@@ -62,7 +62,7 @@ struct SettingMetadata {
namespace detail {
template <class Type>
template <class T>
class Setting {
public:
/**
......@@ -72,10 +72,10 @@ class Setting {
* reference obtained here after some amount of time (on the order
* of minutes).
*/
const Type& operator*() const {
const T& operator*() const {
return core_.get();
}
const Type* operator->() const {
const T* operator->() const {
return &core_.get();
}
......@@ -87,18 +87,18 @@ class Setting {
* @param reason Will be stored with the current value, useful for debugging.
* @throws std::runtime_error If we can't convert t to string.
*/
void set(const Type& t, StringPiece reason = "api") {
void set(const T& t, StringPiece reason = "api") {
/* Check that we can still display it */
folly::to<std::string>(t);
core_.set(t, reason);
}
Setting(SettingMetadata meta, Type defaultValue)
Setting(SettingMetadata meta, T defaultValue)
: meta_(std::move(meta)), core_(meta_, std::move(defaultValue)) {}
private:
SettingMetadata meta_;
SettingCore<Type> core_;
SettingCore<T> core_;
};
/* C++20 has std::type_indentity */
......
......@@ -33,10 +33,10 @@ struct SettingMetadata;
namespace detail {
template <class Type>
template <class T>
struct SettingContents {
std::string updateReason;
Type value;
T value;
template <class... Args>
SettingContents(std::string _reason, Args&&... args)
......@@ -65,13 +65,13 @@ convertOrConstruct(StringPiece newValue) {
return to<T>(newValue);
}
template <class Type>
template <class T>
class SettingCore : public SettingCoreBase {
public:
using Contents = SettingContents<Type>;
using Contents = SettingContents<T>;
void setFromString(StringPiece newValue, StringPiece reason) override {
set(convertOrConstruct<Type>(newValue), reason.str());
set(convertOrConstruct<T>(newValue), reason.str());
}
std::pair<std::string, std::string> getAsString() const override {
auto contents = *const_cast<SettingCore*>(this)->tlValue();
......@@ -85,16 +85,16 @@ class SettingCore : public SettingCoreBase {
return meta_;
}
const Type& get() const {
const T& get() const {
return const_cast<SettingCore*>(this)->tlValue()->value;
}
void set(const Type& t, StringPiece reason) {
void set(const T& t, StringPiece reason) {
SharedMutex::WriteHolder lg(globalLock_);
globalValue_ = std::make_shared<Contents>(reason.str(), t);
++(*globalVersion_);
}
SettingCore(const SettingMetadata& meta, Type defaultValue)
SettingCore(const SettingMetadata& meta, T defaultValue)
: meta_(meta),
defaultValue_(std::move(defaultValue)),
globalValue_(std::make_shared<Contents>("default", defaultValue_)),
......@@ -108,7 +108,7 @@ class SettingCore : public SettingCoreBase {
private:
const SettingMetadata& meta_;
const Type defaultValue_;
const T defaultValue_;
SharedMutex globalLock_;
std::shared_ptr<Contents> globalValue_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment