Flow123d  JS_before_hm-1730-gbf8dc60dc
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 () const
 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
const static 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

◆ ChildDataIter

Public typedef of constant iterator into array of keys.

Definition at line 122 of file type_abstract.hh.

Constructor & Destructor Documentation

◆ Abstract() [1/3]

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

Default constructor.

Definition at line 57 of file type_abstract.cc.

Here is the caller graph for this function:

◆ Abstract() [2/3]

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.

◆ Abstract() [3/3]

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

◆ add_attribute()

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:

◆ add_child()

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:

◆ allow_auto_conversion()

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:

◆ begin_child_data()

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:

◆ child_size()

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:

◆ class_name()

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.

◆ close()

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:

◆ content_hash()

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:

◆ deep_copy()

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:

◆ end_child_data()

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:

◆ finish()

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:

◆ finish_status()

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.

◆ get_default_descendant()

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:

◆ get_descendant()

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:

◆ get_selection_default()

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:

◆ get_type_selection()

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.

◆ have_default_descendant()

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:

◆ is_closed()

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:

◆ is_finished()

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:

◆ make_instance()

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

Definition at line 237 of file type_abstract.cc.

◆ root_of_generic_subtree()

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:

◆ type_name()

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

◆ AdHocAbstract

friend class AdHocAbstract
friend

Definition at line 64 of file type_abstract.hh.

◆ OutputBase

friend class OutputBase
friend

Definition at line 63 of file type_abstract.hh.

◆ Record

friend class Record
friend

Definition at line 255 of file type_abstract.hh.

Member Data Documentation

◆ child_data_

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:
Input::Type::Abstract
Class for declaration of polymorphic Record.
Definition: type_abstract.hh:62
Input::Type
Definition: balance.hh:41
Input::Type::Abstract::Abstract
Abstract()
Default constructor.
Definition: type_abstract.cc:57