Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SH::ShVariable Class Reference

A reference and interface to a generic n-tuple variable. More...

#include <ShVariable.hpp>

Inheritance diagram for SH::ShVariable:

Inheritance graph
[legend]
Collaboration diagram for SH::ShVariable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ShVariable (const ShVariableNodePtr &node)
 ShVariable (const ShVariableNodePtr &node, const ShSwizzle &swizzle, bool neg)
ShVariableoperator= (const ShProgram &prg)
bool null () const
 true iff node is a null pointer.
bool uniform () const
 Is this a uniform (non-shader specific) variable?
bool hasValues () const
 Does this variable have constant (host-local) values?
int size () const
 Get the number of elements in this variable, after swizzling.
ShValueType valueType () const
 Returns index of the data type held in this node, or 0 if no node.
const ShSwizzleswizzle () const
 Obtain the swizzling (if any) applied to this variable.
const ShVariableNodePtr & node () const
 Obtain the actual node this variable refers to.
bool neg () const
 Return true if this variable is negated.
bool & neg ()
ShVariantPtr getVariant () const
 Returns a copy of the variant (with swizzling & proper negation).
ShVariantPtr getVariant (int index) const
bool loadVariant (ShVariant *&result) const
 Sets result to this' variant if possible.
void updateVariant ()
void setVariant (const ShVariant *other, bool neg, const ShSwizzle &writemask)
 Sets the elements of this variant from other accounting for this' writemask and negations.
void setVariant (ShVariantCPtr other, bool neg, const ShSwizzle &writemask)
void setVariant (const ShVariant *other, int index)
 Sets the indicated element of this' variant from other.
void setVariant (ShVariantCPtr other, int index)
void setVariant (const ShVariant *other)
 Sets this' variant from the contents of other.
void setVariant (ShVariantCPtr other)
ShVariable operator() () const
 Identity swizzle.
ShVariable operator() (int) const
ShVariable operator() (int, int) const
ShVariable operator() (int, int, int) const
ShVariable operator() (int, int, int, int) const
ShVariable operator() (int size, int indices[]) const
ShVariable operator- () const
bool operator== (const ShVariable &other) const
bool operator!= (const ShVariable &other) const
void clone (const ShVariable &other)
Metadata
void rangeVariant (const ShVariant *low, const ShVariant *high)
 Set a range of values for this variable.
Metadata
This data is useful for various things, including asset management.

ShVariantPtr lowBoundVariant () const
ShVariantPtr highBoundVariant () const
 Obtain an upper bounds on this variable (tuple of same size as this).

Protected Attributes

ShVariableNodePtr m_node
 The actual variable node we refer to.
ShSwizzle m_swizzle
 Swizzling applied to this variable.
bool m_neg
 True iff this variable is negated.

Friends

SH_DLLEXPORT std::ostream & operator<< (std::ostream &out, const ShVariable &shVariableToPrint)

Detailed Description

A reference and interface to a generic n-tuple variable.

Note: subclasses should not keep any additional data. All data relevant to the node should be stored in m_node. This is due to instances of subclasses of ShVariable being sliced when they get placed in ShStatements.

Definition at line 48 of file ShVariable.hpp.


Member Function Documentation

bool SH::ShVariable::loadVariant ShVariant *&  result  )  const
 

Sets result to this' variant if possible.

Otherwise, if swizzling or negation are required, then makes a copy into result.

Returns:
whether a copy was allocated
(This function should only be used internally. the ref count on result will be 1 if it's allocated as a copy. You may assign this to a refcounted pointer, and then manually release a ref.

Todo:
type figure out a cleaner way)
Since this allows you to possibly change the variant values without triggering a uniform update, if loadVariant returns false, you must call updateVariant() afterwards if you change any values in result.

Definition at line 137 of file ShVariable.cpp.

References getVariant(), SH::ShSwizzle::identity(), m_neg, m_node, m_swizzle, and SH::ShPointer< T >::object().


The documentation for this class was generated from the following files:
Generated on Mon Jan 24 18:38:26 2005 for Sh by  doxygen 1.4.1