InstantIO::Vec2< T > Class Template Reference

Helper class for exchanging vectors of two float components. More...

#include <InstantIO/Vec2.h>

List of all members.

Public Member Functions

 Vec2 ()
 Constructor that initializes all components of the vector with 0.
 Vec2 (T x, T y)
 Constructor that initializes the components of the vector with the given float values.
 Vec2 (const T *vec)
 Constructor that initializes the components of the vector with the values of a given float array.
 Vec2 (const Vec2 &vec)
 Constructor that initializes the components of the vector with the components taken from another vector.
const Vec2operator= (const Vec2 &vec)
 Assigns the components of another Vec2 object to this object's components.
const T * operator= (const T *vec)
 Assigns an array of floats to this object's components.
void setX (T x)
 Sets the value of the x component.
getX () const
 Returns the value of the x component.
void setY (T y)
 Sets the value of the y component.
getY () const
 Returns the value of the y component.
void set (T x, T y)
 Sets the values of the x and y components.
void set (const T *vec)
 Sets the values of the x and y components.
void set (const Vec2 &vec)
 Sets the values of the x and y components.
void get (T &x, T &y) const
 Returns the values of the x and y components.
void get (T *vec) const
 Returns the values of the x and y components.
void get (Vec2 &vec) const
 Returns the values of the x and y components.
const T * get () const
 Returns the values of the x and y components.
T * get ()
 Returns the values of the x and y components.
operator[] (int i) const
 Returns a component of the vector specified by an index.
T & operator[] (int i)
 Returns a component of the vector specified by an index.
 operator T * ()
 Converts the Vec2 object to an array of floats.
 operator const T * () const
 Converts the Vec2 object to an array of floats.

Friends

bool operator== (const Vec2 &a, const Vec2 &b)
 Checks if all components of two vectors are the same.
bool operator!= (const Vec2 &a, const Vec2 &b)
 Checks if two vectors differ at least in one component.

Detailed Description

template<class T>
class InstantIO::Vec2< T >

Helper class for exchanging vectors of two float components.

Vec2 is a basic helper class for exchanging vectors of two float components between different software components. It does not contain any means for vector arithmetics, only methods for setting and getting the components. It is not meant to be used directly by software components for vector representation. Instead, software components should use their own, appropriate classes for handling vectors. Only when sending vectors to an OutSlot, or when receiving vectors from an InSlot, the internal representation of vectors should be converted to Vec2's. This ensures the interoperability between different software components that use different internal representations for vectors.

Author:
Patrick Dähne

Constructor & Destructor Documentation

template<class T >
InstantIO::Vec2< T >::Vec2 ( x,
y 
) [inline]

Constructor that initializes the components of the vector with the given float values.

Parameters:
x Value of the x component of the new vector.
y Value of the y component of the new vector.
template<class T >
InstantIO::Vec2< T >::Vec2 ( const T *  vec  )  [inline]

Constructor that initializes the components of the vector with the values of a given float array.

Parameters:
vec An array of at least two float values. The x component of the vector is set to the value of the first element of the array, and the y component is set to the value of the second element of the array.
template<class T >
InstantIO::Vec2< T >::Vec2 ( const Vec2< T > &  vec  )  [inline]

Constructor that initializes the components of the vector with the components taken from another vector.

Parameters:
vec The other vector used to initialize the new vector.

Member Function Documentation

template<class T >
const Vec2& InstantIO::Vec2< T >::operator= ( const Vec2< T > &  vec  )  [inline]

Assigns the components of another Vec2 object to this object's components.

Parameters:
vec The other Vec2 object
Returns:
The other Vec2 object
template<class T >
const T* InstantIO::Vec2< T >::operator= ( const T *  vec  )  [inline]

Assigns an array of floats to this object's components.

Parameters:
vec An array of at least two float values. The x component of the vector is set to the value of the first element of the array, and the z component is set to the value of the second element of the array.
Returns:
The array of floats
template<class T >
void InstantIO::Vec2< T >::setX ( x  )  [inline]

