Classes | Public Types | Public Member Functions | List of all members
EnvironmentProperties Class Reference

A hierarchical environment properties holder created from a composite property. More...

#include <EnvironmentProperties.hpp>

Classes

class  Item
 Instances of the Item class are returned from iterators. More...
 
class  iterator
 The EnvironmentProperties iterator. More...
 

Public Types

typedef iterator const_iterator
 The const iterator of EnvironmentProperties is the same as a non-const one. More...
 

Public Member Functions

 EnvironmentProperties (std::unique_ptr< const Impl::BindingMap > &&bindings_)
 Create an environment properties instance. More...
 
 EnvironmentProperties ()
 Create an empty environment properties instance. More...
 
iterator begin ()
 Get an iterator positioned at the beginning of the environment properties list. More...
 
const_iterator begin () const
 Get a const iterator positioned at the beginning of the environment properties list. More...
 
bool empty () const
 Returns true if the environment properties object is empty. More...
 
iterator end ()
 Get an iterator positioned at the end of the environment properties list. More...
 
const_iterator end () const
 Get a const iterator positioned at the end of the environment properties list. More...
 
std::shared_ptr< EnvironmentPropertiesgetComposite (std::string_view name) const
 Get a child environment properties instance with the specified name. More...
 
std::shared_ptr< EnvironmentPropertiesgetCompositeOrNull (std::string_view name) const
 Get a child environment properties instance with the specified name. More...
 
template<typename BaseT >
std::unique_ptr< BaseT > getUnique (std::string_view name) const
 Get a polymorphic value of the specified type and name. More...
 
template<typename BaseT >
std::unique_ptr< BaseT > getUnique (std::string_view name, std::unique_ptr< BaseT > &&defaultValue) const
 Get a polymorphic value of the specified type and name. More...
 
template<typename ValueT >
ValueT getValue (std::string_view name) const
 Get a non-polymorphic value of the specified type and name. More...
 
template<typename ValueT >
ValueT getValue (std::string_view name, const ValueT &defaultValue) const
 Get a non-polymorphic value of the specified type and name. More...
 
bool hasComposite (std::string_view name) const
 Returns true if the composite property has a child composite binding with the specified name. More...
 
template<typename BaseT >
bool hasUnique (std::string_view name) const
 Returns true if the composite property has a unique pointer binding matching the specified type and name. More...
 
template<typename ValueT >
bool hasValue (std::string_view name) const
 Returns true if the composite property has a value binding matching the specified type and name. More...
 

Detailed Description

A hierarchical environment properties holder created from a composite property.

An instance of this class contains a set of value and/or shared injector bindings, which were created from the parsing of a composite property within a hierarchical property file.

The direct or indirect value binding descendants of an EnvironmentProperties instance represent the simple and composite properties that were contained within the composite property in the hierarchical property file. Descendant value bindings may be a mixture of untyped simple properties (supplied as std::string) and typed simple properties (supplied as the type specified within the injector configuration). All descendant shared bindings are more instances of the EnvironmentProperties.

EnvironmentProperties instances may be iterated over. As the contained items being iterated over are of different types, (T, std::unique_ptr<T>, and std::shared_ptr<EnvironmentProperties>), de-referenced iterators provide opaque EnvironmentProperties::Item proxy objects. The EnvironmentProperties::Item class provides a similar API to the EnvironmentProperties class, allowing type and name examination of the contained binding, and extraction via getValue, getUnique, and getComposite methods.

Member Typedef Documentation

◆ const_iterator

The const iterator of EnvironmentProperties is the same as a non-const one.

Constructor & Destructor Documentation

◆ EnvironmentProperties() [1/2]

EnvironmentProperties ( std::unique_ptr< const Impl::BindingMap > &&  bindings_)
inline

Create an environment properties instance.

This is usually performed by the injector environment configuration.

◆ EnvironmentProperties() [2/2]

Create an empty environment properties instance.

This is required by certain Balau components.

Member Function Documentation

◆ begin() [1/2]

iterator begin ( )
inline

Get an iterator positioned at the beginning of the environment properties list.

◆ begin() [2/2]

const_iterator begin ( ) const
inline

Get a const iterator positioned at the beginning of the environment properties list.

◆ empty()

bool empty ( ) const
inline

Returns true if the environment properties object is empty.

◆ end() [1/2]

iterator end ( )
inline

Get an iterator positioned at the end of the environment properties list.

◆ end() [2/2]

const_iterator end ( ) const
inline

Get a const iterator positioned at the end of the environment properties list.

◆ getComposite()

std::shared_ptr<EnvironmentProperties> getComposite ( std::string_view  name) const
inline

Get a child environment properties instance with the specified name.

If no suitable binding is found, NoBindingException is thrown.

Parameters
namethe name of the binding
Returns
the child environment properties instance with the specified name
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getCompositeOrNull()

std::shared_ptr<EnvironmentProperties> getCompositeOrNull ( std::string_view  name) const
inline

Get a child environment properties instance with the specified name.

If no suitable binding is found, null is returned.

Parameters
namethe name of the binding
Returns
child environment properties instance with the specified name or null

◆ getUnique() [1/2]

std::unique_ptr<BaseT> getUnique ( std::string_view  name) const
inline

Get a polymorphic value of the specified type and name.

The value is cloned from the prototype via the base type's provider function in the unique binding.

If no suitable binding is found, NoBindingException is thrown.

Template Parameters
BaseTthe base type of the unique binding
Parameters
namethe name of the binding
Returns
a new polymorphic value
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getUnique() [2/2]

std::unique_ptr<BaseT> getUnique ( std::string_view  name,
std::unique_ptr< BaseT > &&  defaultValue 
) const
inline

Get a polymorphic value of the specified type and name.

The value is cloned from the prototype via the type's provider function in the unique binding.

If no suitable binding is found, the supplied default value is moved into the return value.

Template Parameters
BaseTthe base type of the unique binding
Parameters
namethe name of the binding
defaultValuea default value to copy if no suitable binding was found
Returns
a new polymorphic value or the supplied default value

◆ getValue() [1/2]

ValueT getValue ( std::string_view  name) const
inline

Get a non-polymorphic value of the specified type and name.

The value is copy constructed from the prototype in the value binding.

If no suitable binding is found, NoBindingException is thrown.

Template Parameters
ValueTthe type of the value binding
Parameters
namethe name of the binding
Returns
a new value
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getValue() [2/2]

ValueT getValue ( std::string_view  name,
const ValueT &  defaultValue 
) const
inline

Get a non-polymorphic value of the specified type and name.

The value is copy constructed from the prototype in the value binding.

If no suitable binding is found, the supplied default value is copied into the return value.

Template Parameters
ValueTthe type of the value binding
Parameters
namethe name of the binding
defaultValuea default value to copy if no suitable binding was found
Returns
a new value or a copy of the supplied default value

◆ hasComposite()

bool hasComposite ( std::string_view  name) const
inline

Returns true if the composite property has a child composite binding with the specified name.

Parameters
namethe name of the binding
Returns
true if the composite property has a child composite binding with the specified name

◆ hasUnique()

bool hasUnique ( std::string_view  name) const
inline

Returns true if the composite property has a unique pointer binding matching the specified type and name.

Template Parameters
BaseTthe base type of the binding
Parameters
namethe name of the binding
Returns
true if the composite property has a unique pointer binding matching the specified type and name

◆ hasValue()

bool hasValue ( std::string_view  name) const
inline

Returns true if the composite property has a value binding matching the specified type and name.

Template Parameters
ValueTthe value binding type
Parameters
namethe name of the binding
Returns
true if the composite property has a value binding matching the specified type and name

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