HuginBase::ImageVariable< Type > Class Template Reference

An ImageVariable stores a value that can be linked to other ImageVariables of the same type. More...

#include <ImageVariable.h>

Inheritance diagram for HuginBase::ImageVariable< Type >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ImageVariable ()
 constructor
 ImageVariable (Type data)
 construct with a given initial data value
 ImageVariable (ImageVariable< Type > *link)
 Construct linked with something else.
 ImageVariable (const ImageVariable &source)
 Copy constructor.
 ~ImageVariable ()
 destructor
Type getData () const
 get the variable's value
void setData (const Type data)
 Set the variable groups' value.
void linkWith (ImageVariable< Type > *link)
 Create a link.
void removeLinks ()
 remove all links
bool isLinked () const
 Find out if there are other linked variables.
bool isLinkedWith (const ImageVariable< Type > *otherVariable) const
 Find out if this variable is linked to a given variable.

Protected Member Functions

bool searchBackwards (const ImageVariable< Type > *otherVariable) const
 Find if we are linked to another ImageVariable earlier in the list.
bool searchForwards (const ImageVariable< Type > *otherVariable) const
 Find if we are linked to another ImageVariable later in the list.
ImageVariable< Type > * findStart ()
 Find the first item in the list of links with this ImageVariable.
ImageVariable< Type > * findEnd ()
 Find the last item in the list of links with this ImageVariable.
void setBackwards (const Type data)
 Set all linked variables earlier in the list to some given data.
void setForwards (const Type data)
 Set all linked variables later in the list to some given data.

Protected Attributes

Type m_data
 the data that will be returned when getData() is called.
ImageVariable< Type > * m_linkPrevious
 The item preceding us in the list of links.
ImageVariable< Type > * m_linkNext
 The item following us in the list of links.

Detailed Description

template<class Type>
class HuginBase::ImageVariable< Type >

An ImageVariable stores a value that can be linked to other ImageVariables of the same type.

When you link ImageVariables, setting one using setData sets all the other linked ImageVariables. Then when reading the ImageVariables data with getData you get the last value set on any of the linked ImageVariables.

Type The type of the data value to store with this variable. It is the return type for getData and the parameter type for setData.

Todo:
These will probably be copied when creating the Undo/redo data, but their pointers will remain the same. Therefore when copying a SrcPanoImg, we should offset all the pointers by the difference between the old and new SrcPanoImg, so the links are relatively the same.

Definition at line 47 of file ImageVariable.h.


Constructor & Destructor Documentation

template<class Type>
HuginBase::ImageVariable< Type >::ImageVariable (  ) 

constructor

Definition at line 226 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkNext, and HuginBase::ImageVariable< Type >::m_linkPrevious.

template<class Type>
HuginBase::ImageVariable< Type >::ImageVariable ( Type  data  ) 

construct with a given initial data value

Definition at line 234 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_data, HuginBase::ImageVariable< Type >::m_linkNext, and HuginBase::ImageVariable< Type >::m_linkPrevious.

template<class Type>
HuginBase::ImageVariable< Type >::ImageVariable ( ImageVariable< Type > *  link  ) 

Construct linked with something else.

Sets the data from the linked item. Behaves like linkWith.

See also:
linkWith
Parameters:
link ImageVariable which to link with. It provides the data for the newly constructed variable.

Definition at line 244 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::linkWith(), HuginBase::ImageVariable< Type >::m_linkNext, and HuginBase::ImageVariable< Type >::m_linkPrevious.

template<class Type>
HuginBase::ImageVariable< Type >::ImageVariable ( const ImageVariable< Type > &  source  ) 

Copy constructor.

Genrally copied for a getSrcImage call, so make the copy independant from the other image variables.

template<class Type>
HuginBase::ImageVariable< Type >::~ImageVariable (  ) 

destructor

Definition at line 265 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::removeLinks().


Member Function Documentation

template<class Type>
ImageVariable< Type > * HuginBase::ImageVariable< Type >::findEnd (  )  [protected]

Find the last item in the list of links with this ImageVariable.

Definition at line 387 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkNext.

Referenced by HuginBase::ImageVariable< Type >::linkWith().

