libadc-cxx 1.0.0
Structured logging for scientific computing
Loading...
Searching...
No Matches
factory.hpp
Go to the documentation of this file.
1/* Copyright 2025 NTESS. See the top-level LICENSE.txt file for details.
2 *
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef adc_factory_hpp
6#define adc_factory_hpp
7#include <string>
8#include <string_view>
9#include <map>
10#include <set>
11#include "adc/types.hpp"
12#ifdef ADC_HAVE_MPI
13#include <mpi.h>
14#endif
18
19namespace adc {
20
21/** \addtogroup API
22 * @{
23 */
24inline version adc_factory_version("1.0.0", {"none"});
25
26/*!
27 \brief provides publishers and builders of application metadata.
28
29This class provides builders of abstracted metadata objects
30and publishers. Generally an application will create and configure
31one publisher (or a multipublisher) and as many builder objects
32as needed. In most cases, a new builder object is used for each published event.
33 */
34class ADC_VISIBLE factory {
35public:
36 /// \return a publisher instance
37 /// \param name one of the elements found with get_publisher_names().
38 std::shared_ptr<publisher_api> get_publisher(const std::string& name);
39
40 /** \return a publisher instance, or an empty pointer if the name is unavailable.
41 \param name one of the elements found with get_publisher_names().
42 \param opts a map of option names and their values; plugins will
43 silently ignore unused options.
44 */
45 std::shared_ptr<publisher_api> get_publisher(const std::string& name, const std::map<std::string, std::string>& opts);
46
47 /** \return the names of publishers available.
48 The "none", "stdout", "file", "multifile", "syslog", and "script" publishers are always available
49 in Linux environments.
50 */
51 const std::set<std::string>& get_publisher_names();
52
53 /** \return a multipublisher instance for populating.
54
55 multi_publisher provides a convenient way to publish on multiple
56 publishers without duplicate calls to a publish() function.
57 */
58 std::shared_ptr<multi_publisher_api> get_multi_publisher();
59
60 /** \return a multipublisher instance pre-populated using env_name.
61
62 This function creates a multi_publisher pre-configured with the
63 publisher plugins named in the given environment variable.
64 If the environment variable given is the empty string, then
65 publishers named in the environment variable ADC_MULTI_PUBLISHER_NAMES are created.
66 Plugin names in the environment variable are colon-separated.
67 In either case, the publishers are configured using their defaults and
68 plugin-specific environment variables documented by each plugin implementation.
69 */
70 std::shared_ptr<multi_publisher_api> get_multi_publisher_from_env(const std::string& env_name);
71
72 /** \return a multipublisher instance pre-populated from environment settings for the listed plugins.
73
74 This function creates a multi_publisher pre-configured with the
75 publisher plugins named in the input vector. If the input vector is empty,
76 this is equivalent to get_multi_publisher().
77 */
78 std::shared_ptr<multi_publisher_api> get_multi_publisher_from_env(std::vector< std::string > & plugin_list);
79
80 /// \return an empty json builder object
81 std::shared_ptr<builder_api> get_builder();
82
83private:
84 std::set<std::string> names; //!< the list of publisher names
85 int debug;
86 void init();
87
88}; // class factory
89
90/** @}*/
91
92} // namespace adc
93#endif // adc_factory_hpp
provides publishers and builders of application metadata.
Definition factory.hpp:34
version adc_factory_version("1.0.0", {"none"})
Definition adc.hpp:82
A version with tags list.
Definition types.hpp:28