Commit 51f63abd authored by Dominik Charousset's avatar Dominik Charousset

Move opt_group out of actor_system_config

parent 751f86fd
......@@ -37,6 +37,7 @@ set(LIBCAF_CORE_SRCS
src/blocking_behavior.cpp
src/concatenated_tuple.cpp
src/config_option.cpp
src/config_option_adder.cpp
src/config_option_set.cpp
src/config_value.cpp
src/decorated_tuple.cpp
......
......@@ -26,16 +26,17 @@
#include <type_traits>
#include <unordered_map>
#include "caf/fwd.hpp"
#include "caf/stream.hpp"
#include "caf/thread_hook.hpp"
#include "caf/config_value.hpp"
#include "caf/actor_factory.hpp"
#include "caf/config_option.hpp"
#include "caf/config_option_adder.hpp"
#include "caf/config_option_set.hpp"
#include "caf/actor_factory.hpp"
#include "caf/config_value.hpp"
#include "caf/fwd.hpp"
#include "caf/is_typed_actor.hpp"
#include "caf/type_erased_value.hpp"
#include "caf/named_actor_config.hpp"
#include "caf/stream.hpp"
#include "caf/thread_hook.hpp"
#include "caf/type_erased_value.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/type_traits.hpp"
......@@ -83,33 +84,9 @@ public:
using string_list = std::vector<std::string>;
// -- nested classes ---------------------------------------------------------
using named_actor_config_map = hash_map<std::string, named_actor_config>;
class opt_group {
public:
opt_group(config_option_set& xs, const char* category);
template <class T>
opt_group& add(T& storage, const char* name, const char* description) {
xs_.add(storage, category_, name, description);
return *this;
}
template <class T>
opt_group& add(const char* name, const char* description) {
xs_.add<T>(category_, name, description);
return *this;
}
opt_group& add_neg(bool& storage, const char* name,
const char* description);
private:
config_option_set& xs_;
const char* category_;
};
using opt_group = config_option_adder;
// -- constructors, destructors, and assignment operators --------------------
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
#include <vector>
#include "caf/config_option.hpp"
#include "caf/fwd.hpp"
#include "caf/make_config_option.hpp"
namespace caf {
/// Adds config options of the same category to a `config_option_set`.
class config_option_adder {
public:
// -- constructors, destructors, and assignment operators --------------------
config_option_adder(config_option_set& target, const char* category);
// -- properties -------------------------------------------------------------
/// Adds a config option to the category that synchronizes with `ref`.
template <class T>
config_option_adder& add(T& ref, const char* name, const char* description) {
return add_impl(make_config_option(ref, category_, name, description));
}
/// Adds a config option to the category.
template <class T>
config_option_adder& add(const char* name, const char* description) {
return add_impl(make_config_option<T>(category_, name, description));
}
/// For backward compatibility only. Do not use for new code!
/// @private
config_option_adder& add_neg(bool& storage, const char* name,
const char* description);
private:
// -- properties -------------------------------------------------------------
config_option_adder& add_impl(config_option&& opt);
// -- member variables -------------------------------------------------------
/// Reference to the target set.
config_option_set& xs_;
/// Category for all options generated by this adder.
const char* category_;
};
} // namespace caf
......@@ -101,18 +101,17 @@ public:
template <class T>
config_option_set& add(const char* category, const char* name,
const char* description = "") {
opts_.emplace_back(make_config_option<T>(category, name, description));
return *this;
return add(make_config_option<T>(category, name, description));
}
/// Adds a config option to the set that synchronizes its value with `ref`.
template <class T>
config_option_set& add(T& ref, const char* category, const char* name,
const char* description = "") {
opts_.emplace_back(make_config_option<T>(ref, category, name, description));
return *this;
return add(make_config_option<T>(ref, category, name, description));
}
/// Adds a config option to the set.
/// @private
config_option_set& add(config_option&& opt);
......
......@@ -84,6 +84,7 @@ class actor_system_config;
class behavior;
class blocking_actor;
class config_option;
class config_option_adder;
class config_option_set;
class config_value;
class deserializer;
......
......@@ -34,20 +34,6 @@ CAF_PUSH_DEPRECATED_WARNING
namespace caf {
actor_system_config::opt_group::opt_group(config_option_set& xs,
const char* category)
: xs_(xs),
category_(category) {
// nop
}
actor_system_config::opt_group&
actor_system_config::opt_group::add_neg(bool& storage, const char* name,
const char* description) {
xs_.add(make_negated_config_option(storage, category_, name, description));
return *this;
}
actor_system_config::~actor_system_config() {
// nop
}
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/config_option_adder.hpp"
#include "caf/config_option_set.hpp"
namespace caf {
config_option_adder::config_option_adder(config_option_set& target,
const char* category)
: xs_(target),
category_(category) {
// nop
}
config_option_adder& config_option_adder::add_neg(bool& ref, const char* name,
const char* description) {
return add_impl(make_negated_config_option(ref, category_,
name, description));
}
config_option_adder& config_option_adder::add_impl(config_option&& opt) {
xs_.add(std::move(opt));
return *this;
}
} // namespace caf
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