Flow123d  release_3.0.0-1106-ga3b2e4c
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Input::Type::Abstract Class Reference

Class for declaration of polymorphic Record. More...

#include <type_abstract.hh>

Inheritance diagram for Input::Type::Abstract:
Inheritance graph
[legend]
Collaboration diagram for Input::Type::Abstract:
Collaboration graph
[legend]

Classes

class  ChildData
 Actual data of the abstract record. More...
 

Public Types

typedef std::vector< Record >::const_iterator ChildDataIter
 Public typedef of constant iterator into array of keys. More...
 
- Public Types inherited from Input::Type::TypeBase
typedef std::size_t TypeHash
 Type returned by content_hash methods. More...
 
typedef std::string json_string
 String stored in JSON format. More...
 
typedef std::map< std::string, json_stringattribute_map
 Defines map of Input::Type attributes. More...
 
typedef std::pair< std::string, std::shared_ptr< TypeBase > > ParameterPair
 Defines pairs of (name, Input::Type), that are used for replace of parameters in generic types. More...
 
typedef std::vector< ParameterPairParameterVector
 Define vector of parameters passed to the overloaded make_instance method. More...
 
typedef std::map< std::string, TypeHashParameterMap
 Defines map of used parameters. More...
 
typedef std::pair< std::shared_ptr< TypeBase >, ParameterMapMakeInstanceReturnType
 Return type of make_instance methods, contains instance of generic type and map of used parameters. More...
 

Public Member Functions

 Abstract ()
 Default constructor. More...
 
 Abstract (const Abstract &other)
 Copy constructor. More...
 
 Abstract (const string &type_name_in, const string &description)
 Basic constructor. More...
 
TypeHash content_hash () const override
 Implements TypeBase::content_hash. More...
 
Abstractallow_auto_conversion (const string &type_default)
 Allows shorter input of the Abstract providing the default value to the "TYPE" key. More...
 
Abstractclose ()
 Close the Abstract and add its to type repository (see TypeRepository::add_type). More...
 
Abstractroot_of_generic_subtree ()
 
Abstractadd_attribute (std::string key, TypeBase::json_string value)
 Frontend to TypeBase::add_attribute_. More...
 
FinishStatus finish (FinishStatus finish_type=FinishStatus::regular_) override
 Finish declaration of the Abstract type. More...
 
const Recordget_descendant (const string &name) const
 Returns reference to the inherited Record with given name. More...
 
const Recordget_default_descendant () const
 Returns default descendant. More...
 
const Selectionget_type_selection () const
 Returns reference to Selection type of the implicit key TYPE. More...
 
unsigned int child_size () const
 Returns number of descendants in the child_data_. More...
 
virtual FinishStatus finish_status () const override
 Implements TypeBase::finish_status. More...
 
virtual bool is_finished () const override
 Implements TypeBase::is_finished. More...
 
virtual bool is_closed () const override
 Returns true if data_ is closed. More...
 
virtual string type_name () const override
 Implements Type::TypeBase::type_name. More...
 
string class_name () const override
 Override Type::TypeBase::class_name. More...
 
ChildDataIter begin_child_data () const
 Container-like access to the descendants of the Abstract. More...
 
ChildDataIter end_child_data () const
 Container-like access to the descendants of the Abstract. More...
 
int add_child (Record &subrec)
 Add inherited Record. More...
 
Defaultget_selection_default () const
 
virtual MakeInstanceReturnType make_instance (std::vector< ParameterPair > vec=std::vector< ParameterPair >()) override
 
- Public Member Functions inherited from Input::Type::TypeBase
string desc () const
 Returns string with Type extensive documentation. More...
 
virtual bool operator== (const TypeBase &other) const
 Comparison of types. More...
 
bool operator!= (const TypeBase &other) const
 Comparison of types. More...
 
virtual ~TypeBase ()
 Destructor. More...
 
std::string hash_str () const
 Format the hash of this type. More...
 
virtual MakeInstanceReturnType make_instance (ParameterVector vec=ParameterVector())=0
 
bool is_root_of_generic_subtree ()
 Indicates if type is marked with flag root_of_generic_subtree_. More...
 

Protected Member Functions

Abstract deep_copy () const
 Create deep copy of Abstract (copy all data stored in shared pointers etc.) More...
 
bool have_default_descendant () const
 Check if type has set value of default descendants. More...
 
- Protected Member Functions inherited from Input::Type::TypeBase
 TypeBase ()
 The default constructor. More...
 
 TypeBase (const TypeBase &other)
 Copy constructor. More...
 
void add_attribute_ (std::string name, json_string val)
 Add attribute of given name to attribute map. More...
 