Sets the value of the x component.

Parameters:
x The new value of the x component
template<class T >
T InstantIO::Vec2< T >::getX (  )  const [inline]

Returns the value of the x component.

Returns:
The value of the x component
template<class T >
void InstantIO::Vec2< T >::setY ( y  )  [inline]

Sets the value of the y component.

Parameters:
y The new value of the y component
template<class T >
T InstantIO::Vec2< T >::getY (  )  const [inline]

Returns the value of the y component.

Returns:
The value of the y component
template<class T >
void InstantIO::Vec2< T >::set ( x,
y 
) [inline]

Sets the values of the x and y components.

Parameters:
x The new value of the x component
y The new value of the y component
template<class T >
void InstantIO::Vec2< T >::set ( const T *  vec  )  [inline]

Sets the values of the x and y components.

Parameters:
vec An array of at least two float values. The x component of the vector is set to the value of the first element of the array, and the y component is set to the value of the second element of the array.
template<class T >
void InstantIO::Vec2< T >::set ( const Vec2< T > &  vec  )  [inline]

Sets the values of the x and y components.

Parameters:
vec The other vector used to set the components of this vector.
template<class T >
void InstantIO::Vec2< T >::get ( T &  x,
T &  y 
) const [inline]

Returns the values of the x and y components.

Parameters:
x Returns the x component of the vector
y Returns the y component of the vector
template<class T >
void InstantIO::Vec2< T >::get ( T *  vec  )  const [inline]

Returns the values of the x and y components.

Parameters:
vec A float array that gets filled with the components of the vector. This array must have at least two elements. The first element of the array is set to the x component of the vector, and the second element of the array is set to the y component of the vector.
template<class T >
void InstantIO::Vec2< T >::get ( Vec2< T > &  vec  )  const [inline]

Returns the values of the x and y components.

Parameters:
vec The other vector whose components are set to components of this vector.
template<class T >
const T* InstantIO::Vec2< T >::get (  )  const [inline]

Returns the values of the x and y components.

Returns:
An array of two float elements. The first element of the array is the x component of the vector, and the second element of the array is the y component of the vector.
template<class T >
T* InstantIO::Vec2< T >::get (  )  [inline]

Returns the values of the x and y components.

Returns:
An array of two float elements. The first element of the array is the x component of the vector, and the second element of the array is the y component of the vector.
template<class T >
T InstantIO::Vec2< T >::operator[] ( int  i  )  const [inline]

Returns a component of the vector specified by an index.

Parameters:
i The index of the component (must be 0 or 1)
Returns:
The component
template<class T >
T& InstantIO::Vec2< T >::operator[] ( int  i  )  [inline]

Returns a component of the vector specified by an index.

Parameters:
i The index of the component (must be 0 or 1)
Returns:
The component
template<class T >
InstantIO::Vec2< T >::operator T * (  )  [inline]

Converts the Vec2 object to an array of floats.

Returns:
Array of floats
template<class T >
InstantIO::Vec2< T >::operator const T * (  )  const [inline]

Converts the Vec2 object to an array of floats.

Returns:
Array of floats

Friends And Related Function Documentation

template<class T >
bool operator== ( const Vec2< T > &  a,
const Vec2< T > &  b 
) [friend]

Checks if all components of two vectors are the same.

Parameters:
a The first vector
b The second vector
Returns:
true when all components are the same, false otherwise
template<class T >
bool operator!= ( const Vec2< T > &  a,
const Vec2< T > &  b 
) [friend]

Checks if two vectors differ at least in one component.

Parameters:
a The first vector
b The second vector
Returns:
true when the two vectors differ at least in one component, false otherwise

The documentation for this class was generated from the following file:
Generated on Thu Jul 31 17:17:32 2014 by  doxygen 1.6.3