1 #ifndef teca_table_collection_h
2 #define teca_table_collection_h
4 #include "teca_table_collection_fwd.h"
5 #include "teca_table.h"
19 p_teca_table_collection New()
26 template<
typename nT,
typename... oT>
27 void declare_set(nT &&a_name, oT &&...args);
31 void declare(nT &&a_name);
35 int append(p_teca_table array);
36 int append(
const std::string &name, p_teca_table array);
39 int set(
unsigned int i, p_teca_table array);
40 int set(
const std::string &name, p_teca_table array);
43 int remove(
unsigned int i);
44 int remove(
const std::string &name);
47 unsigned int size()
const noexcept
48 {
return m_tables.size(); }
51 p_teca_table get(
unsigned int i)
52 {
return m_tables[i]; }
54 const_p_teca_table get(
unsigned int i)
const
55 {
return m_tables[i]; }
58 bool has(
const std::string &name)
const;
61 p_teca_table get(
const std::string &name);
62 const_p_teca_table get(
const std::string &name)
const;
64 p_teca_table operator[](
const std::string &name)
65 {
return this->get(name); }
67 const_p_teca_table operator[](
const std::string &name)
const
68 {
return this->get(name); }
71 std::string &get_name(
unsigned int i)
72 {
return m_names[i]; }
74 const std::string &get_name(
unsigned int i)
const
75 {
return m_names[i]; }
78 std::string get_class_name()
const
79 {
return "teca_table_collection"; }
82 int get_type_code()
const
86 void copy(
const const_p_teca_table_collection &other);
87 void shallow_copy(
const p_teca_table_collection &other);
90 void swap(p_teca_table_collection &other);
98 int to_stream(std::ostream &)
const;
99 int from_stream(std::istream &) {
return -1; }
110 using name_vector_t = std::vector<std::string>;
111 using array_vector_t = std::vector<p_teca_table>;
112 using name_array_map_t = std::map<std::string,unsigned int>;
114 name_vector_t m_names;
115 array_vector_t m_tables;
116 name_array_map_t m_name_array_map;
120 template<
typename nT,
typename... oT>
121 void teca_table_collection::declare_set(nT &&a_name, oT &&... args)
123 this->declare(std::forward<nT>(a_name));
124 this->declare_set(args...);
128 template<
typename nT>
129 void teca_table_collection::declare(nT &&a_name)
131 unsigned int id = m_tables.size();
132 m_names.emplace_back(std::forward<nT>(a_name));
133 m_tables.emplace_back(teca_table::New());
134 m_name_array_map.emplace(std::forward<nT>(a_name),
id);