bool validate_json (json_string str) const
 Check if str is valid JSON string. More...
 
json_string print_parameter_map_to_json (ParameterMap parameter_map) const
 Create JSON output from parameter_map formatted as value of attribute. More...
 
json_string print_parameter_map_keys_to_json (ParameterMap param_map) const
 
void set_generic_attributes (ParameterMap param_map)
 
void copy_attributes (attribute_map other_attributes)
 

Protected Attributes

std::shared_ptr< ChildDatachild_data_
 Actual data of the Abstract. More...
 
- Protected Attributes inherited from Input::Type::TypeBase
std::shared_ptr< attribute_mapattributes_
 map of type attributes (e. g. input_type, name etc.) More...
 
bool root_of_generic_subtree_
 flag is true if type should be root of generic subtree More...
 
TypeHash generic_type_hash_
 hash string of generic type if type is derived, or empty string More...
 
ParameterMap parameter_map_
 map of parameters if type is part of generic subtree More...
 

Friends

class OutputBase
 
class AdHocAbstract
 
class Record
 

Additional Inherited Members

- Static Public Member Functions inherited from Input::Type::TypeBase
static void delete_unfinished_types ()
 Finishes and marks all types registered in type repositories and unused in IST. More...
 
static std::string hash_str (TypeHash hash)
 Format given hash for output. More...
 
- Static Public Attributes inherited from Input::Type::TypeBase
static const TypeHash none_hash = std::numeric_limits<TypeHash>::max()
 
- Protected Types inherited from Input::Type::TypeBase
typedef string KeyHash
 The type of hash values used in associative array that translates key names to indices in Record and Selection. More...
 
- Static Protected Member Functions inherited from Input::Type::TypeBase
static KeyHash key_hash (const string &str)
 Hash function. More...
 
static bool is_valid_identifier (const string &key)
 Check that a key is valid identifier. More...
 

Detailed Description

Class for declaration of polymorphic Record.

Like the Record class this is only proxy class. It allows add Record as descendants, but further there is method no_more_descendants to close adding them. After this you can not derive any Record from this Abstract.

A static method (typically part of an abstract class) for construction of an AbstractType can look like:

static Input::Type::Abstract &SomeAbstractClass::get_input_type() {
using namespace Input::Type;
return Abstract("Function", "Input for generic time-space function.")
.close();
}

Definition at line 62 of file type_abstract.hh.

Member Typedef Documentation

Public typedef of constant iterator into array of keys.

Definition at line 122 of file type_abstract.hh.

Constructor & Destructor Documentation

Input::Type::Abstract::Abstract ( )

Default constructor.

Definition at line 57 of file type_abstract.cc.

Here is the caller graph for this function:

Input::Type::Abstract::Abstract ( const Abstract other)

Copy constructor.

We check that other is non empty.

Definition at line 66 of file type_abstract.cc.

Input::Type::Abstract::Abstract ( const string &  type_name_in,
const string &  description 
)

Basic constructor.

You has to provide type_name of the new declared Abstract type and its description.

Definition at line 72 of file type_abstract.cc.

Member Function Documentation

Abstract & Input::Type::Abstract::add_attribute ( std::string  key,
TypeBase::json_string  value 
)

Frontend to TypeBase::add_attribute_.

Definition at line 284 of file type_abstract.cc.

Here is the caller graph for this function:

int Input::Type::Abstract::add_child ( Record subrec)

Add inherited Record.

Do not use this method for set Record as descendant! For this case should be used Record::derive_from method in generating function of Record.

This method is used primarily for registration of Record during its closing.

Definition at line 134 of file type_abstract.cc.

Here is the caller graph for this function:

Abstract & Input::Type::Abstract::allow_auto_conversion ( const string &  type_default)

Allows shorter input of the Abstract providing the default value to the "TYPE" key.

If the input reader come across the Abstract in the declaration tree and the input is not 'record-like' with specified value for TYPE, it tries to use the descendant Record specified by type_default parameter of this method. Further auto conversion of such Record may be possible.

Definition at line 97 of file type_abstract.cc.

Here is the caller graph for this function:

Abstract::ChildDataIter Input::Type::Abstract::begin_child_data ( ) const

Container-like access to the descendants of the Abstract.

Returns iterator to the first data.

Definition at line 297 of file type_abstract.cc.

Here is the caller graph for this function:

unsigned int Input::Type::Abstract::child_size ( ) const

Returns number of descendants in the child_data_.

Definition at line 129 of file type_abstract.cc.

Here is the caller graph for this function:

