Commit 2ea7e939 authored by Anton Likhtarov's avatar Anton Likhtarov Committed by Facebook Github Bot

Easy: store metadata with SettingsCore object

Summary: Requires a new header to break the circular dependency

Differential Revision: D9983196

fbshipit-source-id: f15ab3c6128d30906ac25384df92813aa9d76c9a
parent ecdcc6d8
......@@ -19,47 +19,11 @@
#include <string>
#include <folly/Range.h>
#include <folly/experimental/settings/SettingsMetadata.h>
#include <folly/experimental/settings/detail/SettingsImpl.h>
namespace folly {
namespace settings {
/**
* Static information about the setting definition
*/
struct SettingMetadata {
/**
* Project string.
*/
folly::StringPiece project;
/**
* Setting name within the project.
*/
folly::StringPiece name;
/**
* String representation of the type.
*/
folly::StringPiece typeStr;
/**
* typeid() of the type.
*/
const std::type_info& typeId;
/**
* String representation of the default value.
* (note: string literal default values will be stringified with quotes)
*/
folly::StringPiece defaultStr;
/**
* Setting description field.
*/
folly::StringPiece description;
};
namespace detail {
template <class T>
......@@ -99,11 +63,9 @@ class Setting {
SettingMetadata meta,
T defaultValue,
std::atomic<uint64_t>& trivialStorage)
: meta_(std::move(meta)),
core_(meta_, std::move(defaultValue), trivialStorage) {}
: core_(std::move(meta), std::move(defaultValue), trivialStorage) {}
private:
SettingMetadata meta_;
SettingCore<T> core_;
};
......
/*
* Copyright 2018-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <folly/Range.h>
namespace folly {
namespace settings {
/**
* Static information about the setting definition
*/
struct SettingMetadata {
/**
* Project string.
*/
folly::StringPiece project;
/**
* Setting name within the project.
*/
folly::StringPiece name;
/**
* String representation of the type.
*/
folly::StringPiece typeStr;
/**
* typeid() of the type.
*/
const std::type_info& typeId;
/**
* String representation of the default value.
* (note: string literal default values will be stringified with quotes)
*/
folly::StringPiece defaultStr;
/**
* Setting description field.
*/
folly::StringPiece description;
};
} // namespace settings
} // namespace folly
......@@ -25,12 +25,10 @@
#include <folly/Range.h>
#include <folly/SharedMutex.h>
#include <folly/ThreadLocal.h>
#include <folly/experimental/settings/SettingsMetadata.h>
namespace folly {
namespace settings {
struct SettingMetadata;
namespace detail {
/**
......@@ -130,10 +128,10 @@ class SettingCore : public SettingCoreBase {
}
SettingCore(
const SettingMetadata& meta,
SettingMetadata meta,
T defaultValue,
std::atomic<uint64_t>& trivialStorage)
: meta_(meta),
: meta_(std::move(meta)),
defaultValue_(std::move(defaultValue)),
trivialStorage_(trivialStorage),
localValue_([]() {
......@@ -146,7 +144,7 @@ class SettingCore : public SettingCoreBase {
}
private:
const SettingMetadata& meta_;
SettingMetadata meta_;
const T defaultValue_;
SharedMutex globalLock_;
......
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