PDI 0.6.1

Data exchange made easy

record_datatype.h
1 /*******************************************************************************
2  * Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
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_RECORD_DATATYPE_H_
26 #define PDI_RECORD_DATATYPE_H_
27 
28 #include <string>
29 #include <vector>
30 
31 #include <pdi/pdi_fwd.h>
32 #include <pdi/datatype.h>
33 
34 
35 namespace PDI {
36 
41 class PDI_EXPORT Record_datatype:
42  public Datatype
43 {
44 public:
47  class Member
48  {
50  size_t m_displacement;
51 
53  Datatype_uptr m_type;
54 
56  std::string m_name;
57 
58  public:
65  Member(size_t displacement, Datatype_uptr type, const std::string& name);
66 
71  Member(const Member& o);
72 
77  size_t displacement() const;
78 
83  const Datatype& type() const;
84 
89  const std::string& name() const;
90 
96  bool operator==(const Member& rhs) const;
97 
103  bool operator!=(const Member& rhs) const;
104 
105  };
106 
107 private:
109  std::vector<Member> m_members;
110 
112  size_t m_buffersize;
113 
114 public:
121  Record_datatype(std::vector<Member>&& members, size_t size);
122 
125  const std::vector<Member>& members() const;
126 
127 
128  Datatype_template_uptr clone() const override;
129 
130  Datatype_uptr clone_type() const override;
131 
132  Datatype_uptr densify() const override;
133 
134  Datatype_uptr evaluate(Context&) const override;
135 
136  bool dense() const override;
137 
138  size_t datasize() const override;
139 
140  size_t buffersize() const override;
141 
142  size_t alignment() const override;
143 
144  bool simple() const override;
145 
146  void* data_to_dense_copy(void* to, const void*) const override;
147 
148  void* data_from_dense_copy(void* to, const void*) const override;
149 
150  void destroy_data(void*) const override;
151 
152  std::string debug_string() const override;
153 
154  bool operator== (const Datatype&) const override;
155 
156 };
157 
158 } // namespace PDI
159 
160 #endif // PDI_RECORD_DATATYPE_H_
Definition: context.h:41
A Datatype is a Datatype_template that accepts no argument.
Definition: datatype.h:42
std::unique_ptr< Datatype_template > Datatype_template_uptr
Definition: pdi_fwd.h:58
std::unique_ptr< Datatype > Datatype_uptr
Definition: pdi_fwd.h:62
A Record_datatype is a Datatype that represents a fixed number of elements of potentially different t...
Definition: record_datatype.h:41
Definition: array_datatype.h:33
A Member is one of the elements inside a Record_datatype.
Definition: record_datatype.h:47