template<class Type>
ImageVariable< Type > * HuginBase::ImageVariable< Type >::findStart (  )  [protected]

Find the first item in the list of links with this ImageVariable.

Definition at line 378 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkPrevious.

Referenced by HuginBase::ImageVariable< Type >::linkWith().

template<class Type>
Type HuginBase::ImageVariable< Type >::getData (  )  const

get the variable's value

Definition at line 275 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_data.

Referenced by HuginBase::PTOVariableConverterFDiff2D< code_x1, code_y1, code_x2, code_y2 >::addToVariableMap(), HuginBase::PTOVariableConverterSingle< code1, code2, code3, T >::addToVariableMap(), HuginBase::PTOVariableConverterFDiff2D< code_x1, code_y1, code_x2, code_y2 >::getValueFromVariable(), HuginBase::PTOVariableConverterSingle< code1, code2, code3, T >::getValueFromVariable(), HuginBase::SrcPanoImage::horizontalWarpNeeded(), HuginBase::SrcPanoImage::resize(), and HuginBase::PTOVariableConverterFDiff2D< code_x1, code_y1, code_x2, code_y2 >::setValueFromVariable().

template<class Type>
bool HuginBase::ImageVariable< Type >::isLinked (  )  const

Find out if there are other linked variables.

Returns:
true if there are any other variables linked with this one, false otherwise.

Definition at line 338 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkNext, and HuginBase::ImageVariable< Type >::m_linkPrevious.

template<class Type>
bool HuginBase::ImageVariable< Type >::isLinkedWith ( const ImageVariable< Type > *  otherVariable  )  const

Find out if this variable is linked to a given variable.

Find if this variable has been linked (either directly or indirectly) with the variable pointed to by otherVariable.

The execution time depends on how the variables were linked. If linked like in the example in linkWith, then it is fastest to use the variable with the largest array index to look for the other one.

In the worst case, the variables are not linked, and the time taken is O(n) where n is the number of linked variables to this object.

See also:
ImageVariable::linkWith
Parameters:
otherVariable the variable to check linkage with.
Returns:
true if this variable is linked with otherVariable, false otherwise.

Definition at line 345 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::searchBackwards(), and HuginBase::ImageVariable< Type >::searchForwards().

template<class Type>
void HuginBase::ImageVariable< Type >::linkWith ( ImageVariable< Type > *  link  ) 

Create a link.

After making a link to another variable, this variable, and any variables we link link to, will now have the passed in variable's data. Calling setData(data) on either variable, or any variable previously linked with either variable, sets the return value for both variable's getData() function, and the getData function of variables previously linked with either variable. (i.e. Links are bidirectional and accumlative)

It takes longer to link when this element is already linked to many other variables. The fastest way to link an array of variables is:

 for (int index = 1; index < size; index++)
 {
     variables_array[index].linkWith(&(variables_array[index - 1]));
 }
When called like this, each call to linkWith is constant time.

worst case time is O(n+m) where n is the number of linked variables to the object you are calling from, and m is the number of linked variables of the object you pass as a pointer.

Parameters:
link a pointer to the variable to link with.

Definition at line 294 of file ImageVariable.h.

References DEBUG_INFO, HuginBase::ImageVariable< Type >::findEnd(), HuginBase::ImageVariable< Type >::findStart(), HuginBase::ImageVariable< Type >::m_data, HuginBase::ImageVariable< Type >::m_linkNext, HuginBase::ImageVariable< Type >::m_linkPrevious, HuginBase::ImageVariable< Type >::searchBackwards(), HuginBase::ImageVariable< Type >::searchForwards(), and HuginBase::ImageVariable< Type >::setBackwards().

Referenced by HuginBase::ImageVariable< Type >::ImageVariable().

template<class Type>
void HuginBase::ImageVariable< Type >::removeLinks (  ) 

remove all links

After calling this, setData will only change the value of this ImageVariable.

Definition at line 321 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkNext, and HuginBase::ImageVariable< Type >::m_linkPrevious.

Referenced by HuginBase::ImageVariable< Type >::~ImageVariable().

template<class Type>
bool HuginBase::ImageVariable< Type >::searchBackwards ( const ImageVariable< Type > *  otherVariable  )  const [protected]

Find if we are linked to another ImageVariable earlier in the list.

Parameters:
otherVariable the variable to look for
Returns:
true if the variable is linked earilier in the list.

Definition at line 356 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkPrevious.

Referenced by HuginBase::ImageVariable< Type >::isLinkedWith(), and HuginBase::ImageVariable< Type >::linkWith().

template<class Type>
bool HuginBase::ImageVariable< Type >::searchForwards ( const ImageVariable< Type > *  otherVariable  )  const [protected]

Find if we are linked to another ImageVariable later in the list.

Parameters:
otherVariable the variable to look for
Returns:
true if the variable is linked later in the list.

Definition at line 367 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_linkNext.

Referenced by HuginBase::ImageVariable< Type >::isLinkedWith(), and HuginBase::ImageVariable< Type >::linkWith().

template<class Type>
void HuginBase::ImageVariable< Type >::setBackwards ( const Type  data  )  [protected]

Set all linked variables earlier in the list to some given data.

Definition at line 396 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_data, and HuginBase::ImageVariable< Type >::m_linkPrevious.

Referenced by HuginBase::ImageVariable< Type >::linkWith(), and HuginBase::ImageVariable< Type >::setData().

template<class Type>
void HuginBase::ImageVariable< Type >::setData ( const Type  data  ) 

Set the variable groups' value.

Calling this sets the value returned by getData for this ImageVariable and any ImageVariables linked to this one.

Parameters:
data the data to be set for this group.

Definition at line 281 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::setBackwards(), and HuginBase::ImageVariable< Type >::setForwards().

Referenced by HuginBase::SrcPanoImage::resize(), HuginBase::PTOVariableConverterFDiff2D< code_x1, code_y1, code_x2, code_y2 >::setValueFromVariable(), and HuginBase::PTOVariableConverterSingle< code1, code2, code3, T >::setValueFromVariable().

template<class Type>
void HuginBase::ImageVariable< Type >::setForwards ( const Type  data  )  [protected]

Set all linked variables later in the list to some given data.

Definition at line 404 of file ImageVariable.h.

References HuginBase::ImageVariable< Type >::m_data, and HuginBase::ImageVariable< Type >::m_linkNext.

Referenced by HuginBase::ImageVariable< Type >::setData().


Member Data Documentation

template<class Type>
Type HuginBase::ImageVariable< Type >::m_data [protected]

the data that will be returned when getData() is called.

Definition at line 211 of file ImageVariable.h.

Referenced by HuginBase::ImageVariable< Type >::getData(), HuginBase::ImageVariable< Type >::ImageVariable(), HuginBase::ImageVariable< Type >::linkWith(), HuginBase::ImageVariable< Type >::setBackwards(), and HuginBase::ImageVariable< Type >::setForwards().

template<class Type>
ImageVariable<Type>* HuginBase::ImageVariable< Type >::m_linkNext [protected]

The item following us in the list of links.

Definition at line 216 of file ImageVariable.h.

Referenced by HuginBase::ImageVariable< Type >::findEnd(), HuginBase::ImageVariable< Type >::ImageVariable(), HuginBase::ImageVariable< Type >::isLinked(), HuginBase::ImageVariable< Type >::linkWith(), HuginBase::ImageVariable< Type >::removeLinks(), HuginBase::ImageVariable< Type >::searchForwards(), and HuginBase::ImageVariable< Type >::setForwards().

template<class Type>
ImageVariable<Type>* HuginBase::ImageVariable< Type >::m_linkPrevious [protected]

The item preceding us in the list of links.

Definition at line 214 of file ImageVariable.h.

Referenced by HuginBase::ImageVariable< Type >::findStart(), HuginBase::ImageVariable< Type >::ImageVariable(), HuginBase::ImageVariable< Type >::isLinked(), HuginBase::ImageVariable< Type >::linkWith(), HuginBase::ImageVariable< Type >::removeLinks(), HuginBase::ImageVariable< Type >::searchBackwards(), and HuginBase::ImageVariable< Type >::setBackwards().


The documentation for this class was generated from the following file:
Generated on 20 Oct 2014 for Hugintrunk by  doxygen 1.4.7