Flow123d  release_3.0.0-893-gf7bf019
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Input::Type::Default Class Reference

Class Input::Type::Default specifies default value of keys of a Input::Type::Record. More...

#include <type_record.hh>

Collaboration diagram for Input::Type::Default:
Collaboration graph
[legend]

Public Member Functions

 Default (const std::string &value)
 Constructor with given default value (at declaration time) More...
 
TypeBase::TypeHash content_hash () const
 Hash of the Default specification, counted of type_ and value_. More...
 
bool has_value_at_read_time () const
 Returns true if the default value is or will be available when someone tries to read the value. More...
 
bool has_value_at_declaration () const
 Returns true if the default value is or will be available when someone tries to read the value. More...
 
bool is_obligatory () const
 Returns true if the key is obligatory and thus must be specified on input. No default value is given. More...
 
bool is_optional () const
 Returns true if the key is optional. More...
 
const string & value () const
 Returns stored value. Possibly empty string. More...
 
bool has_same_type (const Default &other) const
 Compares values type_ of two Default objects. More...
 
bool check_validity (std::shared_ptr< TypeBase > type) const
 Check validity of value_ using the JSON reader if default type is default_at_declaration. More...
 
Input::StorageBaseget_storage (std::shared_ptr< TypeBase > type) const
 Return storage_, if storage_ is NULL, call check_validity method. More...
 

Static Public Member Functions

static Default read_time (const std::string &description)
 The factory function to make an default value that will be specified at the time when a key will be read. More...
 
static Default obligatory ()
 The factory function to make an empty default value which is obligatory. More...
 
static Default optional ()
 The factory function to make an empty default value which is optional. More...
 

Private Types

enum  DefaultType { default_at_declaration, default_at_read_time, no_default_optional_type, no_default_obligatory_type }
 Possible types of default values. More...
 

Private Member Functions

 Default ()
 Forbids default constructor. More...
 
 Default (enum DefaultType type, const std::string &value)
 Constructor for other types then 'declaration'. More...
 

Private Attributes

string value_
 Stored value. More...
 
enum DefaultType type_
 Type of the Default. More...
 
Input::StorageBasestorage_
 Storage of default value read by reader. More...
 

Friends

class Record
 
class OutputBase
 

Detailed Description

Class Input::Type::Default specifies default value of keys of a Input::Type::Record.


It contains type of default value and possibly the value itself stored as std::string. Currently we distinguish four cases:

Definition at line 61 of file type_record.hh.

Member Enumeration Documentation

Possible types of default values.

Enumerator
default_at_declaration 

Default value given at declaration time.

default_at_read_time 

Some default value will be given when the key is read. The description of this value should be provided.

no_default_optional_type 

No default value, optional key. This is default type of the Default.

no_default_obligatory_type 

No default value, obligatory key.

Definition at line 67 of file type_record.hh.

Constructor & Destructor Documentation

Input::Type::Default::Default ( const std::string &  value)

Constructor with given default value (at declaration time)

Definition at line 42 of file type_record.cc.

Input::Type::Default::Default ( )
private

Forbids default constructor.

Definition at line 38 of file type_record.cc.

Input::Type::Default::Default ( enum DefaultType  type,
const std::string &  value 
)
private

Constructor for other types then 'declaration'.

Definition at line 50 of file type_record.cc.

Member Function Documentation

bool Input::Type::Default::check_validity ( std::shared_ptr< TypeBase type) const

Check validity of value_ using the JSON reader if default type is default_at_declaration.

Definition at line 63 of file type_record.cc.

Here is the caller graph for this function:

TypeBase::TypeHash Input::Type::Default::content_hash ( ) const

Hash of the Default specification, counted of type_ and value_.

Definition at line 54 of file type_record.cc.

Input::StorageBase * Input::Type::Default::get_storage ( std::shared_ptr< TypeBase type) const

Return storage_, if storage_ is NULL, call check_validity method.

Definition at line 86 of file type_record.cc.

Here is the caller graph for this function:

bool Input::Type::Default::has_same_type ( const Default other) const
inline

Compares values type_ of two Default objects.

Definition at line 149 of file type_record.hh.

bool Input::Type::Default::has_value_at_declaration ( ) const
inline

Returns true if the default value is or will be available when someone tries to read the value.

Definition at line 132 of file type_record.hh.

Here is the caller graph for this function:

bool Input::Type::Default::has_value_at_read_time ( ) const
inline

Returns true if the default value is or will be available when someone tries to read the value.

Definition at line 128 of file type_record.hh.

bool Input::Type::Default::is_obligatory ( ) const
inline

Returns true if the key is obligatory and thus must be specified on input. No default value is given.

Definition at line 137 of file type_record.hh.

Here is the caller graph for this function:

bool Input::Type::Default::is_optional ( ) const
inline

Returns true if the key is optional.

Definition at line 141 of file type_record.hh.

Here is the caller graph for this function:

static Default Input::Type::Default::obligatory ( )
inlinestatic

The factory function to make an empty default value which is obligatory.

This and following factory functions should be used instead of private constructors.

Example of usage:

some_record.declare_key("some_key",Integer(),Default::obligatory(),"description");

Definition at line 110 of file type_record.hh.

static Default Input::Type::Default::optional ( )
inlinestatic

The factory function to make an empty default value which is optional.

To get the value of such key from the input you have to use non-throwing variant of the method Input::Record::key, which returns the value through reference and allows checking presence of the key on the input.

Example of usage:

some_record.declare_key("some_key",Integer(),Default::optional(),"description");

Definition at line 124 of file type_record.hh.

static Default Input::Type::Default::read_time ( const std::string &  description)
inlinestatic

The factory function to make an default value that will be specified at the time when a key will be read.

You have to provide a string with description of the default value used at the read time., e.g. the key time_governer of an equation can specify default value as

Default::read_time("By default the global time governor is used.")

To get the value of such key from the input you have to use non-throwing variant of the method Input::Record::key, which returns the value through reference and allows checking presence of the key on the input.

Example of usage:

some_record.declare_key("time_governor",TimeGovernor(),Default::optional(),"description");

Definition at line 97 of file type_record.hh.

Here is the caller graph for this function:

const string& Input::Type::Default::value ( ) const
inline

Returns stored value. Possibly empty string.

Definition at line 145 of file type_record.hh.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class OutputBase
friend

Definition at line 63 of file type_record.hh.

friend class Record
friend

Definition at line 62 of file type_record.hh.

Member Data Documentation

Input::StorageBase* Input::Type::Default::storage_
mutableprivate

Storage of default value read by reader.

Definition at line 161 of file type_record.hh.

enum DefaultType Input::Type::Default::type_
private

Type of the Default.

Definition at line 160 of file type_record.hh.

string Input::Type::Default::value_
private

Stored value.

Definition at line 159 of file type_record.hh.


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