IODA Bundle
Type_Provider.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * (C) Copyright 2020-2021 UCAR
4  *
5  * This software is licensed under the terms of the Apache Licence Version 2.0
6  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7  */
8 /*! \addtogroup ioda_internals_engines_types
9  *
10  * @{
11  * \file Type_Provider.h
12  * \brief Frontend/backend bindings for the type system.
13  */
14 #include <initializer_list>
15 #include <typeindex>
16 #include <typeinfo>
17 
18 #include "ioda/defs.h"
19 
20 namespace ioda {
21 class Type; // This file is included by Type.h.
22 
23 namespace detail {
24 /// \brief Who owns (and should free) pointers passed across the
25 /// frontend / backend interface?
26 /// \ingroup ioda_internals_engines_types
27 enum class PointerOwner {
28  Engine, ///< The backend engine frees pointers that it provides.
29  Caller ///< The user has to free pointers.
30 };
31 
32 /// \brief Backends implement type providers in conjunction with
33 /// Attributes, Has_Attributes, Variables and Has_Variables.
34 /// The backend objects pass through their underlying logic to represent types.
35 /// \ingroup ioda_internals_engines_types
37 public:
38  virtual ~Type_Provider();
39  /// Make a basic object type, like a double, a float, or a char.
40  virtual Type makeFundamentalType(std::type_index type) const;
41  /// Make an array type, like a double[2].
42  virtual Type makeArrayType(std::initializer_list<Dimensions_t> dimensions,
43  std::type_index typeOuter, std::type_index typeInner) const;
44  /// Make a variable-length string type.
45  virtual Type makeStringType(size_t string_length, std::type_index typeOuter) const;
46 
47  /// When a pointer is passed from the backend to the frontend, who has to free it?
48  virtual PointerOwner getReturnedPointerOwner() const;
49 };
50 } // namespace detail
51 } // namespace ioda
52 
53 /// @}
Represents the "type" (i.e. integer, string, float) of a piece of data.
Definition: Type.h:123
Backends implement type providers in conjunction with Attributes, Has_Attributes, Variables and Has_V...
Definition: Type_Provider.h:36
Common preprocessor definitions used throughout IODA.
#define IODA_DL
A preprocessor tag that indicates that a symbol is to be exported/imported.
Definition: defs.h:110
PointerOwner
Who owns (and should free) pointers passed across the frontend / backend interface?
Definition: Type_Provider.h:27
@ Caller
The user has to free pointers.
@ Engine
The backend engine frees pointers that it provides.