BuiltinDataType.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_BUILTIN_DATA_TYPE_H
24 #define VARIANT_TOPIC_TOOLS_BUILTIN_DATA_TYPE_H
25 
28 
29 namespace variant_topic_tools {
33  public DataType {
34  friend class DataType;
35  friend class DataTypeRegistry;
36  public:
40 
43  BuiltinDataType(const BuiltinDataType& src);
44 
47  BuiltinDataType(const DataType& src);
48 
51  virtual ~BuiltinDataType();
52 
55  BuiltinDataType& operator=(const DataType& src);
56 
59  bool isNumeric() const;
60 
61  protected:
64  class Impl :
65  public DataType::Impl {
66  public:
69  Impl(const std::string& identifier);
70 
73  virtual ~Impl();
74 
78  const std::string& getIdentifier() const;
79 
83  virtual bool isNumeric() const = 0;
84 
87  std::string identifier;
88  };
89 
93  template <typename T> class ImplT :
94  public Impl {
95  public:
96  BOOST_STATIC_ASSERT(type_traits::IsBuiltin<T>::value);
97 
100  ImplT(const std::string& identifier);
101 
104  virtual ~ImplT();
105 
109  const std::type_info& getTypeInfo() const;
110 
114  size_t getSize() const;
115 
119  bool isFixedSize() const;
120 
124  bool isSimple() const;
125 
128  bool isNumeric() const;
129 
132  Serializer createSerializer(const DataType& type) const;
133 
136  Variant createVariant(const DataType& type) const;
137  };
138 
141  template <typename T> static BuiltinDataType create(const
142  std::string& identifier);
143  };
144 };
145 
146 #include <variant_topic_tools/BuiltinDataType.tpp>
147 
148 #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)
BuiltinDataType & operator=(const DataType &src)
Assignment operator.
virtual Serializer createSerializer(const DataType &type) const =0
Create a serializer for this data type (abstract declaration)
Built-in data type implementation.
Header file providing the built-in type traits.
bool isNumeric() const
True, if this built-in data type is numeric.
virtual const std::type_info & getTypeInfo() const
Retrieve the type information associated with this data type.
Definition: DataType.cpp:144
const std::string & getIdentifier() const
Retrieve the identifier representing this data type (implementation)
virtual bool isSimple() const =0
True, if this data type represents a simple data type (abstract declaration)
Data type implementation.
Definition: DataType.h:168
BuiltinDataType()
Default constructor.
virtual bool isNumeric() const =0
True, if this built-in data type is numeric (abstract declaration)
static BuiltinDataType create(const std::string &identifier)
Create a built-in data type.
virtual bool isFixedSize() const =0
True, if this data type represents a fixed-size data type (abstract declaration)
std::string identifier
The identifier representing this built-in data type.
virtual size_t getSize() const =0
Retrieve the size of the instances of this data type (abstract declaration)
Built-in data type implementation (templated strong-typed version)


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