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

A container for multiple Property. More...

#include <properties.h>

Collaboration diagram for luxrays::Properties:

Public Member Functions

 Properties ()
 
 Properties (const std::string &fileName)
 Sets the list of Property from a text file . More...
 
 ~Properties ()
 
unsigned int GetSize () const
 Returns the number of Property in this container. More...
 
PropertiesSet (const Property &prop)
 Sets a single Property. More...
 
Propertiesoperator<< (const Property &prop)
 Sets a single Property. More...
 
PropertiesSet (const Properties &prop)
 Sets the list of Property. More...
 
Propertiesoperator<< (const Properties &props)
 Sets the list of Property. More...
 
PropertiesSet (const Properties &props, const std::string &prefix)
 Sets the list of Property while adding a prefix to all names. More...
 
PropertiesSetFromStream (std::istream &stream)
 Sets the list of Property coming from a stream. More...
 
PropertiesSetFromFile (const std::string &fileName)
 Sets the list of Property coming from a file. More...
 
PropertiesSetFromString (const std::string &propDefinitions)
 Sets the list of Property coming from a std::string. More...
 
PropertiesClear ()
 Removes all Property from the container. More...
 
const std::vector< std::string > & GetAllNames () const
 Returns all Property names defined. More...
 
std::vector< std::string > GetAllNames (const std::string &prefix) const
 Returns all Property names that start with a specific prefix. More...
 
std::vector< std::string > GetAllNamesRE (const std::string &regularExpression) const
 Returns all Property unique names that match the passed regular expression. More...
 
std::vector< std::string > GetAllUniqueSubNames (const std::string &prefix) const
 Returns all Property unique names that start with a specific prefix. More...
 
bool HaveNames (const std::string &prefix) const
 Returns if there are at least a Property starting for specific prefix. More...
 
bool HaveNamesRE (const std::string &regularExpression) const
 Returns all a copy of all Property with a name starting with a specific prefix. More...
 
Properties GetAllProperties (const std::string &prefix) const
 Returns a copy of all Property with a name matching the passed regular expression. More...
 
const PropertyGet (const std::string &propName) const
 Returns a property. More...
 
const PropertyGet (const Property &defaultProp) const
 Returns a Property with the same name of the passed Property if it has been defined or the passed Property itself (i.e. the default values). More...
 
bool IsDefined (const std::string &propName) const
 Returns if a Property with the given name has been defined. More...
 
void Delete (const std::string &propName)
 Deletes a Property with the given name. More...
 
void DeleteAll (const std::vector< std::string > &propNames)
 Deletes all listed Property. More...
 
std::string ToString () const
 Converts all Properties in a string. More...
 

Private Attributes

std::vector< std::string > names
 
std::map< std::string, Propertyprops
 

Detailed Description

A container for multiple Property.

Properties is a container for instances of Property class. It keeps also track of the insertion order.

Definition at line 502 of file properties.h.

Constructor & Destructor Documentation

luxrays::Properties::Properties ( )
inline

Definition at line 504 of file properties.h.

luxrays::Properties::Properties ( const std::string &  fileName)

Sets the list of Property from a text file .

Parameters
fileNameis the name of the file to read.
luxrays::Properties::~Properties ( )
inline

Definition at line 511 of file properties.h.

Member Function Documentation

Properties& luxrays::Properties::Clear ( )

Removes all Property from the container.

Returns
a reference to the modified properties.
void luxrays::Properties::Delete ( const std::string &  propName)

Deletes a Property with the given name.

Parameters
propNameis the name of the Property to delete.
void luxrays::Properties::DeleteAll ( const std::vector< std::string > &  propNames)

Deletes all listed Property.

Parameters
propNamesis the list of the Property to delete.
const Property& luxrays::Properties::Get ( const std::string &  propName) const

Returns a property.

Parameters
propNameis the name of the Property to return.
Returns
a Property.
Exceptions
std::runtime_errorif the Property doesn't exist.
const Property& luxrays::Properties::Get ( const Property defaultProp) const

