LuxCore  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
luxrays::Property Class Reference

A generic container for values. More...

#include <properties.h>

Collaboration diagram for luxrays::Property:

Public Member Functions

 Property ()
 Constructs a new empty property. More...
 
 Property (const std::string &propName)
 Constructs a new empty property with a given name. More...
 
 Property (const std::string &propName, const PropertyValue &val)
 Constructs a new property with a given name and value. More...
 
 Property (const std::string &propName, const PropertyValues &vals)
 Constructs a new property with a given name and values. More...
 
 ~Property ()
 
const std::string & GetName () const
 Returns the name of a property. More...
 
Property AddedNamePrefix (const std::string &prefix) const
 Return a new property with a prefix added to the name. More...
 
Property Renamed (const std::string &newName) const
 Return a new property with a new name. More...
 
unsigned int GetSize () const
 Returns the number of values associated to this property. More...
 
PropertyClear ()
 Removes any values associated to the property. More...
 
template<class T >
Get (const unsigned int index) const
 Returns the value at the specified position. More...
 
const PropertyValue::DataType GetValueType (const unsigned int index) const
 Returns the type of the value at the specified position. More...
 
template<class T >
Get () const
 Parses all values as a representation of the specified type. More...
 
template<class T >
PropertySet (const unsigned int index, const T &val)
 Sets the value at the specified position. More...
 
template<class T >
PropertyAdd (const T &val)
 Adds an item at the end of the list of values associated with the property. More...
 
std::string GetValuesString () const
 Returns a string with all values associated to the property. More...
 
void FromString (std::string &s)
 Initialize the property from a string (ex. "a.b.c = 1 2") More...
 
std::string ToString () const
 Returns a string with the name of the property followed by " = " and by all values associated to the property. More...
 
template<class T0 >
Propertyoperator() (const T0 &val0)
 Adds a value to a property. More...
 
template<class T0 , class T1 >
Propertyoperator() (const T0 &val0, const T1 &val1)
 Adds a value to a property. More...
 
template<class T0 , class T1 , class T2 >
Propertyoperator() (const T0 &val0, const T1 &val1, const T2 &val2)
 Adds a value to a property. More...
 
template<class T0 , class T1 , class T2 , class T3 >
Propertyoperator() (const T0 &val0, const T1 &val1, const T2 &val2, const T3 &val3)
 Adds a value to a property. More...
 
template<class T0 >
Propertyoperator() (const std::vector< T0 > &vals)
 Adds a vector of values to a property. More...
 
template<class T >
Propertyoperator= (const T &val)
 Initializes a property with (only) the given value. More...
 
PropertyAdd (const char *val)
 Required to work around the problem of char* to bool conversion (instead of char* to string). More...
 
PropertyAdd (char *val)
 Required to work around the problem of char* to bool conversion (instead of char* to string). More...
 
Propertyoperator() (const char *val)
 
Propertyoperator() (char *val)
 Required to work around the problem of char* to bool conversion (instead of char* to string). More...
 
Propertyoperator= (const char *val)
 Required to work around the problem of char* to bool conversion (instead of char* to string). More...
 
Propertyoperator= (char *val)
 Required to work around the problem of char* to bool conversion (instead of char* to string). More...
 
template<>
CPP_API bool Get () const
 
template<>
CPP_API int Get () const
 
template<>
CPP_API unsigned int Get () const
 
template<>
CPP_API float Get () const
 
template<>
CPP_API double Get () const
 
template<>
CPP_API unsigned long long Get () const
 
template<>
CPP_API const BlobGet () const
 

Static Public Member Functions

static unsigned int CountFields (const std::string &name)
 
static std::string ExtractField (const std::string &name, const unsigned int index)
 
static std::string ExtractPrefix (const std::string &name, const unsigned int count)
 

Private Attributes

std::string name
 
PropertyValues values
 

Detailed Description

A generic container for values.

A Property is a container associating a vector of values to a string name. The vector of values can include items with different data types. Check PropertyValue for a list of allowed types.

Definition at line 153 of file properties.h.

Constructor & Destructor Documentation

luxrays::Property::Property ( )

