19 #define TECA_DATASET_STATIC_NEW(T) \
23 return p_##T(new T); \
26 std::shared_ptr<T> shared_from_this() \
28 return std::static_pointer_cast<T>( \
29 teca_dataset::shared_from_this()); \
32 std::shared_ptr<T const> shared_from_this() const \
34 return std::static_pointer_cast<T const>( \
35 teca_dataset::shared_from_this()); \
39 #define TECA_DATASET_NEW_INSTANCE() \
40 virtual p_teca_dataset new_instance() const override\
46 #define TECA_DATASET_NEW_COPY() \
47 virtual p_teca_dataset new_copy() const override \
49 p_teca_dataset o = this->new_instance(); \
50 o->copy(this->shared_from_this()); \
54 virtual p_teca_dataset new_shallow_copy() override \
56 p_teca_dataset o = this->new_instance(); \
57 o->shallow_copy(this->shared_from_this()); \
63 #define TECA_DATASET_PROPERTY(T, name) \
65 void set_##name(const T &val) \
70 const T &get_##name() const \
81 #define TECA_DATASET_METADATA(key, T, len) \
82 TECA_DATASET_METADATA_V(T, key, len) \
83 TECA_DATASET_METADATA_A(T, key, len) \
84 TECA_DATASET_METADATA_ ## len (T, key)
87 #define TECA_DATASET_METADATA_1(T, key) \
88 void set_##key(const T & val_1) \
90 this->get_metadata().set<T>(#key, val_1); \
93 int get_##key(T &val_1) const \
95 return this->get_metadata().get<T>( \
99 #define TECA_DATASET_METADATA_2(T, key) \
100 void set_##key(const T & val_1, const T & val_2) \
102 this->get_metadata().set<T>( \
103 #key, {val_1, val_2}); \
106 int get_##key(T &val_1, T &val_2) const \
108 std::vector<T> vals; \
109 if (this->get_metadata().get<T>(#key, vals)) \
116 #define TECA_DATASET_METADATA_3(T, key) \
117 void set_##key(const T & val_1, const T & val_2, \
120 this->get_metadata().set<T>(#key, \
121 {val_1, val_2, val_3}); \
124 int get_##key(T &val_1, T &val_2, T &val_3) const \
126 std::vector<T> vals; \
127 if (this->get_metadata().get<T>(#key, vals)) \
135 #define TECA_DATASET_METADATA_4(T, key) \
136 void set_##key(const T & val_1, const T & val_2, \
137 const T & val_3, const T & val_4) \
139 this->get_metadata().set<T>(#key, \
140 {val_1, val_2, val_3, val_4}); \
143 #define TECA_DATASET_METADATA_6(T, key) \
144 void set_##key(const T & val_1, const T & val_2, \
145 const T & val_3, const T & val_4, \
146 const T & val_5, const T & val_6) \
148 this->get_metadata().set<T>(#key, \
149 {val_1, val_2, val_3, \
150 val_4, val_5, val_6}); \
153 #define TECA_DATASET_METADATA_8(T, key) \
154 void set_##key(const T & val_1, const T & val_2, \
155 const T & val_3, const T & val_4, \
156 const T & val_5, const T & val_6, \
157 const T & val_7, const T & val_8) \
159 this->get_metadata().set<T>(#key, \
160 {val_1, val_2, val_3, val_4, val_5, \
161 val_6, val_7, val_8}); \
164 #define TECA_DATASET_METADATA_V(T, key, len) \
165 void set_##key(const std::vector<T> &vals) \
167 if (vals.size() != len) \
169 TECA_ERROR(#key " requires " #len " values") \
171 this->get_metadata().set<T>(#key, vals); \
174 int get_##key(std::vector<T> &vals) const \
176 return this->get_metadata().get<T>(#key, vals); \
179 void set_##key(const p_teca_variant_array &vals) \
181 if (vals->size() != len) \
183 TECA_ERROR(#key " requires " #len " values") \
185 this->get_metadata().set(#key, vals); \
188 int get_##key(p_teca_variant_array vals) const \
190 return this->get_metadata().get(#key, vals); \
193 void set_##key(const std::initializer_list<T> &l) \
195 std::vector<T> vals(l); \
196 if (vals.size() != len) \
198 TECA_ERROR(#key " requires " #len " values") \
200 this->get_metadata().set<T>(#key, vals); \
203 #define TECA_DATASET_METADATA_A(T, key, len) \
204 void set_##key(const T *vals) \
206 this->get_metadata().set<T>(#key, vals, len); \
209 int get_##key(T *vals) const \
211 return this->get_metadata().get<T>( \
223 TECA_DATASET_METADATA(index_request_key, std::string, 1)
228 virtual int get_request_index(
long &val)
const;
229 virtual int set_request_index(
const std::string &key,
long val);
230 virtual int set_request_index(
long val);
234 explicit operator bool()
const noexcept
235 {
return !this->empty(); }
238 virtual bool empty()
const noexcept
242 virtual p_teca_dataset new_instance()
const = 0;
246 virtual p_teca_dataset new_copy()
const = 0;
247 virtual p_teca_dataset new_shallow_copy() = 0;
250 virtual std::string get_class_name()
const = 0;
253 virtual int get_type_code()
const = 0;
257 virtual void copy(
const const_p_teca_dataset &other);
258 virtual void shallow_copy(
const p_teca_dataset &other);
261 virtual void copy_metadata(
const const_p_teca_dataset &other);
264 virtual void swap(
const p_teca_dataset &other);
277 virtual int to_stream(std::ostream &)
const;
278 virtual int from_stream(std::istream &);
286 void operator=(
const p_teca_dataset &other) =
delete;
287 void operator=(p_teca_dataset &&other) =
delete;