-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
387aa3b
commit 89c1936
Showing
24 changed files
with
341 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// config.hpp | ||
// ~~~~~~~~~~ | ||
// | ||
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
|
||
#ifndef ASIO_CONFIG_HPP | ||
#define ASIO_CONFIG_HPP | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER >= 1200) | ||
# pragma once | ||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | ||
|
||
#include "asio/detail/config.hpp" | ||
#include "asio/detail/throw_exception.hpp" | ||
#include "asio/detail/type_traits.hpp" | ||
#include "asio/execution_context.hpp" | ||
#include <cstddef> | ||
|
||
#include "asio/detail/push_options.hpp" | ||
|
||
namespace asio { | ||
|
||
/// Base class for configuration implementations. | ||
class config_service : public execution_context::service | ||
{ | ||
public: | ||
typedef config_service key_type; | ||
|
||
/// Constructor. | ||
ASIO_DECL explicit config_service(execution_context& ctx); | ||
|
||
/// Shutdown the service. | ||
ASIO_DECL void shutdown() override; | ||
|
||
/// Retrieve a configuration value. | ||
virtual const char* get_value(const char* section, const char* key, | ||
char* value, std::size_t value_len) const; | ||
}; | ||
|
||
/// Provides access to the configuration values associated with an execution | ||
/// context. | ||
class config | ||
{ | ||
public: | ||
/// Constructor. | ||
/** | ||
* This constructor initialises a @c config object to retrieve configuration | ||
* values associated with the specified execution context. | ||
*/ | ||
explicit config(execution_context& context) | ||
: service_(use_service<config_service>(context)) | ||
{ | ||
} | ||
|
||
/// Copy constructor. | ||
config(const config& other) noexcept | ||
: service_(other.service_) | ||
{ | ||
} | ||
|
||
/// Retrieve an integral configuration value. | ||
template <typename T> | ||
constraint_t<is_integral<T>::value, T> | ||
get(const char* section, const char* key, T default_value) const; | ||
|
||
private: | ||
config_service& service_; | ||
}; | ||
|
||
/// Configures an execution context based on a concurrency hint. | ||
class config_from_concurrency_hint : public execution_context::service_maker | ||
{ | ||
public: | ||
/// Construct with a default concurrency hint. | ||
config_from_concurrency_hint(); | ||
|
||
/// Construct with a specified concurrency hint. | ||
explicit config_from_concurrency_hint(int concurrency_hint) | ||
: concurrency_hint_(concurrency_hint) | ||
{ | ||
} | ||
|
||
/// Add a concrete service to the specified execution context. | ||
ASIO_DECL void make(execution_context& ctx) const override; | ||
|
||
private: | ||
int concurrency_hint_; | ||
}; | ||
|
||
} // namespace asio | ||
|
||
#include "asio/detail/pop_options.hpp" | ||
|
||
#include "asio/impl/config.hpp" | ||
#if defined(ASIO_HEADER_ONLY) | ||
# include "asio/impl/config.ipp" | ||
#endif // defined(ASIO_HEADER_ONLY) | ||
|
||
#endif // ASIO_CONFIG_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.