Constructs a new empty property.

Constructs a new empty property where the property name is initialized to the empty string (i.e. "") and the vector of values is empty too.

luxrays::Property::Property ( const std::string &  propName)

Constructs a new empty property with a given name.

Constructs a new empty property where the property name is initialized to propName and the vector of values is empty too.

Parameters
propNameis the name of the new property.
luxrays::Property::Property ( const std::string &  propName,
const PropertyValue val 
)

Constructs a new property with a given name and value.

Constructs a new property where the property name is initialized to propName and the vector of values has one single element with the value of val.

Parameters
propNameis the name of the new property.
valis the value of the new property.
luxrays::Property::Property ( const std::string &  propName,
const PropertyValues vals 
)

Constructs a new property with a given name and values.

Constructs a new property where the property name is initialized to propName and the vector of values is initialize with the values of vals.

Parameters
propNameis the name of the new property.
valsis the value of the new property.
luxrays::Property::~Property ( )

Member Function Documentation

template<class T >
Property& luxrays::Property::Add ( const T &  val)
inline

Adds an item at the end of the list of values associated with the property.

Parameters
valis the value to append.
Returns
a reference to the modified property.

Definition at line 318 of file properties.h.

Referenced by operator()().

Property& luxrays::Property::Add ( const char *  val)
inline

Required to work around the problem of char* to bool conversion (instead of char* to string).

Definition at line 428 of file properties.h.

Property& luxrays::Property::Add ( char *  val)
inline

Required to work around the problem of char* to bool conversion (instead of char* to string).

Definition at line 436 of file properties.h.

Property luxrays::Property::AddedNamePrefix ( const std::string &  prefix) const
inline

Return a new property with a prefix added to the name.

Parameters
prefixis the string to add to the name.
Returns
a new property.

Definition at line 208 of file properties.h.

References values.

Property& luxrays::Property::Clear ( )

Removes any values associated to the property.

Returns
a reference to the modified property.
static unsigned int luxrays::Property::CountFields ( const std::string &  name)
static
static std::string luxrays::Property::ExtractField ( const std::string &  name,
const unsigned int  index 
)
static
static std::string luxrays::Property::ExtractPrefix ( const std::string &  name,
const unsigned int  count 
)
static
void luxrays::Property::FromString ( std::string &  s)

Initialize the property from a string (ex. "a.b.c = 1 2")

template<class T >
T luxrays::Property::Get ( const unsigned int  index) const
inline

Returns the value at the specified position.

Parameters
indexis the position of the value to return.
Returns
the value at specified position (casted or translated to the type required).
Exceptions
std::runtime_errorif the index is out of bound.

Definition at line 249 of file properties.h.

template<class T >
T luxrays::Property::Get ( ) const
inline

Parses all values as a representation of the specified type.

The current list of supported data types is:

  • bool
  • int
  • unsigned int
  • float
  • double
  • unsigned longlong
  • string
  • Blob
Returns
the value at first position (casted or translated to the type required).
Exceptions
std::runtime_errorif the property has the wrong number of values for the specified data type.

Definition at line 289 of file properties.h.

template<>
CPP_API bool luxrays::Property::Get ( ) const
template<>
CPP_API int luxrays::Property::Get ( ) const
template<>
CPP_API unsigned int luxrays::Property::Get ( ) const
template<>
CPP_API float luxrays::Property::Get ( ) const
template<>
CPP_API double luxrays::Property::Get ( ) const
template<>
CPP_API unsigned long long luxrays::Property::Get ( ) const
template<>
CPP_API const Blob& luxrays::Property::Get ( ) const
const std::string& luxrays::Property::GetName ( ) const
inline

Returns the name of a property.

Returns
the name of the property

Definition at line 200 of file properties.h.

unsigned int luxrays::Property::GetSize ( ) const
inline

Returns the number of values associated to this property.

Returns
the number of values in this property.

Definition at line 232 of file properties.h.

std::string luxrays::Property::GetValuesString ( ) const

Returns a string with all values associated to the property.

Returns
a string with all values.
const PropertyValue::DataType luxrays::Property::GetValueType ( const unsigned int  index) const
inline

