Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PanoramaVariable.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
26 #ifndef _PANODATA_PANORAMAVARIABLE_H
27 #define _PANODATA_PANORAMAVARIABLE_H
28 
29 
30 #include <hugin_shared.h>
31 #include <string>
32 #include <iostream>
33 #include <vector>
34 #include <set>
35 #include <map>
36 
37 #include <hugin_utils/stl_utils.h>
38 
39 
40 namespace HuginBase {
41 
49 {
50 public :
51 // in the hsi version, class Variable needs a default Ctor
52 #ifdef HUGIN_HSI
53  Variable(const std::string & name = "" ,
54  double val = 0.0)
55  : name(name), value(val)
56  {};
57 #else
58  Variable(const std::string & name, double val = 0.0)
59  : name(name), value(val)
60  {};
61 #endif
62  virtual ~Variable()
63  {};
64 
65 
67  virtual std::ostream & print(std::ostream & o) const;
68 
69 
70  const std::string & getName() const
71  { return name; }
72 
73  void setValue(double v)
74  { value = v; }
75 
76  double getValue() const
77  { return value; }
78 
79  protected:
80  std::string name;
81  double value;
82 };
83 
84 
85 
86 // a linked variable (which contains the link target explicitly
88 {
89 
90  public:
91  LinkedVariable(const std::string & name = "",
92  double val = 0.0,
93  int link=-1)
94  : Variable(name, val), m_link(link)
95  {}
96 
97  bool isLinked() const
98  { return m_link >= 0; }
99 
100  int getLink() const
101  { return m_link; }
102 
103  void setLink(int link)
104  { m_link = link; }
105 
106  protected:
107  int m_link;
108 };
109 
110 
111 
117 // KFJ 2011-01-12 added default for name and value parameter
118 // in order to have a default contructor
119 
121 {
122  public:
123 
124 // in the hsi version, class LensVariable needs a default Ctor
125 #ifdef HUGIN_HSI
126  LensVariable(const std::string & name = "" ,
127  double value = 0.0 ,
128  bool link=false)
129  : Variable(name, value), linked(link)
130  {};
131 #else
132  LensVariable(const std::string & name, double value, bool link=false)
133  : Variable(name, value), linked(link)
134  {};
135 #endif
136  virtual ~LensVariable()
137  {};
138 
139 
141  virtual std::ostream& printLink(std::ostream & o, unsigned int link) const;
142 
143 
145  bool isLinked() const
146  { return linked; }
148  void setLinked(bool l=true)
149  { linked = l; }
150 
151  private:
152  bool linked;
153 
154 };
155 
157 #ifndef SWIG
158 /* this gave me trouble in hsi, currently deactivated
159  * TODO: find out how it can be made to work */
160 struct PrintVar
161 {
162  explicit PrintVar(std::ostream & o)
163  : os(o)
164  {};
165 
166  void operator()(Variable x) const
167  { x.print(os) << " "; };
168 
169  std::ostream& os;
170 };
171 #endif
172 
174 typedef std::map<std::string,Variable> VariableMap;
175 
177 IMPEX void fillVariableMap(VariableMap & vars);
178 
180 IMPEX void printVariableMap(std::ostream & o, const VariableMap & vars);
181 
183 typedef std::vector<VariableMap> VariableMapVector;
184 
185 
187 typedef std::map<std::string,LensVariable> LensVarMap;
188 
190 IMPEX void fillLensVarMap(LensVarMap & vars);
191 
192 
194 typedef std::vector<std::set<std::string> > OptimizeVector;
195 
196 
197 } // namespace
198 #endif // _H
void fillVariableMap(VariableMap &vars)
fill map with all image &amp; lens variables
LinkedVariable(const std::string &name="", double val=0.0, int link=-1)
PrintVar(std::ostream &o)
void printVariableMap(std::ostream &o, const VariableMap &vars)
print a variable map to o
const std::string & getName() const
void operator()(Variable x) const
a variable has a value and a name.
std::map< std::string, LensVariable > LensVarMap
void setLinked(bool l=true)
std::vector< VariableMap > VariableMapVector
LensVariable(const std::string &name, double value, bool link=false)
A lens variable can be linked.
virtual std::ostream & print(std::ostream &o) const
print this variable
double getValue() const
#define IMPEX
Definition: hugin_shared.h:39
std::map< std::string, Variable > VariableMap
void fillLensVarMap(LensVarMap &variables)
just lens variables
Variable(const std::string &name, double val=0.0)
std::vector< std::set< std::string > > OptimizeVector
functor to print a variable.
void setValue(double v)