walberla::config::Config::BlockHandle Class Reference

Detailed Description

Handle for a Block object.

Author
Klaus Iglberger

The BlockHandle class is a simple wrapper for a pointer to a Block object that facilitates the handling of a Block pointer. The class is used transparently in the Blocks container type.

#include <Config.h>

Public Member Functions

 BlockHandle ()
 Default constructor for a block handle. More...
 
 BlockHandle (const Block *block)
 
template<typename Type >
Config::Parameter< Type > getParameter (const std::string &key) const
 
template<typename T >
Config::Parameter< T > getParameter (const std::string &key, const T &def) const
 
Get functions
const std::string & getKey () const
 Returns the key of the block. More...
 
bool isDefined (std::string key) const
 Checks if a parameter was defined in the parameter file. More...
 
template<typename T >
Parameter< T > getParameter (const std::string &key) const
 Returns an extracted parameter. More...
 
template<typename T >
Parameter< T > getParameter (const std::string &key, const T &def) const
 Returns an extracted parameter. More...
 
bool isValid () const
 
 operator bool () const
 
const_iterator begin () const
 Returns an iterator to the first parameter of the block. More...
 
const_iterator end () const
 Returns an iterator one past the last parameter of the block. More...
 
size_type getNumBlocks () const
 Returns the number of contained parameter blocks. More...
 
size_type getNumBlocks (const std::string &key) const
 Returns the number of contained parameter blocks corresponding to given key. More...
 
BlockHandle getOneBlock (const std::string &key) const
 
BlockHandle getBlock (const std::string &key) const
 
void getBlocks (const std::string &key, Blocks &blocks, size_t min=0, size_t max=std::numeric_limits< size_t >::max()) const
 Adds to the given blocks all extracted blocks with key key. More...
 
void getBlocks (Blocks &blocks) const
 Adds to the given blocks all blocks inside the handles block. More...
 
Block cloneBlock () const
 Creates a copy of the bound block. More...
 

Utility functions

const Blockblock_
 Pointer to a const parameter block. More...
 
void listParameters () const
 Output function for the contained parameters. More...
 

Constructor & Destructor Documentation

◆ BlockHandle() [1/2]

walberla::config::Config::BlockHandle::BlockHandle ( )
inline

Default constructor for a block handle.

Note: The BlockHandle object is uninitialized. Any access to the bound block will result in an error until the BlockHandle object is bound to a block.

◆ BlockHandle() [2/2]

walberla::config::Config::BlockHandle::BlockHandle ( const Block block)
inline

Member Function Documentation

◆ begin()

Config::const_iterator walberla::config::Config::BlockHandle::begin ( ) const
inline

Returns an iterator to the first parameter of the block.

Returns
Iterator to the first parameter of the block.

◆ cloneBlock()

Config::Block walberla::config::Config::BlockHandle::cloneBlock ( ) const
inline

Creates a copy of the bound block.

Returns
The copy of the bound block.

◆ end()

Config::const_iterator walberla::config::Config::BlockHandle::end ( ) const
inline

Returns an iterator one past the last parameter of the block.

Returns
Iterator one past the last parameter of the block.

◆ getBlock()

BlockHandle walberla::config::Config::BlockHandle::getBlock ( const std::string &  key) const
inline

◆ getBlocks() [1/2]

void walberla::config::Config::BlockHandle::getBlocks ( Blocks blocks) const
inline

Adds to the given blocks all blocks inside the handles block.

Parameters
[out]blocksReference to the vector of blocks
Returns
void.

◆ getBlocks() [2/2]

void walberla::config::Config::BlockHandle::getBlocks ( const std::string &  key,
Blocks blocks,
size_t  min = 0,
size_t  max = std::numeric_limits< size_t >::max() 
) const
inline

Adds to the given blocks all extracted blocks with key key.

Parameters
keyThe key of the extracted blocks.
[out]blocksReference to the vector of blocks
minminimum number of blocks the caller expects
maxmaximum number of blocks the caller can handle
Returns
void.

◆ getKey()

const std::string & walberla::config::Config::BlockHandle::getKey ( ) const
inline

Returns the key of the block.

Returns
The block key.

◆ getNumBlocks() [1/2]

Config::size_type walberla::config::Config::BlockHandle::getNumBlocks ( ) const
inline

Returns the number of contained parameter blocks.

Returns
The number of contained parameter blocks.

◆ getNumBlocks() [2/2]

Config::size_type walberla::config::Config::BlockHandle::getNumBlocks ( const std::string &  key) const
inline

Returns the number of contained parameter blocks corresponding to given key.

Parameters
keyThe key of the blocks to count.
Returns
The number of contained parameter blocks corresponding to given key.

◆ getOneBlock()

BlockHandle walberla::config::Config::BlockHandle::getOneBlock ( const std::string &  key) const
inline

◆ getParameter() [1/4]

template<typename T >
Config::Parameter< Type > walberla::config::Config::BlockHandle::getParameter ( const std::string &  key) const
inline

Returns an extracted parameter.

Parameters
keyThe key of the extracted parameter.
Returns
The extracted parameter.

◆ getParameter() [2/4]

template<typename Type >
Config::Parameter<Type> walberla::config::Config::BlockHandle::getParameter ( const std::string &  key) const
inline

◆ getParameter() [3/4]

template<typename T >
Config::Parameter< T > walberla::config::Config::BlockHandle::getParameter ( const std::string &  key,
const T &  def 
) const
inline

Returns an extracted parameter.

Parameters
keyThe key of the extracted parameter.
defdefault value, used if key is not defined
Returns
The extracted parameter if key is defined, default value otherwise

◆ getParameter() [4/4]

template<typename T >
Config::Parameter<T> walberla::config::Config::BlockHandle::getParameter ( const std::string &  key,
const T &  def 
) const
inline

◆ isDefined()

bool walberla::config::Config::BlockHandle::isDefined ( std::string  key) const
inline

Checks if a parameter was defined in the parameter file.

Parameters
keyThe parameter key to be checked.
Returns
true if the parameter was defined, false if the parameter wasn't defined.

◆ isValid()

bool walberla::config::Config::BlockHandle::isValid ( ) const
inline

◆ listParameters()

void walberla::config::Config::BlockHandle::listParameters ( ) const
inline

Output function for the contained parameters.

Returns
void

◆ operator bool()

walberla::config::Config::BlockHandle::operator bool ( ) const
inline

Member Data Documentation

◆ block_

const Block* walberla::config::Config::BlockHandle::block_
private

Pointer to a const parameter block.


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