1 #ifndef teca_table_collection_h
2 #define teca_table_collection_h
4 #include "teca_config.h"
5 #include "teca_table.h"
18 using allocator = teca_dataset::allocator;
22 p_teca_table_collection
New()
29 template<
typename nT,
typename... oT>
30 void declare_set(nT &&a_name, oT &&...args);
34 void declare(nT &&a_name);
38 int append(p_teca_table array);
39 int append(
const std::string &name, p_teca_table array);
42 int set(
unsigned int i, p_teca_table array);
43 int set(
const std::string &name, p_teca_table array);
46 int remove(
unsigned int i);
47 int remove(
const std::string &name);
50 unsigned int size()
const noexcept
51 {
return m_tables.size(); }
54 p_teca_table get(
unsigned int i)
55 {
return m_tables[i]; }
57 const_p_teca_table get(
unsigned int i)
const
58 {
return m_tables[i]; }
61 bool has(
const std::string &name)
const;
64 p_teca_table get(
const std::string &name);
65 const_p_teca_table get(
const std::string &name)
const;
67 p_teca_table operator[](
const std::string &name)
68 {
return this->get(name); }
70 const_p_teca_table operator[](
const std::string &name)
const
71 {
return this->get(name); }
74 std::string &get_name(
unsigned int i)
75 {
return m_names[i]; }
77 const std::string &get_name(
unsigned int i)
const
78 {
return m_names[i]; }
81 std::string get_class_name()
const
82 {
return "teca_table_collection"; }
85 int get_type_code()
const
89 void copy(
const const_p_teca_table_collection &other,
90 allocator alloc = allocator::malloc);
96 void swap(p_teca_table_collection &other);
104 int to_stream(std::ostream &)
const;
105 int from_stream(std::istream &) {
return -1; }
116 using name_vector_t = std::vector<std::string>;
117 using array_vector_t = std::vector<p_teca_table>;
118 using name_array_map_t = std::map<std::string,unsigned int>;
120 name_vector_t m_names;
121 array_vector_t m_tables;
122 name_array_map_t m_name_array_map;
126 template<
typename nT,
typename... oT>
127 void teca_table_collection::declare_set(nT &&a_name, oT &&... args)
129 this->declare(std::forward<nT>(a_name));
130 this->declare_set(args...);
134 template<
typename nT>
135 void teca_table_collection::declare(nT &&a_name)
137 unsigned int id = m_tables.size();
138 m_names.emplace_back(std::forward<nT>(a_name));
139 m_tables.emplace_back(teca_table::New());
140 m_name_array_map.emplace(std::forward<nT>(a_name),
id);
Serialize objects into a binary stream.
Definition: teca_binary_stream.h:17
A collection of named tables.
Definition: teca_table_collection.h:16
void shallow_copy(const p_teca_table_collection &other)
shallow copy
void copy(const const_p_teca_table_collection &other, allocator alloc=allocator::malloc)
deep copy using the passed allocator for new allocations
p_teca_error_handler error_handler TECA_EXPORT
The global error handler instance.
TECA_EXPORT bool append(teca_variant_array *varr, PyObject *obj)
Append values from the object to the variant array.
Definition: teca_py_array.h:221
TECA_EXPORT bool set(teca_variant_array *varr, unsigned long i, PyObject *obj)
Set i'th element of the variant array to the value of the object.
Definition: teca_py_array.h:305
auto New(size_t n_elem, teca_variant_array::allocator alloc=teca_variant_array::allocator::malloc)
Definition: teca_variant_array_util.h:269