PDI 1.6.0

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/context.h>
31#include <pdi/callbacks.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;
46public:
51
57 Context_proxy(Context& ctx, const std::string& logger_name, PC_tree_t logging_tree);
58
63 void setup_logger(const std::string& logger_name, PC_tree_t logging_tree);
64
67 Data_descriptor& desc(const std::string& name) override;
68
71 Data_descriptor& desc(const char* name) override;
72
75 Data_descriptor& operator[](const std::string& name) override;
76
79 Data_descriptor& operator[](const char* name) override;
80
83 Iterator begin() override;
84
87 Iterator end() override;
88
93 void event(const char* name) override;
94
99 Logger& logger() override;
100
106
109 Datatype_template_ptr datatype(PC_tree_t node) override;
110
113 void add_datatype(const std::string& name, Datatype_template_parser parser) override;
114
117 Callbacks& callbacks() override;
118
119 void finalize_and_exit() override;
120};
121
122} //namespace PDI
123
124#endif // PDI_CONTEXT_PROXY_H_
Definition: callbacks.h:39
An iterator used to go through the descriptor store.
Definition: context.h:50
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.
Data_descriptor & operator[](const std::string &name) override
Context::operator[] proxy for plugins.
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.
Data_descriptor & operator[](const char *name) override
Context::operator[] proxy for plugins.
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:45
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:40
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