InstantIO::Vec4< T > Class Template Reference

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

#include <InstantIO/Vec4.h>

List of all members.

Public Member Functions

 Vec4 ()
 Constructor that initializes all components of the vector with 0.
 Vec4 (T x, T y, T z, T w)
 Constructor that initializes the components of the vector with the given float values.
 Vec4 (const T *vec)
 Constructor that initializes the components of the vector with the values of a given float array.
 Vec4 (const Vec4 &vec)
 Constructor that initializes the components of the vector with the components taken from another vector.
const Vec4operator= (const Vec4 &vec)
 Assigns the components of another Vec4 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 setZ (T z)
 Sets the value of the z component.
getZ () const
 Returns the value of the z component.
void setW (T w)
 Sets the value of the w component.
getW () const
 Returns the value of the w component.
void set (T x, T y, T z, T w)
 Sets the values of the x, y, z and w components.
void set (const T *vec)
 Sets the values of the x, y, z and w components.
void set (const Vec4 &vec)
 Sets the values of the x, y, z and w components.
void get (T &x, T &y, T &z, T &w) const
 Returns the values of the x, y, z and w components.
void get (T *vec) const
 Returns the values of the x, y, z and w components.
void get (Vec4 &vec) const
 Returns the values of the x, y, z and w components.
const T * get () const
 Returns the values of the x, y, z and w components.
T * get ()
 Returns the values of the x, y, z and w 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 Vec4 object to an array of floats.
 operator const T * () const
 Converts the Vec4 object to an array of floats.

Friends

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

Detailed Description

template<class T>
class InstantIO::Vec4< T >

Helper class for exchanging vectors of four float components.

Vec4 is a basic helper class for exchanging vectors of four 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 Vec4'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::Vec4< T >::Vec4 ( x,
y,
z,
w 
) [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.
z Value of the z component of the new vector.
w Value of the w component of the new vector.
template<class T >
InstantIO::Vec4< T >::Vec4 ( 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 four float values. The x component of the vector is set to the value of the first element of the array, the y component is set to the value of the second element of the array, the z component is set to the value of the third element of the array, and the w component is set to the value of the fourth element of the array.
template<class T >
InstantIO::Vec4< T >::Vec4 ( const Vec4< 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 Vec4& InstantIO::Vec4< T >::operator= ( const Vec4< T > &  vec  )  [inline]

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

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

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

Parameters:
vec An array of at least four float values. The x component of the vector is set to the value of the first element of the array, the y component is set to the value of the second element of the array, the z component is set to the value of the third element of the array, and the w component is set to the value of the fourth element of the array.
Returns:
The array of floats
template<class T >
void InstantIO::Vec4< 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::Vec4< T >::getX (  )  const [inline]

Returns the value of the x component.

Returns:
The value of the x component
template<class T >
void InstantIO::Vec4< 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::Vec4< T >::getY (  )  const [inline]

Returns the value of the y component.

Returns:
The value of the y component
template<class T >
void InstantIO::Vec4< T >::setZ ( z  )  [inline]

Sets the value of the z component.

Parameters:
z The new value of the z component
template<class T >
T InstantIO::Vec4< T >::getZ (  )  const [inline]

Returns the value of the z component.

Returns:
The value of the z component
template<class T >
void InstantIO::Vec4< T >::setW ( w  )  [inline]

Sets the value of the w component.

Parameters:
w The new value of the w component
template<class T >
T InstantIO::Vec4< T >::getW (  )  const [inline]

Returns the value of the w component.

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

Sets the values of the x, y, z and w components.

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

Sets the values of the x, y, z and w components.

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

Sets the values of the x, y, z and w components.

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

Returns the values of the x, y, z and w components.

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

Returns the values of the x, y, z and w components.

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

Returns the values of the x, y, z and w components.

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

Returns the values of the x, y, z and w components.

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

Returns the values of the x, y, z and w components.

Returns:
An array of four float elements. The first element of the array is the x component of the vector, the second element of the array is the y component of the vector, the third element of the array is the z component of the vector, and the fourth element of the array is the w component of the vector.
template<class T >
T InstantIO::Vec4< 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, 1, 2 or 3)
Returns:
The component
template<class T >
T& InstantIO::Vec4< 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, 1, 2 or 3)
Returns:
The component
template<class T >
InstantIO::Vec4< T >::operator T * (  )  [inline]

Converts the Vec4 object to an array of floats.

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

Converts the Vec4 object to an array of floats.

Returns:
Array of floats

Friends And Related Function Documentation

template<class T >
bool operator== ( const Vec4< T > &  a,
const Vec4< 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 Vec4< T > &  a,
const Vec4< 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