Returns the type of the value at the specified position.

Parameters
indexis the position of the value.
Returns
the type information of the value at specified position.
Exceptions
std::runtime_errorif the index is out of bound.

Definition at line 264 of file properties.h.

template<class T0 >
Property& luxrays::Property::operator() ( const T0 &  val0)
inline

Adds a value to a property.

It can be used to write expressions like:

Property("test1.prop1")("aa")

Parameters
val0is the value to assign.
Returns
a reference to the modified property.

Definition at line 350 of file properties.h.

template<class T0 , class T1 >
Property& luxrays::Property::operator() ( const T0 &  val0,
const T1 &  val1 
)
inline

Adds a value to a property.

It can be used to write expressions like:

Property("test1.prop1")(1.f, 2.f)

Parameters
val0is the value to assign as first item.
val1is the value to assign as second item.
Returns
a reference to the modified property.

Definition at line 365 of file properties.h.

References Add().

template<class T0 , class T1 , class T2 >
Property& luxrays::Property::operator() ( const T0 &  val0,
const T1 &  val1,
const T2 &  val2 
)
inline

Adds a value to a property.

It can be used to write expressions like:

Property("test1.prop1")(1.f, 2.f, 3.f)

Parameters
val0is the value to assign as first item.
val1is the value to assign as second item.
val2is the value to assign as third item.
Returns
a reference to the modified property.

Definition at line 381 of file properties.h.

References Add().

template<class T0 , class T1 , class T2 , class T3 >
Property& luxrays::Property::operator() ( const T0 &  val0,
const T1 &  val1,
const T2 &  val2,
const T3 &  val3 
)
inline

Adds a value to a property.

It can be used to write expressions like:

Property("test1.prop1")(1.f, 2.f, 3.f, 4.f)

Parameters
val0is the value to assign as first item.
val1is the value to assign as second item.
val2is the value to assign as third item.
val3is the value to assign as forth item.
Returns
a reference to the modified property.

Definition at line 398 of file properties.h.

References Add().

template<class T0 >
Property& luxrays::Property::operator() ( const std::vector< T0 > &  vals)
inline

Adds a vector of values to a property.

Parameters
valsis the value to assign.
Returns
a reference to the modified property.

Definition at line 408 of file properties.h.

Property& luxrays::Property::operator() ( const char *  val)
inline

Definition at line 440 of file properties.h.

Property& luxrays::Property::operator() ( char *  val)
inline

Required to work around the problem of char* to bool conversion (instead of char* to string).

Definition at line 447 of file properties.h.

template<class T >
Property& luxrays::Property::operator= ( const T &  val)
inline

Initializes a property with (only) the given value.

Returns
a reference to the modified property.

Definition at line 419 of file properties.h.

Property& luxrays::Property::operator= ( const char *  val)
inline

Required to work around the problem of char* to bool conversion (instead of char* to string).

Definition at line 454 of file properties.h.

Property& luxrays::Property::operator= ( char *  val)
inline

Required to work around the problem of char* to bool conversion (instead of char* to string).

Definition at line 462 of file properties.h.

Property luxrays::Property::Renamed ( const std::string &  newName) const
inline

Return a new property with a new name.

Parameters
prefixis the string to use for the new name.
Returns
a new property.

Definition at line 221 of file properties.h.

References values.

template<class T >
Property& luxrays::Property::Set ( const unsigned int  index,
const T &  val 
)
inline

Sets the value at the specified position.

Parameters
indexis the position of the value to set.
valis the new value to set.
Returns
a reference to the modified property.
Exceptions
std::runtime_errorif the index is out of bound.

Definition at line 302 of file properties.h.

std::string luxrays::Property::ToString ( ) const

Returns a string with the name of the property followed by " = " and by all values associated to the property.

Returns
a string with the name and all values.

Referenced by luxrays::operator<<().

Member Data Documentation

std::string luxrays::Property::name
private

Definition at line 472 of file properties.h.

PropertyValues luxrays::Property::values
private

Definition at line 473 of file properties.h.

Referenced by AddedNamePrefix(), and Renamed().


The documentation for this class was generated from the following file: