[an error occurred while processing this directive]
Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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>

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.


Constructor & Destructor Documentation

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

constructor

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

construct with a given initial data value

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.

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


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.

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

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

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

get the variable's value

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.

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.

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.

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

remove all links

After calling this, setData will only change the value of this 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.

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.

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

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

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.

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

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


Member Data Documentation

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

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

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

The item following us in the list of links.

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

The item preceding us in the list of links.


The documentation for this class was generated from the following file:

Generated on Mon Sep 20 01:01:36 2010 for Hugintrunk by doxygen 1.3.9.1