TECA
teca_cartesian_mesh_reader.h
1 #ifndef teca_cartesian_mesh_reader_h
2 #define teca_cartesian_mesh_reader_h
3 
4 #include "teca_algorithm.h"
5 #include "teca_metadata.h"
6 #include "teca_shared_object.h"
7 #include "teca_cartesian_mesh.h"
8 
9 #include <vector>
10 #include <string>
11 #include <mutex>
12 
13 
14 TECA_SHARED_OBJECT_FORWARD_DECL(teca_cartesian_mesh_reader)
15 
16 
30 {
31 public:
32  TECA_ALGORITHM_STATIC_NEW(teca_cartesian_mesh_reader)
33  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_cartesian_mesh_reader)
34  TECA_ALGORITHM_CLASS_NAME(teca_cartesian_mesh_reader)
36 
37  // report/initialize to/from Boost program options
38  // objects.
39  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
40  TECA_SET_ALGORITHM_PROPERTIES()
41 
42  // the file from which data will be read.
43  TECA_ALGORITHM_PROPERTY(std::string, file_name)
44 
45  // name of the column containing index values.
46  // if this is not empty the reader will operate
47  // in parallel mode serving up requested indices
48  // on demand. otherwise rank 0 reads the entire
49  // cartesian_mesh regardless of what is requested.
50  TECA_ALGORITHM_PROPERTY(std::string, index_column)
51 
52  // when set a column named "original_ids" is placed
53  // into the output. values map back to the row number
54  // of the source dataset. By default this is off.
55  TECA_ALGORITHM_PROPERTY(int, generate_original_ids)
56 
57  // name of columns to copy directly into metadata
58  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, metadata_column_name)
59 
60  // keys that identify metadata columns
61  TECA_ALGORITHM_VECTOR_PROPERTY(std::string, metadata_column_key)
62 
63  // add a metadata column with the given key
64  void add_metadata_column(const std::string &column, const std::string &key)
65  {
66  this->append_metadata_column_name(column);
67  this->append_metadata_column_key(key);
68  }
69 
70  // removes all metadata columns
71  void clear_metadata_columns()
72  {
73  this->clear_metadata_column_names();
74  this->clear_metadata_column_keys();
75  }
76 
77 protected:
79 
80 private:
81  teca_metadata get_output_metadata(unsigned int port,
82  const std::vector<teca_metadata> &input_md) override;
83 
84  const_p_teca_dataset execute(unsigned int port,
85  const std::vector<const_p_teca_dataset> &input_data,
86  const teca_metadata &request) override;
87 
88  void set_modified() override;
89  void clear_cached_metadata();
90 
91 private:
92  std::string file_name;
93  std::string index_column;
94  int generate_original_ids;
95  std::vector<std::string> metadata_column_names;
96  std::vector<std::string> metadata_column_keys;
97 
100 };
101 
102 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_cartesian_mesh_reader::teca_cartesian_mesh_reader_internals
Definition: teca_cartesian_mesh_reader.cxx:23
teca_cartesian_mesh_reader
a reader for data stored in binary cartesian_mesh format
Definition: teca_cartesian_mesh_reader.h:30
teca_algorithm
Definition: teca_algorithm.h:25