PDI 1.4.3

the PDI data interface

datatype_template.h
1 /*******************************************************************************
2  * Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
3  * Copyright (C) 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_DATATYPE_TEMPLATE_H_
27 #define PDI_DATATYPE_TEMPLATE_H_
28 
29 #include <memory>
30 #include <string>
31 #include <unordered_map>
32 
33 #include <paraconf.h>
34 
35 #include <pdi/expression.h>
36 #include <pdi/pdi_fwd.h>
37 
38 namespace PDI {
39 
40 using Attributes_map = std::unordered_map<std::string, Expression>;
41 
42 class PDI_EXPORT Datatype_template
43 {
44 protected:
46 
47 public:
52  Datatype_template(const Attributes_map& attributes = {});
53 
60  Datatype_template(PC_tree_t datatype_tree);
61 
64  virtual ~Datatype_template();
65 
70  virtual Datatype_template_uptr clone() const = 0;
71 
77  virtual Datatype_uptr evaluate(Context& ctx) const = 0;
78 
84  Expression attribute(const std::string& attribute_name) const;
85 
90  const Attributes_map& attributes() const;
91 
97  static void load_basic_datatypes(Context& ctx);
98 
105  static void load_user_datatypes(Context& ctx, PC_tree_t types_tree);
106 
107 };
108 
109 } // namespace PDI
110 
111 #endif // PDI_DATATYPE_TEMPLATE_H_
112 
Definition: context.h:44
Definition: expression.h:41
std::unique_ptr< Datatype_template > Datatype_template_uptr
Definition: pdi_fwd.h:70
std::unique_ptr< Datatype > Datatype_uptr
Definition: pdi_fwd.h:74
std::unordered_map< std::string, Expression > Attributes_map
Definition: datatype_template.h:40
Definition: datatype_template.h:42
Definition: array_datatype.h:37
Attributes_map m_attributes
Definition: datatype_template.h:45