Singleton that is aware of all considered unknown, regardless of GodOfDof.
More...
#include <UnknownManager.hpp>
|
static const std::string & | ClassName () |
| Return the name of the class.
|
|
static UnknownManager & | CreateOrGetInstance (const std::source_location location=std::source_location::current(), Args &&... args) |
| Call instance of the singleton.
|
|
static UnknownManager & | GetInstance (const std::source_location location=std::source_location::current()) |
| Call an instance of the singleton that must already have been created.
|
|
static void | Destroy () |
| Destroy the singleton.
|
|
|
static void | OnDeadReference (const std::source_location location=std::source_location::current()) |
| Gets called if dead reference detected.
|
|
static std::mutex & | GetNonCstSingletonMutex () |
| Get reference to the singleton mutex.
|
|
|
static UnknownManager * | instance_ |
| Internal pointer to the actual instance.
|
|
static bool | destroyed_ |
| Used for protection against dead reference problem (invocation while the instance has been destroyed).
|
|
static std::mutex | singleton_mutex_ |
| Mutex object.
|
|
|
class | Utilities::Singleton< UnknownManager > |
| Friendship declaration to Singleton template class (to enable call to constructor).
|
|
| UnknownManager ()=default |
| Constructor.
|
|
virtual | ~UnknownManager () override |
| Destructor.
|
|
Singleton that is aware of all considered unknown, regardless of GodOfDof.
Each of the unknowns must be defined in the input data file.
◆ indexed_section_tag
Convenient alias to the (internal) tag used to identify IndexedSection of a specific type (e.g. all the sections related to a Mesh).
Tag used to identify IndexedSection
of a given type (e.g. all Mesh
sections in the input data or model settings)
◆ UnknownManager() [1/2]
The copy constructor.
- Parameters
-
[in] | rhs | The object from which the construction occurs. |
◆ UnknownManager() [2/2]
The move constructor.
- Parameters
-
[in] | rhs | The object from which the construction occurs. |
◆ operator=() [1/2]
The (copy) operator=.
- Parameters
-
[in] | rhs | The object from which the affectation occurs. |
- Returns
- Reference to the object (to enable chained affectation).
◆ operator=() [2/2]
The (move) operator=.
- Parameters
-
[in] | rhs | The object from which the affectation occurs. |
- Returns
- Reference to the object (to enable chained affectation).
◆ Create() [1/2]
template<class IndexedSectionDescriptionT , ::MoReFEM::Concept::ModelSettingsType ModelSettingsT, ::MoReFEM::Concept::InputDataType InputDataT>
void MoReFEM::UnknownManager::Create |
( |
const IndexedSectionDescriptionT & | indexed_section_description, |
|
|
const ModelSettingsT & | model_settings, |
|
|
const InputDataT & | input_data ) |
Create a Unknown object from InputData and ModelSettings information.
- Parameters
-
[in] | indexed_section_description | Instantiation of a IndexedSectionDescription object that is a placeholder to tell a given IndexedSection exists for the Model. Most of the time the instantiation itself is not used and the relevant information is in fact its type (from which type of the IndexedSection may be inferred). |
- Parameters
-
[in] | model_settings | Object which hold the values of all the input data that should not be modifiable by the end user. Example (in most of the models): NumberingSubset in which an Unknown should be allotted in a FEltSpace. |
- Parameters
-
[in] | input_data | Object which hold the values of all the input data that were defined in the Lua file (and that is thus modifiable by the end user). Example (in most of the models): the shape function to use for an Unknown in a FEltSpace. |
◆ GetUnknown() [1/2]
Get the unknown associated with unique_id.
- Parameters
-
◆ GetUnknownPtr() [1/2]
Get the unknown associated with unique_id as a smart pointer.
- Parameters
-
◆ GetUnknown() [2/2]
const Unknown & MoReFEM::UnknownManager::GetUnknown |
( |
const std::string & | name | ) |
const |
Get the unknown which name is given as argument.
- Parameters
-
◆ GetUnknownPtr() [2/2]
Get the unknown which name is given as argument.
- Parameters
-
◆ Create() [2/2]
void MoReFEM::UnknownManager::Create |
( |
UnknownNS::unique_id | unique_id, |
|
|
const std::string & | name, |
|
|
const std::string & | nature ) |
|
private |
Create a new Unknown, which is a unique id, a name and a nature (scalar or vectorial).
- Parameters
-
[in] | unique_id | Unique identifier of the unknown, used to tag it in the input data file. |
[in] | name | Name of the unknown, which can be whatever you wish provided it's unique within the model. |
[in] | nature | Whether the unknown is scalar or vectorial. |
◆ Clear()
void MoReFEM::UnknownManager::Clear |
( |
| ) |
|
|
private |
◆ RegisterUnknown()
Register properly unknown in use.
- Parameters
-
[in] | unknown | New Unknown to register. |
◆ CreateOrGetInstance()
Call instance of the singleton.
If not already existing it will be created on the fly, otherwise the existing one will be used. This method should be called in two cases:
- If we do not know whether the instance already exists or not. The most typical example is when a value is registered within the singleton in an anonymous namespace.
- If we know for sure it is the first call to the singleton. For instance the initialization of TimeKeep sinfgleton class that sets the initial time.
In all other cases, call instead GetInstance().
- Template Parameters
-
Args | Variadic template arguments. |
- Parameters
-
[in] | args | Arguments passed to the constructor if the object is to be built. |
- Parameters
-
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
- Returns
- Instance of the singleton.
◆ GetInstance()
Call an instance of the singleton that must already have been created.
This must be called instead of CreateOrGetInstance(location) if T doesn't get a default constructor.
- Parameters
-
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
- Returns
- Instance of the singleton.
◆ OnDeadReference()
Gets called if dead reference detected.
- Parameters
-
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
◆ MoReFEM::TestNS::ClearSingletons
Friendship to a function in tests that is allowed to call Clear(). This function should be used only for tests!
◆ destroyed_
Used for protection against dead reference problem (invocation while the instance has been destroyed).
Should not occur in our case, but it is much safer to put the protection there anyway.
◆ singleton_mutex_
Mutex object.
This follows item 16 of Scott Meyers's "Effective Modern C++", which advises to make const member functions thread safe.
The documentation for this class was generated from the following file:
- /builds/2mk6rsew/0/MoReFEM/CoreLibrary/MoReFEM/Sources/FiniteElement/Unknown/UnknownManager.hpp