PDI 1.7.1

the PDI data interface

context_proxy.h
1/*******************************************************************************
2 * Copyright (C) 2021 Commissariat a l'energie atomique et aux energies alternatives (CEA)
3 * Copyright (C) 2019-2021 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of CEA nor the names of its contributors may be used to
14 * endorse or promote products derived from this software without specific
15 * prior written permission.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 ******************************************************************************/
25
26#ifndef PDI_CONTEXT_PROXY_H_
27#define PDI_CONTEXT_PROXY_H_
28
29#include <pdi/pdi_fwd.h>
30#include <pdi/callbacks.h>
31#include <pdi/context.h>
32#include <pdi/logger.h>
33
34#include <functional>
35#include <string>
36
37namespace PDI {
38
39class PDI_EXPORT Context_proxy: public Context
40{
42 Context& m_real_context;
43
45 Logger m_plugin_logger;
46
47public:
52
58 Context_proxy(Context& ctx, const std::string& logger_name, PC_tree_t logging_tree);
59
64 void setup_logger(const std::string& logger_name, PC_tree_t logging_tree);
65
68 Data_descriptor& desc(const std::string& name) override;
69
72 Data_descriptor& desc(const char* name) override;
73
76 Data_descriptor& operator[] (const std::string& name) override;
77
80 Data_descriptor& operator[] (const char* name) override;
81
84 Iterator begin() override;
85
88 Iterator end() override;
89
94 void event(const char* name) override;
95
100 Logger& logger() override;
101
107
110 Datatype_template_ptr datatype(PC_tree_t node) override;
111
114 void add_datatype(const std::string& name, Datatype_template_parser parser) override;
115
118 Callbacks& callbacks() override;
119
120 void finalize_and_exit() override;
121};
122
123} //namespace PDI
124
125#endif // PDI_CONTEXT_PROXY_H_
Definition: callbacks.h:39
An iterator used to go through the descriptor store.
Definition: context.h:49
Definition: context_proxy.h:40
Iterator end() override
Context::end proxy for plugins.
Logger & pdi_core_logger()
Returns pdi core logger.
void setup_logger(const std::string &logger_name, PC_tree_t logging_tree)
Sets up logger.
Context_proxy(Context &ctx)
Creates Context proxy without plugin logger.
Iterator begin() override
Context::begin proxy for plugins.
Context_proxy(Context &ctx, const std::string &logger_name, PC_tree_t logging_tree)
Creates Context proxy.
void event(const char *name) override
Context::event proxy for plugins.
Logger & logger() override
Returns plugin logger.
Datatype_template_ptr datatype(PC_tree_t node) override
Context::datatype proxy for plugins.
void finalize_and_exit() override
Finalizes PDI and exits application.
void add_datatype(const std::string &name, Datatype_template_parser parser) override
Context::add_datatype proxy for plugins.
Data_descriptor & desc(const std::string &name) override
Context::desc proxy for plugins.
Data_descriptor & desc(const char *name) override
Context::desc proxy for plugins.
Callbacks & callbacks() override
Context::callbacks proxy for plugins.
Definition: context.h:44
std::function< Datatype_template_ptr(Context &, PC_tree_t)> Datatype_template_parser
A function that parses a PC_tree_t to create a datatype_template.
Definition: context.h:65
Definition: data_descriptor.h:39
Wrapper for spdlog::logger with additional pattern getter method.
Definition: logger.h:42
Definition: array_datatype.h:38
std::shared_ptr< const Datatype_template > Datatype_template_ptr
Definition: pdi_fwd.h:76