Loading...
Searching...
No Matches
WindowOp.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#ifndef WINDOWOP_H_
32#define WINDOWOP_H_
33
34#include "ImageOp.h"
35#include "drain/image/Window.h"
36
37namespace drain
38{
39
40namespace image
41{
42
43
44
49template <class W = Window<WindowConfig> >
50class WindowOp : public ImageOp {
51public:
52
53 typedef W window_t;
54
55 typename W::conf_t conf;
56
57 WindowOp(const std::string & name = __FUNCTION__, const std::string & description="") :
58 ImageOp(name, description) { //, fullName(name+'('+drain::TypeName<W>::str()+')') { // tODO: fix XML tag &gt; handling
59 this->parameters.link("width", conf.frame.tuple()).fillArray = true;
60 // this->parameters.link("width", conf.frame.width);
61 // this->parameters.link("height", conf.frame.height);
62 };
63
64 WindowOp(const std::string & name, const std::string & description, unsigned int width, unsigned int height) :
65 ImageOp(name, description) { // , fullName(name+'('+drain::TypeName<W>::str()+')') {
66 this->parameters.link("width", conf.frame.tuple()).fillArray = true;
67 // this->parameters.link("width", conf.frame.width);
68 // this->parameters.link("height", conf.frame.height);
69 setSize(width, height);
70 };
71
72 WindowOp(const typename W::conf_t & c, const std::string & name = __FUNCTION__, const std::string & description="") :
73 ImageOp(name, description), conf(c) { // , fullName(name+'('+drain::TypeName<W>::str()+')') {
74 this->parameters.link("width", conf.frame.tuple()).fillArray = true;
75 };
76
77 WindowOp(const WindowOp<W> & op) : ImageOp(op), conf(op.conf) { // , fullName(op.name+'('+drain::TypeName<W>::str()+')'){
78 this->parameters.link("width", conf.frame.tuple()).fillArray = true;
79 }
80
81 virtual ~WindowOp(){};
82
83 // TODO virtual?
84 //void setSize(unsigned int width, unsigned int height = 0){
85 inline
86 void setSize(unsigned int width){
87 setSize(width, width);
88 }
89
90 void setSize(unsigned int width, unsigned int height){
91 conf.frame.set(width, height);
92 }
93
94 virtual inline
95 const std::string & getName() const override {
96 return TypeName<image::WindowOp<W> >::str();
97 };
98
99};
100
101
102
103
104} // image::
105
106
107
108template <class W>
109struct TypeName<image::WindowOp<W> > {
110
111 static const std::string & str(){
112 static const std::string name = drain::StringBuilder<>("WindowOp<", drain::TypeName<W>::str(), ">");
113 return name;
114 }
115
116};
117
118
119} // drain::
120
121#endif /*WINDOWOP_H_*/
Definition StringBuilder.h:58
Base class for image processing functions.
Definition ImageOp.h:49
Definition WindowOp.h:50
virtual const std::string & getName() const override
Return the name of an instance.
Definition WindowOp.h:95
Definition DataSelector.cpp:1277
Definition Type.h:542
static const std::string name
Default implementation: name returned by std::type_info::name()
Definition Type.h:558