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
60extern
61const drain::FileInfo listFileInfo;
62
64extern
66
68extern
70
72extern
74
75class CmdOutputFile : public drain::SimpleCommand<std::string> {
76
77public:
78
79 inline
80 CmdOutputFile() : drain::SimpleCommand<>(__FUNCTION__, "Output data to HDF5, text, image or GraphViz file. See also: --image, --outputRawImages.",
81 "filename", "", "<filename>.[h5|hdf5|png|pgm|txt|dat|mat|dot]|-") {
82 };
83
84 //void writeGeoTIFF(const drain::image::Image & src, const std::string & filename) const;
85
86 virtual
87 void exec() const override;
88
89 void writeProfile(const Hi5Tree & src, const std::string & filename) const;
90
91 void writeSamples(const Hi5Tree & src, const std::string & filename) const;
92
93 void writeDotGraph(const Hi5Tree & src, const std::string & filename, ODIMPathElem::group_t selector = (ODIMPathElem::ROOT | ODIMPathElem::IS_INDEXED)) const;
94
95
96};
97
98class CmdOutputTree : public drain::SimpleCommand<std::string> {
99
100public:
101
102 inline
103 CmdOutputTree() : drain::SimpleCommand<>(__FUNCTION__, "Output data as simple tree structure.",
104 "filename", "", "<filename>|-") {
105 };
106
107 void exec() const;
108
109
110};
111
112
113/*
114class CmdOutputPanel : public drain::BasicCommand {
115
116public:
117
118 inline
119 CmdOutputPanel() : drain::BasicCommand(__FUNCTION__, "Save SVG panel of latest images. See also: --image, --outputRawImages.") {
120 getParameters().link("filename", filename="");
121 getParameters().link("layout", layout, "basic");
122 };
123
124 CmdOutputPanel(const CmdOutputPanel & cmd) : drain::BasicCommand(cmd) {
125 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
126 }
127
128
129 void exec() const;
130
131
132 std::string layout;
133 std::string filename;
134
135 void appendImage(TreeSVG & group, const std::string & prefix, drain::VariableMap & vmap,
136 const drain::Point2D<double> & location, const drain::image::Image & image, drain::BBox & bbox) const;
137};
138*/
139
140
141class FileModule : public drain::CommandModule<> { // : public drain::CommandGroup {
142
143public:
144
146 //virtual void initialize();
147
148};
149
150}
151
152#endif
153
154// Rack
Container and execution tools for commands derived from Command.
Definition CommandBank.h:56
Combines command installation and sectioning.
Definition CommandInstaller.h:153
Definition FileInfo.h:47
Definition RegExp.h:58
A single-parameter command.
Definition Command.h:467
Definition fileio.h:75
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:333
void writeSamples(const Hi5Tree &src, const std::string &filename) const
Definition file-sample.cpp:82
Definition fileio.h:98
void exec() const
Run the command with current parameter values.
Definition fileio.cpp:870
Definition fileio.h:141
static const group_t IS_INDEXED
Group index mask for groups that have an index.
Definition ODIMPath.h:158
static const group_t ROOT
Definition ODIMPath.h:101
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:91
CommandBank & getCommandBank()
Global program command registry. Optional utility.
Definition CommandBank.cpp:52
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:69
const drain::RegExp textFileExtension(".*\\.(txt)$", REG_EXTENDED|REG_ICASE)
Syntax for recognising text files.
Definition fileio.h:65
const drain::RegExp h5FileExtension
Syntax for recognising hdf5 files.
const drain::RegExp listFileExtension(".*\\.(lst|vol)$", REG_EXTENDED)
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:73