ArrayDataType.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2014 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
23 #ifndef VARIANT_TOPIC_TOOLS_ARRAY_DATA_TYPE_H
24 #define VARIANT_TOPIC_TOOLS_ARRAY_DATA_TYPE_H
25 
28 
32  class ArrayDataType :
33  public DataType {
34  friend class ArraySerializer;
35  friend class ArrayVariant;
36  friend class DataType;
37  friend class DataTypeRegistry;
38  public:
41  ArrayDataType();
42 
45  ArrayDataType(const ArrayDataType& src);
46 
49  ArrayDataType(const DataType& src);
50 
53  virtual ~ArrayDataType();
54 
57  const DataType& getMemberType() const;
58 
61  size_t getNumMembers() const;
62 
65  bool isDynamic() const;
66 
69  ArrayDataType& operator=(const DataType& src);
70 
71  protected:
74  class Impl :
75  public DataType::Impl {
76  public:
79  Impl(const DataType& memberType);
80 
83  virtual ~Impl();
84 
88  const std::string& getIdentifier() const;
89 
93  virtual size_t getNumMembers() const = 0;
94 
98  virtual bool isDynamic() const = 0;
99 
102  mutable std::string identifier;
103 
107  };
108 
111  class ImplV :
112  public Impl {
113  public:
116  ImplV(const DataType& memberType, size_t numMembers);
117 
120  virtual ~ImplV();
121 
125  size_t getNumMembers() const;
126 
130  size_t getSize() const;
131 
135  bool isDynamic() const;
136 
140  bool isFixedSize() const;
141 
145  bool isSimple() const;
146 
149  Serializer createSerializer(const DataType& type) const;
150 
153  Variant createVariant(const DataType& type) const;
154 
157  size_t numMembers;
158  };
159 
162  template <typename T> class ImplT :
163  public Impl {
164  public:
165  BOOST_STATIC_ASSERT(type_traits::IsArray<T>::value);
166 
169  ImplT();
170 
173  virtual ~ImplT();
174 
178  const std::type_info& getTypeInfo() const;
179 
183  size_t getNumMembers() const;
184 
188  bool isDynamic() const;
189 
193  size_t getSize() const;
194 
198  bool isFixedSize() const;
199 
203  bool isSimple() const;
204 
207  Serializer createSerializer(const DataType& type) const;
208 
211  Variant createVariant(const DataType& type) const;
212  };
213 
217  ArrayDataType(const DataType& memberType, size_t numMembers);
218 
222  template <typename T> static ArrayDataType create();
223 
227  template <typename T, size_t N> static ArrayDataType create(typename
228  boost::enable_if<boost::type_traits::ice_eq<N, 0> >::type* = 0);
229 
233  template <typename T, size_t N> static ArrayDataType create(typename
234  boost::disable_if<boost::type_traits::ice_eq<N, 0> >::type* = 0);
235  };
236 };
237 
238 #include <variant_topic_tools/ArrayDataType.tpp>
239 
240 #endif
Header file providing the DataType class interface.
virtual Variant createVariant(const DataType &type) const =0
Create a variant from this data type (abstract declaration)
static ArrayDataType create()
Create an array data type (version templated on the array type)
Array data type implementation (templated strong-typed version)
virtual Serializer createSerializer(const DataType &type) const =0
Create a serializer for this data type (abstract declaration)
Header file providing the array type traits.
ArrayDataType & operator=(const DataType &src)
Assignment operator.
virtual const std::type_info & getTypeInfo() const
Retrieve the type information associated with this data type.
Definition: DataType.cpp:144
ArrayDataType()
Default constructor.
size_t numMembers
The number of members of the array data type.
virtual bool isDynamic() const =0
True, if this array data type represents a dynamic array (abstract declaration)
virtual bool isSimple() const =0
True, if this data type represents a simple data type (abstract declaration)
Array data type implementation.
Definition: ArrayDataType.h:74
Data type implementation.
Definition: DataType.h:168
Array data type implementation (variant-typed version)
bool isDynamic() const
True, if this array data type represents a dynamic array.
const std::string & getIdentifier() const
Retrieve the identifier representing this data type (implementation)
virtual ~ArrayDataType()
Destructor.
DataType memberType
The member type of the array data type.
std::string identifier
The identifier representing this array data type.
virtual bool isFixedSize() const =0
True, if this data type represents a fixed-size data type (abstract declaration)
virtual size_t getNumMembers() const =0
Retrieve the number of members of this array data type (abstract declaration)
const DataType & getMemberType() const
Retrieve the member type of this array data type.
size_t getNumMembers() const
Retrieve the number of members of this array data type.
virtual size_t getSize() const =0
Retrieve the size of the instances of this data type (abstract declaration)


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49