string Input::Type::Abstract::class_name ( ) const
overridevirtual

Override Type::TypeBase::class_name.

Reimplemented from Input::Type::TypeBase.

Reimplemented in Input::Type::AdHocAbstract.

Definition at line 216 of file type_abstract.cc.

Abstract & Input::Type::Abstract::close ( )

Close the Abstract and add its to type repository (see TypeRepository::add_type).

Definition at line 190 of file type_abstract.cc.

Here is the caller graph for this function:

TypeBase::TypeHash Input::Type::Abstract::content_hash ( ) const
overridevirtual

Implements TypeBase::content_hash.

Hash is calculated by type name, description and hash of attributes.

Implements Input::Type::TypeBase.

Reimplemented in Input::Type::AdHocAbstract.

Definition at line 77 of file type_abstract.cc.

Here is the caller graph for this function:

Abstract Input::Type::Abstract::deep_copy ( ) const
protected

Create deep copy of Abstract (copy all data stored in shared pointers etc.)

Definition at line 263 of file type_abstract.cc.

Here is the caller graph for this function:

Abstract::ChildDataIter Input::Type::Abstract::end_child_data ( ) const

Container-like access to the descendants of the Abstract.

Returns iterator to the last data.

Definition at line 301 of file type_abstract.cc.

Here is the caller graph for this function:

FinishStatus Input::Type::Abstract::finish ( FinishStatus  finish_type = FinishStatus::regular_)
overridevirtual

Finish declaration of the Abstract type.

Checks if Abstract is closed and completes Abstract (check default descendant, parameters of generic types etc).

Reimplemented from Input::Type::TypeBase.

Reimplemented in Input::Type::AdHocAbstract.

Definition at line 149 of file type_abstract.cc.

Here is the caller graph for this function:

FinishStatus Input::Type::Abstract::finish_status ( ) const
overridevirtual

Implements TypeBase::finish_status.

Reimplemented from Input::Type::TypeBase.

Definition at line 196 of file type_abstract.cc.

const Record * Input::Type::Abstract::get_default_descendant ( ) const

Returns default descendant.

Returns only if TYPE key has default value, otherwise returns empty Record.

Definition at line 113 of file type_abstract.cc.

Here is the caller graph for this function:

const Record & Input::Type::Abstract::get_descendant ( const string &  name) const

Returns reference to the inherited Record with given name.

Definition at line 105 of file type_abstract.cc.

Here is the caller graph for this function:

Default & Input::Type::Abstract::get_selection_default ( ) const

Definition at line 221 of file type_abstract.cc.

Here is the caller graph for this function:

const Selection & Input::Type::Abstract::get_type_selection ( ) const

Returns reference to Selection type of the implicit key TYPE.

Definition at line 123 of file type_abstract.cc.

bool Input::Type::Abstract::have_default_descendant ( ) const
protected

Check if type has set value of default descendants.

Definition at line 225 of file type_abstract.cc.

Here is the caller graph for this function:

bool Input::Type::Abstract::is_closed ( ) const
overridevirtual

Returns true if data_ is closed.

Reimplemented from Input::Type::TypeBase.

Definition at line 206 of file type_abstract.cc.

Here is the caller graph for this function:

bool Input::Type::Abstract::is_finished ( ) const
overridevirtual

Implements TypeBase::is_finished.

Reimplemented from Input::Type::TypeBase.

Definition at line 201 of file type_abstract.cc.

Here is the caller graph for this function:

TypeBase::MakeInstanceReturnType Input::Type::Abstract::make_instance ( std::vector< ParameterPair vec = std::vector<ParameterPair>())
overridevirtual

Definition at line 237 of file type_abstract.cc.

Abstract & Input::Type::Abstract::root_of_generic_subtree ( )

Mark the type to be root of a generic subtree. Such type can not appear in IST directly but only as the internal type of the Instance auxiliary object.

Definition at line 278 of file type_abstract.cc.

Here is the caller graph for this function:

string Input::Type::Abstract::type_name ( ) const
overridevirtual

Implements Type::TypeBase::type_name.

Name corresponds to data_->type_name_.

Reimplemented from Input::Type::TypeBase.

Definition at line 211 of file type_abstract.cc.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class AdHocAbstract
friend

Definition at line 64 of file type_abstract.hh.

friend class OutputBase
friend

Definition at line 63 of file type_abstract.hh.

friend class Record
friend

Definition at line 255 of file type_abstract.hh.

Member Data Documentation

std::shared_ptr<ChildData> Input::Type::Abstract::child_data_
protected

Actual data of the Abstract.

Definition at line 253 of file type_abstract.hh.


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