SH::ShDataVariant< T, DT > Class Template Reference

Inheritance diagram for SH::ShDataVariant< T, DT >:

Inheritance graph
[legend]
Collaboration diagram for SH::ShDataVariant< T, DT >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ShDataVariant< T,
DT > * 
PtrType
typedef const ShDataVariant<
T, DT > * 
CPtrType
typedef ShDataTypeCppType<
T, DT >::type 
DataType
typedef DataTypeiterator
typedef const DataTypeconst_iterator

Public Member Functions

 ShDataVariant (int N)
 Constructs a data array and sets the value to a default value (typically zero).
 ShDataVariant (int N, const DataType &value)
 Constructs a data array and sets the value to a given value.
 ShDataVariant (std::string encodedValue)
 Constructs a data array that reads its size and values from a string encoding (must be from the encode() method of a ShDataVariant of the same type).
 ShDataVariant (int N, void *data, bool managed=true)
 Constructs a data array from an existing array of type T of the given size.
 ShDataVariant (const ShDataVariant< T, DT > &other)
 Constructs a data array using values from another array swizzled and negated as requested.
 ShDataVariant (const ShDataVariant< T, DT > &other, bool neg, const ShSwizzle &swizzle, int count=1)
virtual ~ShDataVariant ()
ShValueType valueType () const
 Gives the associated type identifier string mapped to a unique integer index (Note this is here only for convenience and the value is cached somewhere better like in the ShVariableNode).
ShDataType dataType () const
 Gives the data type held by this variant.
bool typeMatches (ShValueType valueType, ShDataType dataType) const
 Returns whether the value/data type in this variant match the given ones.
const char * typeName () const
int size () const
 Gives the number of elements stored in this data array.
int datasize () const
 Gives the number of bytes per element stored in this data array.
bool managed () const
 Returns true if the array held in the ShVariant was allocated by this.
void negate ()
 The only two required operations on data values - negation and copy assignment.
void set (ShVariantCPtr other)
void set (const ShVariant *other)
void set (ShVariantCPtr other, int index)
void set (const ShVariant *other, int index)
void set (ShVariantCPtr other, bool neg, const ShSwizzle &writemask)
void set (const ShVariant *other, bool neg, const ShSwizzle &writemask)
ShVariantPtr get () const
 Creates a copy of this ShVariant.
ShVariantPtr get (int index) const
 Creates single element ShVariant with the indexed element from this.
ShVariantPtr get (bool neg, const ShSwizzle &swizzle, int count=1) const
 Creates a copy of the Variant with the given swizzle and negation for a given number of elements (defaults to 1) swizzle.m_srcSize must equal size().
bool equals (ShVariantCPtr other) const
bool equals (const ShVariant *other) const
bool isTrue () const
 Returns whether every tuple element is positive.
void * array ()
 Returns a pointer to the beginning of the array.
const void * array () const
DataTypeoperator[] (int index)
const DataTypeoperator[] (int index) const
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
std::string encode () const
 Encodes the data value as a string.
std::string encode (int index, int repeats=1) const
std::string encode (bool neg, const ShSwizzle &swizzle) const
std::string encodeArray () const
 For now, make all encodings human-readable so they will still be useful if we switch to byte encodings.
void * operator new (std::size_t size)
void operator delete (void *d, std::size_t size)

Static Public Attributes

static const ShValueType value_type
static const ShDataType data_type

Protected Member Functions

void alloc (int N)
 allocates an array of size N and sets m_begin, m_end

Protected Attributes

DataTypem_begin
 Start of the data array.
DataTypem_end
 One after the end of the array.
bool m_managed
 true iff we are responsible for array alloc/delete

Static Protected Attributes

static ShPoolm_pool

Detailed Description

template<typename T, ShDataType DT = SH_HOST>
class SH::ShDataVariant< T, DT >

Definition at line 182 of file ShVariant.hpp.


Constructor & Destructor Documentation

template<typename T, ShDataType DT>
SH::ShDataVariant< T, DT >::ShDataVariant int  N,
void *  data,
bool  managed = true
 

Constructs a data array from an existing array of type T of the given size.

This uses the given array internally iff managed = false, otherwise it allocates a new array and makes a copy.

Definition at line 71 of file ShVariantImpl.hpp.

References SH::ShDataVariant< T, DT >::alloc(), SH::ShDataVariant< T, DT >::m_begin, and SH::ShDataVariant< T, DT >::m_managed.


The documentation for this class was generated from the following files:
Generated on Wed Nov 9 15:36:51 2005 for Sh by  doxygen 1.4.5