Flow123d  release_3.0.0-1182-ga9abfa7
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 567 of file accessors.hh.

Member Typedef Documentation

Definition at line 570 of file accessors.hh.

Constructor & Destructor Documentation

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.

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

Copy constructor.

Definition at line 301 of file accessors.cc.

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

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:

template<class ValueType >
Iterator< ValueType > Input::Array::begin ( ) const
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:

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:

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:

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:

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 619 of file accessors.hh.

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 Input::Array::address_
private

Contains address and relationships with array ancestor.

Definition at line 640 of file accessors.hh.

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

Corresponding Type::Array.

Definition at line 637 of file accessors.hh.

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 633 of file accessors.hh.


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