fileio.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 
32 #ifndef RACK_FILE_IO
33 #define RACK_FILE_IO
34 
35 #include <string>
36 
37 #include <drain/RegExp.h>
38 
39 #include <drain/prog/CommandBank.h>
40 #include <drain/prog/CommandInstaller.h>
41 
42 #include <drain/util/FileInfo.h>
43 //#include <drain/image/FileGeoTIFF.h>
44 
45 #include "hi5/Hi5.h"
46 
47 #include "resources.h"
48 
49 namespace rack {
50 
52 // Edited 2017/07 such that also files without extension are considered h5 files.
53 extern
55 
57 //extern
58 //const drain::RegExp tiffFileExtension;
59 //const drain::FileInfo fileInfoTIFF;
60 
62 //extern
63 //const drain::RegExp pngFileExtension;
64 
66 //extern
67 //const drain::RegExp pnmFileExtension;
68 
70 extern
72 
74 extern
76 
78 extern
80 
81 class CmdOutputFile : public drain::SimpleCommand<std::string> {
82 
83 public:
84 
85  inline
86  CmdOutputFile() : drain::SimpleCommand<>(__FUNCTION__, "Output data to HDF5, text, image or GraphViz file. See also: --image, --outputRawImages.",
87  "filename", "", "<filename>.[h5|hdf5|png|pgm|txt|dat|mat|dot]|-") {
88  };
89 
90  //void writeGeoTIFF(const drain::image::Image & src, const std::string & filename) const;
91 
92  void writeProfile(const Hi5Tree & src, const std::string & filename) const;
93 
94  void writeSamples(const Hi5Tree & src, const std::string & filename) const;
95 
96  void writeDotGraph(const Hi5Tree & src, const std::string & filename, ODIMPathElem::group_t selector = (ODIMPathElem::ROOT | ODIMPathElem::IS_INDEXED)) const;
97 
98  void exec() const;
99 
100 
101 
102 };
103 
104 class CmdOutputTree : public drain::SimpleCommand<std::string> {
105 
106 public:
107 
108  inline
109  CmdOutputTree() : drain::SimpleCommand<>(__FUNCTION__, "Output data as simple tree structure.",
110  "filename", "", "<filename>|-") {
111  };
112 
113  void exec() const;
114 
115 
116 };
117 
118 
119 /*
120 class CmdOutputPanel : public drain::BasicCommand {
121 
122 public:
123 
124  inline
125  CmdOutputPanel() : drain::BasicCommand(__FUNCTION__, "Save SVG panel of latest images. See also: --image, --outputRawImages.") {
126  getParameters().link("filename", filename="");
127  getParameters().link("layout", layout, "basic");
128  };
129 
130  CmdOutputPanel(const CmdOutputPanel & cmd) : drain::BasicCommand(cmd) {
131  getParameters().copyStruct(cmd.getParameters(), cmd, *this);
132  }
133 
134 
135  void exec() const;
136 
137 
138  std::string layout;
139  std::string filename;
140 
141  void appendImage(TreeSVG & group, const std::string & prefix, drain::VariableMap & vmap,
142  const drain::Point2D<double> & location, const drain::image::Image & image, drain::BBox & bbox) const;
143 };
144 */
145 
146 
147 class FileModule : public drain::CommandModule<> { // : public drain::CommandGroup {
148 
149 public:
150 
152  //virtual void initialize();
153 
154 };
155 
156 }
157 
158 #endif
159 
160 // Rack
Container and execution tools for commands derived from Command.
Definition: CommandBank.h:54
Combines command installation and sectioning.
Definition: CommandInstaller.h:159
Definition: RegExp.h:58
A single-parameter command.
Definition: Command.h:501
Definition: fileio.h:81
void writeProfile(const Hi5Tree &src, const std::string &filename) const
Definition: file-prof.cpp:78
void exec() const
Run the command with current parameter values.
Definition: fileio.cpp:325
void writeSamples(const Hi5Tree &src, const std::string &filename) const
Definition: file-sample.cpp:80
Definition: fileio.h:104
void exec() const
Definition: fileio.cpp:822
Definition: fileio.h:147
static const group_t IS_INDEXED
Group index mask for groups that have an index.
Definition: ODIMPath.h:156
static const group_t ROOT
Definition: ODIMPath.h:99
drain::Flagger::ivalue_t group_t
In H5, "groups" correspond to "directories" or "folders" in Unix and Windows.
Definition: ODIMPath.h:91
CommandBank & getCommandBank()
Global program command registry. Optional utility.
Definition: CommandBank.cpp:51
Definition: DataSelector.cpp:44
const drain::RegExp arrayFileExtension(".*\\.(mat)$", REG_EXTENDED|REG_ICASE)
Syntax for recognising numeric array files (in plain text format anyway).
Definition: fileio.h:75
const drain::RegExp textFileExtension(".*\\.(txt)$", REG_EXTENDED|REG_ICASE)
Syntax for recognising hdf5 files.
Definition: fileio.h:71
const drain::RegExp h5FileExtension
Syntax for recognising hdf5 files.
const drain::RegExp sampleFileExtension(".*\\.(dat)$", REG_EXTENDED|REG_ICASE)
Syntax for sparsely resampled data.
Definition: fileio.h:79