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 { ...@@ -62,7 +62,7 @@ struct SettingMetadata {
namespace detail { namespace detail {
template <class Type> template <class T>
class Setting { class Setting {
public: public:
/** /**
...@@ -72,10 +72,10 @@ class Setting { ...@@ -72,10 +72,10 @@ class Setting {
* reference obtained here after some amount of time (on the order * reference obtained here after some amount of time (on the order
* of minutes). * of minutes).
*/ */
const Type& operator*() const { const T& operator*() const {
return core_.get(); return core_.get();
} }
const Type* operator->() const { const T* operator->() const {
return &core_.get(); return &core_.get();
} }
...@@ -87,18 +87,18 @@ class Setting { ...@@ -87,18 +87,18 @@ class Setting {
* @param reason Will be stored with the current value, useful for debugging. * @param reason Will be stored with the current value, useful for debugging.
* @throws std::runtime_error If we can't convert t to string. * @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 */ /* Check that we can still display it */
folly::to<std::string>(t); folly::to<std::string>(t);
core_.set(t, reason); core_.set(t, reason);
} }
Setting(SettingMetadata meta, Type defaultValue) Setting(SettingMetadata meta, T defaultValue)
: meta_(std::move(meta)), core_(meta_, std::move(defaultValue)) {} : meta_(std::move(meta)), core_(meta_, std::move(defaultValue)) {}
private: private:
SettingMetadata meta_; SettingMetadata meta_;
SettingCore<Type> core_; SettingCore<T> core_;
}; };
/* C++20 has std::type_indentity */ /* C++20 has std::type_indentity */
......
...@@ -33,10 +33,10 @@ struct SettingMetadata; ...@@ -33,10 +33,10 @@ struct SettingMetadata;
namespace detail { namespace detail {
template <class Type> template <class T>
struct SettingContents { struct SettingContents {
std::string updateReason; std::string updateReason;
Type value; T value;
template <class... Args> template <class... Args>
SettingContents(std::string _reason, Args&&... args) SettingContents(std::string _reason, Args&&... args)
...@@ -65,13 +65,13 @@ convertOrConstruct(StringPiece newValue) { ...@@ -65,13 +65,13 @@ convertOrConstruct(StringPiece newValue) {
return to<T>(newValue); return to<T>(newValue);
} }
template <class Type> template <class T>
class SettingCore : public SettingCoreBase { class SettingCore : public SettingCoreBase {
public: public:
using Contents = SettingContents<Type>; using Contents = SettingContents<T>;
void setFromString(StringPiece newValue, StringPiece reason) override { 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 { std::pair<std::string, std::string> getAsString() const override {
auto contents = *const_cast<SettingCore*>(this)->tlValue(); auto contents = *const_cast<SettingCore*>(this)->tlValue();
...@@ -85,16 +85,16 @@ class SettingCore : public SettingCoreBase { ...@@ -85,16 +85,16 @@ class SettingCore : public SettingCoreBase {
return meta_; return meta_;
} }
const Type& get() const { const T& get() const {
return const_cast<SettingCore*>(this)->tlValue()->value; 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_); SharedMutex::WriteHolder lg(globalLock_);
globalValue_ = std::make_shared<Contents>(reason.str(), t); globalValue_ = std::make_shared<Contents>(reason.str(), t);
++(*globalVersion_); ++(*globalVersion_);
} }
SettingCore(const SettingMetadata& meta, Type defaultValue) SettingCore(const SettingMetadata& meta, T defaultValue)
: meta_(meta), : meta_(meta),
defaultValue_(std::move(defaultValue)), defaultValue_(std::move(defaultValue)),
globalValue_(std::make_shared<Contents>("default", defaultValue_)), globalValue_(std::make_shared<Contents>("default", defaultValue_)),
...@@ -108,7 +108,7 @@ class SettingCore : public SettingCoreBase { ...@@ -108,7 +108,7 @@ class SettingCore : public SettingCoreBase {
private: private:
const SettingMetadata& meta_; const SettingMetadata& meta_;
const Type defaultValue_; const T defaultValue_;
SharedMutex globalLock_; SharedMutex globalLock_;
std::shared_ptr<Contents> globalValue_; 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