Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageVariable.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _PANODATA_IMAGEVARIABLE_H
25 #define _PANODATA_IMAGEVARIABLE_H
26 #include <memory>
27 
28 
29 namespace HuginBase
30 {
31 
47 template <class Type>
49 {
50 public:
52  ImageVariable();
53 
55  explicit ImageVariable(Type data);
56 
65  explicit ImageVariable(ImageVariable<Type> * link);
66 
72  ImageVariable(const ImageVariable &source);
73 
76 
78  Type getData() const;
79 
87  void setData(const Type data);
88 
101  void linkWith(ImageVariable<Type> * link);
102 
108  void removeLinks();
109 
115  bool isLinked() const;
116 
127  bool isLinkedWith(const ImageVariable<Type> * otherVariable) const;
128 
129 protected:
130  std::shared_ptr<Type> m_ptr;
131 }; // ImageVariable class
132 
134 // Public member functions //
136 
137 // Constructors
138 
139 template <class Type>
141 {
142 }
143 
144 template <class Type>
145 ImageVariable<Type>::ImageVariable(Type data) : m_ptr(new Type(data))
146 {
147 }
148 
149 template <class Type>
151 {
152 }
153 
154 template <class Type>
155 ImageVariable<Type>::ImageVariable(const ImageVariable<Type> & source) : m_ptr(new Type(*source.m_ptr))
156 {
157 }
158 
159 // Destructor
160 
161 template <class Type>
163 {
164 }
165 
166 // Other public member functions
167 
168 template <class Type>
170 {
171  return *m_ptr;
172 }
173 
174 template <class Type>
176 {
177  *m_ptr = data;
178 }
179 
180 template <class Type>
182 {
183  // We need to first check that we aren't linked already.
184  if (m_ptr == link->m_ptr)
185  {
186  DEBUG_INFO("Attempt to link already linked variables");
187  return;
188  }
189  else
190  {
191 
192  m_ptr = link->m_ptr;
193  }
194 }
195 
196 template <class Type>
198 {
199  m_ptr.reset(new Type(*m_ptr));
200 }
201 
202 template <class Type>
204 {
205  return m_ptr.use_count() > 1;
206 }
207 
208 template <class Type>
210 {
211  // return true if we can find a link with the given item.
212  return m_ptr == otherVariable->m_ptr;
213 }
214 
215 } // HuginBase namespace
216 
217 #endif // ndef _PANODATA_IMAGEVARIABLE_H
#define DEBUG_INFO(msg)
Definition: utils.h:69
void removeLinks()
remove all links
An ImageVariable stores a value that can be linked to other ImageVariables of the same type...
Definition: ImageVariable.h:48
bool isLinked() const
Find out if there are other linked variables.
void setData(const Type data)
Set the variable groups&#39; value.
void linkWith(ImageVariable< Type > *link)
Create a link.
Type getData() const
get the variable&#39;s value
bool isLinkedWith(const ImageVariable< Type > *otherVariable) const
Find out if this variable is linked to a given variable.
std::shared_ptr< Type > m_ptr
ImageVariable()
constructor
options wxIntPtr wxIntPtr sortData std::vector< PanoInfo > * data