Alexandria  2.25.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GridContainerToTable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef GRIDCONTAINER_GRIDCONTAINERTOTABLE_H
20 #define GRIDCONTAINER_GRIDCONTAINERTOTABLE_H
21 
23 #include "Table/Table.h"
25 #include <vector>
26 
27 namespace Euclid {
28 namespace GridContainer {
29 
36 template <typename T>
38  typedef T table_cell_t;
39 
40  static T serialize(T v) {
41  return v;
42  }
43 };
44 
48 template <>
51 
53  return qn.qualifiedName();
54  }
55 };
56 
62 template <typename T, typename Enable = void>
64  static_assert(!std::is_same<T, T>::value, "Specialization of GridCellToTable required");
65 
74  static void addColumnDescriptions(const T& c, std::vector<Table::ColumnDescription>& columns);
75 
83  static void addCells(const T& c, std::vector<Table::Row::cell_type>& row);
84 };
85 
89 template <typename T>
90 struct GridCellToTable<T, typename std::enable_if<std::is_arithmetic<T>::value>::type> {
91 
93  columns.emplace_back("value", typeid(T));
94  }
95 
96  static void addCells(const T& c, std::vector<Table::Row::cell_type>& row) {
97  row.emplace_back(c);
98  }
99 };
100 
105 template <typename GridCellManager, typename... AxesTypes>
106 Table::Table gridContainerToTable(const GridContainer<GridCellManager, AxesTypes...>& grid);
107 
108 } // end of namespace GridContainer
109 } // end of namespace Euclid
110 
112 
113 #endif // GRIDCONTAINER_GRIDCONTAINERTOTABLE_H
const std::string & qualifiedName() const
Returns the qualified name as a string.
STL class.
static void addColumnDescriptions(const T &, std::vector< Table::ColumnDescription > &columns)
static void addColumnDescriptions(const T &c, std::vector< Table::ColumnDescription > &columns)
static void addCells(const T &c, std::vector< Table::Row::cell_type > &row)
Represents a table.
Definition: Table.h:49
STL class.
Table::Table gridContainerToTable(const GridContainer< GridCellManager, AxesTypes...> &grid)
Represents a name qualified with a set of groups.
Definition: QualifiedName.h:66
static table_cell_t serialize(const Euclid::XYDataset::QualifiedName &qn)
T emplace_back(T...args)