Flow123d  master-f44eb46
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Input::TypeRepository< T > Class Template Reference

The Singleton class TypeRepository serves for handling the lazy-evaluated input types, derived from the base class Type::TypeBase. More...

#include <type_repository.hh>

Collaboration diagram for Input::TypeRepository< T >:
Collaboration graph
[legend]

Public Types

typedef std::map< Type::TypeBase::TypeHash, std::shared_ptr< T > > TypeRepositoryMap
 Template parameter can be only descendant of TypeBase class. More...
 
typedef TypeRepositoryMap::const_iterator TypeRepositoryMapIter
 Public typedef of constant iterator into map of stored type. More...
 

Public Member Functions

std::shared_ptr< T > add_type (const T &type)
 Add type to TypeRepository if doesn't exist there or get existing type with same TypeHash. More...
 
std::shared_ptr< T > find_hash (Type::TypeBase::TypeHash hash)
 
void finish (Type::FinishStatus finish_type)
 Finish all stored types. More...
 
void reset_deleted_types ()
 Reset and remove types marked as deleted during finish. More...
 
TypeRepositoryMapIter begin () const
 Container-like access to the data stored in TypeRepository. Returns iterator to the first data. More...
 
TypeRepositoryMapIter end () const
 Container-like access to the data stored in TypeRepository. Returns iterator to the last data. More...
 

Static Public Member Functions

static TypeRepositoryget_instance ()
 Return singleton instance of class. More...
 

Private Member Functions

 TypeRepository ()
 Default constructor. More...
 

Private Attributes

TypeRepositoryMap type_repository_map_
 Stores input type objects. More...
 

Detailed Description

template<class T>
class Input::TypeRepository< T >

The Singleton class TypeRepository serves for handling the lazy-evaluated input types, derived from the base class Type::TypeBase.

When all static variables are initialized, the method TypeRepository::instance().finish() can be called in order to finish initialization of lazy types such as Records, Abstracts, Arrays and Selections. Selections have to be finished after all other types since they are used by Abstracts to register all derived types. For this reason TypeRepository contains two arrays - one for Selections, one for the rest.

This is list of unique instances that may contain raw pointers to possibly not yet constructed (static) objects. Unique instance is the instance that creates unique instance of the data class in pimpl idiom. These has to be completed/finished before use.

Definition at line 45 of file type_repository.hh.

Member Typedef Documentation

◆ TypeRepositoryMap

template<class T >
typedef std::map< Type::TypeBase::TypeHash, std::shared_ptr<T> > Input::TypeRepository< T >::TypeRepositoryMap

Template parameter can be only descendant of TypeBase class.

Type stored objects of input types.

Definition at line 53 of file type_repository.hh.

◆ TypeRepositoryMapIter

template<class T >
typedef TypeRepositoryMap::const_iterator Input::TypeRepository< T >::TypeRepositoryMapIter

Public typedef of constant iterator into map of stored type.

Definition at line 56 of file type_repository.hh.

Constructor & Destructor Documentation

◆ TypeRepository()

template<class T >
Input::TypeRepository< T >::TypeRepository ( )
inlineprivate

Default constructor.

Definition at line 101 of file type_repository.hh.

Member Function Documentation

◆ add_type()

template<class T >
std::shared_ptr< T > Input::TypeRepository< T >::add_type ( const T &  type)

Add type to TypeRepository if doesn't exist there or get existing type with same TypeHash.

Definition at line 109 of file type_repository.hh.

Here is the caller graph for this function:

◆ begin()

template<class T >
TypeRepositoryMapIter Input::TypeRepository< T >::begin ( ) const
inline

Container-like access to the data stored in TypeRepository. Returns iterator to the first data.

Definition at line 91 of file type_repository.hh.

◆ end()

template<class T >
TypeRepositoryMapIter Input::TypeRepository< T >::end ( ) const
inline

Container-like access to the data stored in TypeRepository. Returns iterator to the last data.

Definition at line 96 of file type_repository.hh.

◆ find_hash()

template<class T >
std::shared_ptr< T > Input::TypeRepository< T >::find_hash ( Type::TypeBase::TypeHash  hash)

Definition at line 124 of file type_repository.hh.

Here is the caller graph for this function:

◆ finish()

template<class T >
void Input::TypeRepository< T >::finish ( Type::FinishStatus  finish_type)

Finish all stored types.

Iterate through all types stored in TypeRepository and call finish with given status.

Note: This method is meant to be used only with FinishType::delete.

Definition at line 134 of file type_repository.hh.

Here is the caller graph for this function:

◆ get_instance()

template<class T >
static TypeRepository& Input::TypeRepository< T >::get_instance ( )
inlinestatic

Return singleton instance of class.

Definition at line 59 of file type_repository.hh.

Here is the caller graph for this function:

◆ reset_deleted_types()

template<class T >
void Input::TypeRepository< T >::reset_deleted_types

Reset and remove types marked as deleted during finish.

Iterate through all types stored in TypeRepository and -

  • check count of usage of shared pointer to type (must be one)
  • reset this shared pointer
  • remove type from repository

Definition at line 141 of file type_repository.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ type_repository_map_

template<class T >
TypeRepositoryMap Input::TypeRepository< T >::type_repository_map_
private

Stores input type objects.

Definition at line 104 of file type_repository.hh.


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