Flow123d  master-9c1c1b8e5
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Input::Array Class Reference

Accessor to input data conforming to declared Array. More...

#include <accessors.hh>

Collaboration diagram for Input::Array:
Collaboration graph
[legend]

Public Types

typedef ::Input::Type::Array InputType
 

Public Member Functions

 Array ()
 
 Array (const Array &ar)
 
 Array (const Address &address, const Type::Array type)
 
template<class ValueType >
Iterator< ValueType > begin () const
 
IteratorBase end () const
 
unsigned int size () const
 
template<class Container >
void copy_to (Container &out) const
 
bool is_empty () const
 
EI_Address ei_address () const
 
string address_string () const
 

Static Public Attributes

static StorageArray empty_storage_ = StorageArray(0)
 Need persisting empty instance of StorageArray that can be used to create an empty Address. More...
 

Private Attributes

Input::Type::Array array_type_
 Corresponding Type::Array. More...
 
Address address_
 Contains address and relationships with array ancestor. More...
 

Detailed Description

Accessor to input data conforming to declared Array.

There are two possible ways how to retrieve data from Array accessor. First, you can use generic copy_to function to copy the data into a given container. Second, you can get an Iterator<Type> and iterate through the Array. Unfortunately, you have to provide Type to the begin() method so this implementation is not fully compliant with standard library. The reason is that in order to speed up compilation of many classes using input accessors we wouldn't have Input::Array a class template that it can be compiled only once. By this reason one can not use BOOST_FOREACH to iterate over Input::Array. TODO: Make Input::Array<Type> wrapper which is compliant with standard library.

In either case correspondence between resulting type (i.e. type of elements of the container or type of the Iterator) and the type of the data in the Array is checked only once.

Example of usage:

Input::Array decay_array = in_rec.val<Input::Array>("decays"); // get accessor to an array stored under key 'decays'
int size = decay_array.size(); // get size of the actual arrya in the input (possibly for allocation)
for(Input::Iterator<Input::Record> it = decay_array.begin<Input::Record>() // pass through the array, that is array of records
; it != dacay_array.end(); ++it) {
Input::Iterator<double> it_hl = it->find<double>("half_life"); // check existence of an optional key
if (it_hl) {
double hl = *it_hl;
} else {
// use some other value, or turn-off the decay
}
Input::Array products = it->val<Input::Array>("products"); // read an obligatory key, theat conatins an array
// ... process the array 'products'
}

Definition at line 566 of file accessors.hh.

Member Typedef Documentation

◆ InputType

Definition at line 569 of file accessors.hh.

Constructor & Destructor Documentation

◆ Array() [1/3]

Input::Array::Array ( )

Default constructor, empty accessor.

Constructor uses empty Address which causes error in program, Address has to be filled.

Definition at line 296 of file accessors.cc.

◆ Array() [2/3]

Input::Array::Array ( const Array ar)

Copy constructor.

Definition at line 301 of file accessors.cc.

◆ Array() [3/3]

Input::Array::Array ( const Address address,
const Type::Array  type 
)

Constructs the accessor providing pointer store to storage node with list of data of the record and type specification of the record given by parameter type.

Definition at line 306 of file accessors.cc.

Member Function Documentation

◆ address_string()

string Input::Array::address_string ( ) const

Get address as string.

Definition at line 321 of file accessors.cc.

Here is the caller graph for this function:

◆ begin()

template<class ValueType >
Iterator< ValueType > Input::Array::begin
inline

Returns iterator to the first element of input array. The template parameter is C++ type you want to read from the array. Only types supported by Input::Interface::Iterator can be used.

Definition at line 145 of file accessors_impl.hh.

Here is the caller graph for this function:

◆ copy_to()

template<class Container >
void Input::Array::copy_to ( Container &  out) const

Method to fill the given container out with data in the input Array. The container has to have methods clear and push_back. The C++ type of the values in the container has to be supported by Iterator<T>.

Definition at line 170 of file accessors_impl.hh.

Here is the caller graph for this function:

◆ ei_address()

Input::EI_Address Input::Array::ei_address ( ) const

Returns address error info.

Definition at line 314 of file accessors.cc.

Here is the caller graph for this function:

◆ end()

IteratorBase Input::Array::end ( ) const
inline

Returns end iterator common to all iterators inner types.

Definition at line 157 of file accessors_impl.hh.

Here is the caller graph for this function:

◆ is_empty()

bool Input::Array::is_empty ( ) const
inline

Returns true if the accessor is empty (after default constructor). TODO: have something similar for other accessors.

Definition at line 618 of file accessors.hh.

◆ size()

unsigned int Input::Array::size ( ) const
inline

Actual size of the input array.

Definition at line 163 of file accessors_impl.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ address_

Address Input::Array::address_
private

Contains address and relationships with array ancestor.

Definition at line 639 of file accessors.hh.

◆ array_type_

Input::Type::Array Input::Array::array_type_
private

Corresponding Type::Array.

Definition at line 636 of file accessors.hh.

◆ empty_storage_

StorageArray Input::Array::empty_storage_ = StorageArray(0)
static

Need persisting empty instance of StorageArray that can be used to create an empty Address.

Definition at line 632 of file accessors.hh.


The documentation for this class was generated from the following files:
Input::Array::begin
Iterator< ValueType > begin() const
Definition: accessors_impl.hh:145
Input::Iterator
Definition: accessors.hh:143
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
Input::Array::size
unsigned int size() const
Definition: accessors_impl.hh:163
Input::Type
Definition: balance.hh:41
Input::Array
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566