Returns a Property with the same name of the passed Property if it has been defined or the passed Property itself (i.e. the default values).

Parameters
defaultProphas the Property to look for and the default values in case it has not been defined.
Returns
a Property.
const std::vector<std::string>& luxrays::Properties::GetAllNames ( ) const

Returns all Property names defined.

Returns
a reference to all Property names defined.
std::vector<std::string> luxrays::Properties::GetAllNames ( const std::string &  prefix) const

Returns all Property names that start with a specific prefix.

This method is used to iterate over all properties.

Parameters
prefixof the Property names to return.
Returns
a vector of Property names.
std::vector<std::string> luxrays::Properties::GetAllNamesRE ( const std::string &  regularExpression) const

Returns all Property unique names that match the passed regular expression.

Parameters
regularExpressionto use for the pattern matching.
Returns
a vector of Property names.
Properties luxrays::Properties::GetAllProperties ( const std::string &  prefix) const

Returns a copy of all Property with a name matching the passed regular expression.

Parameters
regularExpressionto use for the pattern matching.
Returns
a copy of all Property matching the prefix.
std::vector<std::string> luxrays::Properties::GetAllUniqueSubNames ( const std::string &  prefix) const

Returns all Property unique names that start with a specific prefix.

For instance, given the the following names:

  • test.prop1.subprop1
  • test.prop1.subprop2
  • test.prop2.subprop1

GetAllUniqueSubNames("test") will return:

  • test.prop1
  • test.prop2
Parameters
prefixof the Property names to return.
Returns
a vector of Property names.
unsigned int luxrays::Properties::GetSize ( ) const

Returns the number of Property in this container.

Returns
the number of Property.
bool luxrays::Properties::HaveNames ( const std::string &  prefix) const

Returns if there are at least a Property starting for specific prefix.

Parameters
prefixof the Property to look for.
Returns
true if there is at least on Property starting for the prefix.
bool luxrays::Properties::HaveNamesRE ( const std::string &  regularExpression) const

Returns all a copy of all Property with a name starting with a specific prefix.

Parameters
prefixof the Property names to use.
Returns
a copy of all Property matching the prefix.
bool luxrays::Properties::IsDefined ( const std::string &  propName) const

Returns if a Property with the given name has been defined.

Parameters
propNameis the name of the Property to check.
Returns
if defined or not.
Properties& luxrays::Properties::operator<< ( const Property prop)

Sets a single Property.

Parameters
propis the Property to set.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::operator<< ( const Properties props)

Sets the list of Property.

Parameters
propsis the list of Property to set.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::Set ( const Property prop)

Sets a single Property.

Parameters
propis the Property to set.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::Set ( const Properties prop)

Sets the list of Property.

Parameters
propis the list of Property to set.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::Set ( const Properties props,
const std::string &  prefix 
)

Sets the list of Property while adding a prefix to all names.

Parameters
propsis the list of Property to set.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::SetFromFile ( const std::string &  fileName)

Sets the list of Property coming from a file.

Parameters
fileNameis the name of the file to read.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::SetFromStream ( std::istream &  stream)

Sets the list of Property coming from a stream.

Parameters
streamis the input stream to read.
Returns
a reference to the modified properties.
Properties& luxrays::Properties::SetFromString ( const std::string &  propDefinitions)

Sets the list of Property coming from a std::string.

Parameters
propDefinitionsis the list of Property to add in text format.
Returns
a reference to the modified properties.
std::string luxrays::Properties::ToString ( ) const

Converts all Properties in a string.

Returns
a string with the definition of all properties.

Referenced by luxrays::operator<<().

Member Data Documentation

std::vector<std::string> luxrays::Properties::names
private

Definition at line 713 of file properties.h.

std::map<std::string, Property> luxrays::Properties::props
private

Definition at line 714 of file properties.h.


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