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