PDI 0.6.1

Data exchange made easy

context_proxy.h
1 /*******************************************************************************
2  * Copyright (C) 2019 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of CEA nor the names of its contributors may be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  ******************************************************************************/
24 
25 #ifndef PDI_CONTEXT_PROXY_H_
26 #define PDI_CONTEXT_PROXY_H_
27 
28 #include "context.h"
29 #include "pdi_fwd.h"
30 
31 #include <functional>
32 #include <string>
33 
34 namespace PDI {
35 
36 class PDI_EXPORT Context_proxy : public Context
37 {
38  Context& m_real_context;
39  Logger_sptr m_plugin_logger;
40 public:
41  Context_proxy(Context& ctx, std::string plugin_name, PC_tree_t logging_tree);
42 
45  Data_descriptor& desc(const std::string& name) override;
46 
49  Data_descriptor& desc(const char* name) override;
50 
53  Data_descriptor& operator[](const std::string& name) override;
54 
57  Data_descriptor& operator[](const char* name) override;
58 
61  Iterator begin() override;
62 
65  Iterator end() override;
66 
69  void event(const char* name) override;
70 
73  Logger_sptr logger() const override;
74 
77  Logger_sptr pdi_core_logger() const;
78 
81  Datatype_template_uptr datatype(PC_tree_t node) override;
82 
85  void add_datatype(const std::string& name, Datatype_template_parser parser) override;
86 
87  std::function<void()> add_init_callback(const std::function<void()>& callback) override;
88 
89  std::function<void()> add_data_callback(const std::function<void(const std::string&, Ref)>& callback, const std::string& name = {}) override;
90 
91  std::function<void()> add_event_callback(const std::function<void(const std::string&)>& callback, const std::string& name = {}) override;
92 
93  std::function<void()> add_empty_desc_access_callback(const std::function<void(const std::string&)>& callback, const std::string& name = {}) override;
94 };
95 
96 } //namespace PDI
97 
98 #endif // PDI_CONTEXT_PROXY_H_
Definition: context.h:41
std::shared_ptr< spdlog::logger > Logger_sptr
A shared pointer to a logger instance.
Definition: pdi_fwd.h:67
A dynamically typed reference to data with automatic memory management and read/write locking semanti...
Definition: pdi_fwd.h:77
std::unique_ptr< Datatype_template > Datatype_template_uptr
Definition: pdi_fwd.h:58
Definition: context_proxy.h:36
Definition: data_descriptor.h:39
An iterator used to go through the descriptor store.
Definition: context.h:46
Definition: array_datatype.h:33
std::function< Datatype_template_uptr(Context &, PC_tree_t)> Datatype_template_parser
A function that parses a PC_tree_t to create a datatype_template.
Definition: context.h:62