Katana Plug-in APIs 0.1
Public Member Functions | Static Public Member Functions

Foundry::Katana::StringAttribute Class Reference

A class representing a data attribute containing strings. More...

#include <FnAttribute.h>

Inheritance diagram for Foundry::Katana::StringAttribute:
Foundry::Katana::DataAttribute Foundry::Katana::Attribute

List of all members.

Public Member Functions

 StringAttribute ()
 StringAttribute (const std::string &value)
 StringAttribute (const char *value)
 StringAttribute (const value_type *values, int64_t valueCount, int64_t tupleSize)
 StringAttribute (const std::vector< std::string > &stringvec, int64_t tupleSize=1)
 StringAttribute (const char **values, int64_t valueCount, int64_t tupleSize)
 StringAttribute (const float *times, int64_t timeCount, const char ***values, int64_t valueCount, int64_t tupleSize, void *context=NULL, FnAttributeFreeOwnedDataFunc freeOwnedDataFunc=NULL)
accessor_type getSamples () const &
array_type getNearestSample (float time) const &
value_type getValue (const value_type &defValue=value_type(), bool throwOnError=true) const
template<typename T , size_t N>
getValuesAs (const T &defValue=T(), bool throwOnError=true) const
const char * getValueCStr (const char *defValue="", bool throwOnError=true) const &

Static Public Member Functions

static FnKatAttributeType getKatAttributeType ()

Detailed Description

A class representing a data attribute containing strings.


Constructor & Destructor Documentation

Foundry::Katana::StringAttribute::StringAttribute ( ) [inline]

Create empty attribute class (isValid() == false).

Foundry::Katana::StringAttribute::StringAttribute ( const std::string &  value) [inline]

Creates a string attribute containing one value.

Parameters:
valueThe value for the new attribute, in the form of a std::string.
Foundry::Katana::StringAttribute::StringAttribute ( const char *  value) [inline]

Creates a string attribute containing one value.

Parameters:
valueThe value for the new attribute, in the form of a C string.
Foundry::Katana::StringAttribute::StringAttribute ( const value_type *  values,
int64_t  valueCount,
int64_t  tupleSize 
)

Creates a string attribute containing a number of values, grouped into tuples of a given size.

Parameters:
valuesAn array of std::strings containing the values
valueCountThe total number of values. Must be a multiple of tupleSize
tupleSizeThe size of tuples to group values into.
Foundry::Katana::StringAttribute::StringAttribute ( const std::vector< std::string > &  stringvec,
int64_t  tupleSize = 1 
)

Creates a string attribute containing a number of values, grouped into tuples of a given size.

Parameters:
stringvecA vector of std::string containing the values
tupleSizeThe size of tuples to group values into.
Foundry::Katana::StringAttribute::StringAttribute ( const char **  values,
int64_t  valueCount,
int64_t  tupleSize 
) [inline]

Creates a string attribute containing a number of values, grouped into tuples of a given size.

Parameters:
valuesAn array of C strings containing the values
valueCountThe total number of values. Must be a multiple of tupleSize
tupleSizeThe size of tuples to group values into.
Foundry::Katana::StringAttribute::StringAttribute ( const float *  times,
int64_t  timeCount,
const char ***  values,
int64_t  valueCount,
int64_t  tupleSize,
void *  context = NULL,
FnAttributeFreeOwnedDataFunc  freeOwnedDataFunc = NULL 
) [inline]

Creates a string attribute containing several timed samples, each containing a number of values, grouped into tuples of a given size.

Specifying values for context and freeOwnedDataFunc will cause the constructor to take ownership of the memory pointed to by values. It is the responsibility of freeOwnedDataFunc to deallocate this memory when called.

Note: when using the 'zero copy' version of this constructor copies of the pointers in times and values will be taken, only management of the memory pointed to by values will be transferred to the attribute.

Parameters:
timesAn array of floats, giving the times of the samples.
timeCountThe number of samples for which there is data
valuesAn array of pointers to C string arrays containing values. There must be timeCount arrays, each of which has valueCount values.
valueCountThe total number of values in each sample. Must be a multiple of tupleSize
tupleSizeThe size of tuples to group values into.
contextUser supplied data passed to freeOwnedDataFunc.
freeOwnedDataFuncPointer to function that will be called when values' memory is to be returned to the operating system.

Member Function Documentation

static FnKatAttributeType Foundry::Katana::StringAttribute::getKatAttributeType ( ) [inline, static]

Returns the intended type of this Attribute, without needing a valid handle.

array_type Foundry::Katana::StringAttribute::getNearestSample ( float  time) const [inline]

Returns a ConstVector object that provides a read-only view into values of the sample nearest to the given time.

Note:
Any pointers or references obtained from the ConstVector are invalidated if the ConstVector is destructed.
accessor_type Foundry::Katana::StringAttribute::getSamples ( ) const [inline]

Returns a SampleAccessor object that provides a read-only view into all time samples of the Attribute.

Note:
Any pointers or references obtained from the SampleAccessor are invalidated if the SampleAccessor is destructed.
value_type Foundry::Katana::StringAttribute::getValue ( const value_type &  defValue = value_type(),
bool  throwOnError = true 
) const [inline]

Returns first value from the time sample nearest 0.0. This is a convenience for the extremely common case of an attribute that stores a single sample of a single value at time 0.0. By default, throws std::runtime_error if there are no time samples or no values available.

Parameters:
defValueThe value to return if an error occurs and throwOnError is false.
throwOnErrorWhen error occurs, if true, throw std::runtime_error. If false, return defValue.
const char* Foundry::Katana::StringAttribute::getValueCStr ( const char *  defValue = "",
bool  throwOnError = true 
) const [inline]

Returns first value from the time sample nearest 0.0. This is a convenience for the extremely common case of an attribute that stores a single sample of a single value at time 0.0. By default, throws std::runtime_error if there are no time samples or no values available.

Parameters:
defValueThe value to return if an error occurs and throwOnError is false.
throwOnErrorWhen error occurs, if true, throw std::runtime_error. If false, return defValue.
Warning:
The pointer returned by this function may be invalidated if *this is destroyed.
template<typename T , size_t N>
T Foundry::Katana::StringAttribute::getValuesAs ( const T &  defValue = T(),
bool  throwOnError = true 
) const [inline]

Convenience function that creates an object of type T by passing the first N values from time sample nearest t=0.0.

Note:
The C++98 implementation supports constructors that take at most 16 arguments.
Template Parameters:
TThe type of object to construct.
NThe number of values to pass to T's constructor.
Parameters:
defValueThe value to return if throwOnError is false and the attribute has either no time samples, or less than N values per sample.
throwOnErrorWhether to throw an exception if the attribute has no time samples or has less than N values per sample.
Returns:
An object of type T, constructed with the first N values from the attribute's primary time sample.
Exceptions:
std::runtime_errorif an error occurs and throwOnError is true.

References Foundry::Katana::SampleAccessorBase< ValueT >::empty(), Foundry::Katana::Sample< ValueT >::getAs(), Foundry::Katana::SampleAccessor< ValueT >::getNearestSample(), and Foundry::Katana::SampleAccessorBase< ValueT >::getNumberOfValues().


The documentation for this class was generated from the following file:
 All Classes Functions Variables Typedefs Enumerations Enumerator