Dev Essential
Loading...
Searching...
No Matches
mapper_base_types.h
Go to the documentation of this file.
1
19
20#ifndef _MAPPER_BASE_HEADER
21#define _MAPPER_BASE_HEADER
22
25
26#include <type_traits>
27
28namespace ddl {
29namespace mapping {
30
35template <typename T>
36class MapperElementBase : public T {
37public:
43 MapperElementBase(std::string name, Properties properties)
44 : _name(std::move(name)), _properties(std::move(properties))
45 {
46 }
47
50 ~MapperElementBase() override = default;
51
56 const std::string& getName() const override
57 {
58 return _name;
59 }
60
65 const Properties& getProperties() const override
66 {
67 return _properties;
68 }
69
75 const Property& getProperty(const std::string& property_name) const
76 {
77 const auto found = _properties.find(property_name);
78 if (found != _properties.end()) {
79 return found->second;
80 }
81 else {
82 throw std::runtime_error("Property with name " + property_name + " was not found");
83 }
84 }
85
86private:
87 std::string _name;
88 Properties _properties;
89};
90
95template <typename SourceType>
97public:
98 std::string getType() const override
99 {
100 return SourceType::getType();
101 }
103 {
104 return SourceType::getDefaultProperties();
105 }
106 std::shared_ptr<Source> make(std::string name, Properties properties) const
107 {
108 return std::make_shared<SourceType>(std::move(name), std::move(properties));
109 }
110};
111
116template <typename TargetType>
118public:
119 std::string getType() const override
120 {
121 return TargetType::getType();
122 }
124 {
125 return TargetType::getDefaultProperties();
126 }
127 std::shared_ptr<Target> make(std::string name, Properties properties) const override
128 {
129 return std::make_shared<TargetType>(std::move(name), std::move(properties));
130 }
131};
132
137template <typename FunctionType>
139public:
140 std::string getType() const override
141 {
142 return FunctionType::getType();
143 }
145 {
146 return FunctionType::getDefaultProperties();
147 }
148 std::shared_ptr<Function> make(std::string name, Properties properties) const override
149 {
150 return std::make_shared<FunctionType>(std::move(name), std::move(properties));
151 }
152};
153
158public:
163
164public:
170 static std::shared_ptr<const PlainSourceValue> make(const std::string& value);
171};
172
173} // namespace mapping
174} // namespace ddl
175#endif // _MAPPER_BASE_HEADER
static std::shared_ptr< const PlainSourceValue > make(const std::string &value)
Constant value factory to create a PlainSourceValue reference.
FunctionFactory implementation template.
Definition mapper_base_types.h:138
Properties getDefaultProperties() const override
Get the default properties to initialize the Source, Target or Function with.
Definition mapper_base_types.h:144
std::string getType() const override
Get the Type as string.
Definition mapper_base_types.h:140
std::shared_ptr< Function > make(std::string name, Properties properties) const override
Factory create function which creates a Source, Target or Function instance with a name and intialize...
Definition mapper_base_types.h:148
~MapperElementBase() override=default
DTOR.
const std::string & getName() const override
Get the Name.
Definition mapper_base_types.h:56
const Property & getProperty(const std::string &property_name) const
Get the Property.
Definition mapper_base_types.h:75
const Properties & getProperties() const override
Get the Properties.
Definition mapper_base_types.h:65
MapperElementBase(std::string name, Properties properties)
CTOR.
Definition mapper_base_types.h:43
Property class representing a pair of value and its type.
Definition mapper_interfaces.h:208
SourceFactory implementation template.
Definition mapper_base_types.h:96
std::shared_ptr< Source > make(std::string name, Properties properties) const
Factory create function which creates a Source, Target or Function instance with a name and intialize...
Definition mapper_base_types.h:106
Properties getDefaultProperties() const override
Get the default properties to initialize the Source, Target or Function with.
Definition mapper_base_types.h:102
std::string getType() const override
Get the Type as string.
Definition mapper_base_types.h:98
TargetFactory implementation template.
Definition mapper_base_types.h:117
std::shared_ptr< Target > make(std::string name, Properties properties) const override
Factory create function which creates a Source, Target or Function instance with a name and intialize...
Definition mapper_base_types.h:127
Properties getDefaultProperties() const override
Get the default properties to initialize the Source, Target or Function with.
Definition mapper_base_types.h:123
std::string getType() const override
Get the Type as string.
Definition mapper_base_types.h:119
definition of the mapping namespace
Definition ddl.h:50
SpecificMapperFactory< Source > SourceFactory
A Source factory to create a Source.
Definition mapper_interfaces.h:504
std::unordered_map< std::string, Property > Properties
Properties class as set of key - property value pairs This proerties are used to adjust the readers a...
Definition mapper_interfaces.h:331
SpecificMapperFactory< Target > TargetFactory
A Target factory to create a Target.
Definition mapper_interfaces.h:556
SpecificMapperFactory< Function > FunctionFactory
A Function factory to create a Function.
Definition mapper_interfaces.h:610
definition of the ddl namespace
Definition codec.h:21