Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Subscriptor Class Reference

#include <deal.II/base/subscriptor.h>

Inherited by AffineConstraints< number >, AffineConstraints< double >, AffineConstraints< typename MatrixType::value_type >, AffineConstraints< typename VectorType::value_type >, Algorithms::OperatorBase, Algorithms::OutputOperator< VectorType >, Algorithms::TimestepControl, AnyData, ArpackSolver, MatrixFreeOperators::Base< dim, LinearAlgebra::distributed::Vector< double >, VectorizedArray< typename LinearAlgebra::distributed::Vector< double > ::value_type > >, BlockIndices, BlockInfo, BlockVectorBase< VectorType >, BlockVectorBase< MPI::Vector >, BlockVectorBase< Vector >, BlockVectorBase< Vector< double > >, BlockVectorBase< Vector< number > >, BlockVectorBase< Vector< Number > >, CellDataStorage< CellIteratorType, DataType >, ChunkSparseMatrix< number > [virtual], ChunkSparsityPattern, CUDAWrappers::MatrixFree< dim, Number >, DataPostprocessor< dim >, DataPostprocessor< DoFHandler< dim > ::space_dimension >, DataPostprocessor< DoFHandlerType::space_dimension >, DiagonalMatrix< VectorType >, DiagonalMatrix< LinearAlgebra::distributed::Vector< double > >, DoFHandler< dim, spacedim >, hp::DoFHandler< dim >, DoFHandler< dim >, hp::DoFHandler< dim, dim >, DynamicSparsityPattern, hp::FECollection< dim, ::FEFaceValues< dim, dim > ::space_dimension >, hp::FECollection< dim, ::FEFaceValues< dim, spacedim > ::space_dimension >, hp::FECollection< dim, ::FEValues< dim, dim > ::space_dimension >, hp::FECollection< dim, ::FEValues< dim, spacedim > ::space_dimension >, hp::FECollection< dim, dim >, hp::FECollection< dim, FEValuesType::space_dimension >, FETools::FEFactoryBase< FE::dimension, FE::space_dimension >, FESeries::Fourier< dim, spacedim >, FESeries::Legendre< dim, spacedim >, FETools::FEFactoryBase< dim, spacedim >, FiniteElement< dim, spacedim >, FiniteElement< 1, spacedim >, FiniteElement< 2, 2 >, FiniteElement< dim >, FiniteElement< dim, dim >, FiniteElement< PolynomialType::dimension+1, PolynomialType::dimension+1 >, FiniteElement< PolynomialType::dimension, PolynomialType::dimension >, Function< dim, RangeNumberType >, Function< 2 >, Function< dim >, Function< dim, double >, Function< dim, Vector< double > ::value_type >, GeneralDataStorage, hp::DoFHandler< dim, spacedim >, hp::FECollection< dim, spacedim >, hp::MappingCollection< dim, spacedim >, hp::QCollection< dim >, InterGridMap< MeshType >, LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::EpetraWrappers::Vector, LinearAlgebra::ReadWriteVector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LogStream, Manifold< dim, spacedim >, Manifold< dim, dim >, Mapping< dim, spacedim >, Mapping< dim >, Mapping< dim, dim >, hp::MappingCollection< dim, ::FEFaceValues< dim, dim > ::space_dimension >, hp::MappingCollection< dim, ::FEFaceValues< dim, spacedim > ::space_dimension >, hp::MappingCollection< dim, ::FEValues< dim, dim > ::space_dimension >, hp::MappingCollection< dim, ::FEValues< dim, spacedim > ::space_dimension >, hp::MappingCollection< dim, dim >, hp::MappingCollection< dim, FEValuesType::space_dimension >, MatrixBlock< MatrixType >, MatrixBlock< FullMatrix< double > >, MatrixBlock< FullMatrix< number > >, MatrixFree< dim, Number, VectorizedArrayType >, MatrixFree< dim, double, VectorizedArray< double > >, MatrixFree< dim, Number, VectorizedArray< Number > >, MatrixFree< dim, value_type, VectorizedArray< typename LinearAlgebra::distributed::Vector< double > ::value_type > >, MatrixFreeOperators::Base< dim, VectorType, VectorizedArrayType >, MatrixFreeOperators::MGInterfaceOperator< OperatorType >, MeshWorker::LocalIntegrator< dim, spacedim, number >, MeshWorker::VectorSelector, mg::SparseMatrixCollection< number >, MGCoarseGridBase< VectorType >, MGCoarseGridBase< Vector< double > >, MGConstrainedDoFs, MGLevelObject< Object >, MGLevelObject< LinearAlgebra::distributed::Vector< Number > >, MGLevelObject< LinearOperator< BlockVector< number > > >, MGLevelObject< LinearOperator< Vector< double > > >, MGLevelObject< LinearOperator< VectorType > >, MGLevelObject< MatrixType >, MGLevelObject< PreconditionerType >, MGLevelObject< RelaxationType >, MGLevelObject< SparseMatrix< number > >, MGLevelObject< SparsityPattern >, MGLevelObject< std::shared_ptr< const Utilities::MPI::Partitioner > >, MGLevelObject< VectorType >, MGMatrixBase< VectorType >, MGMatrixBase< Vector< double > >, MGMatrixBase< Vector< number > >, MGMatrixBlockVector< MatrixType >, MGSmootherBase< VectorType >, MGSmootherBase< BlockVector< number > >, MGSmootherBase< Vector< double > >, MGTransferBase< VectorType >, MGTransferBase< BlockVector< number > >, MGTransferBase< LinearAlgebra::distributed::BlockVector< Number > >, MGTransferBase< LinearAlgebra::distributed::Vector< Number > >, MGTransferBase< Vector< number > >, Multigrid< VectorType >, ParameterAcceptor, ParameterHandler, PArpackSolver< VectorType >, PETScWrappers::MatrixBase, PETScWrappers::VectorBase, Polynomials::PiecewisePolynomial< double >, Polynomials::Polynomial< double >, Polynomials::PiecewisePolynomial< number >, Polynomials::Polynomial< number >, PreconditionBlock< MatrixType, inverse_type > [virtual], PreconditionBlock< MatrixType, typename MatrixType::value_type > [virtual], PreconditionBlockJacobi< MatrixType, inverse_type > [virtual], PreconditionBlockSOR< MatrixType, inverse_type > [virtual], PreconditionBlockSOR< MatrixType, typename MatrixType::value_type > [virtual], PreconditionBlockSSOR< MatrixType, inverse_type > [virtual], PreconditionChebyshev< MatrixType, VectorType, PreconditionerType >, PreconditionIdentity, PreconditionLU< number >, PreconditionMG< dim, VectorType, TRANSFER >, PreconditionRelaxation< MatrixType >, PreconditionRelaxation< SparseMatrix< double > >, PreconditionRichardson, PreconditionSelector< MatrixType, VectorType >, PreconditionUseMatrix< MatrixType, VectorType >, hp::QCollection< q_dim >, Quadrature< dim >, Quadrature< 1 >, Quadrature< dim - 1 >, Quadrature< structdim >, RelaxationBlock< MatrixType, InverseNumberType, VectorType >::AdditionalData, RelaxationBlockJacobi< MatrixType, InverseNumberType, VectorType > [virtual], RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType > [virtual], RelaxationBlockSSOR< MatrixType, InverseNumberType, VectorType > [virtual], SolverBase< VectorType >, SolverBase< Vector< double > >, SolverControl, SolverSelector< VectorType >, SparseDirectUMFPACK, SparseLUDecomposition< number > [virtual], SparseMatrix< number > [virtual], SparseMatrix< double > [virtual], SparseMatrixEZ< number >, SparseMatrixEZ< Number >, SparsityPatternBase, TableBase< N, T >, TableBase< 1, T >, TableBase< 2, double >, TableBase< 2, inverse_type >, TableBase< 2, InverseNumberType >, TableBase< 2, number >, TableBase< 2, Number >, TableBase< 2, NumberType >, TableBase< 2, T >, TableBase< 2, typename MatrixType::value_type >, TableBase< 3, T >, TableBase< 4, T >, TableBase< 5, T >, TableBase< 6, T >, TableBase< 7, T >, TableBase< N, CoefficientType >, TableBase< N, DerivativeForm< 1, dim, spacedim > >, TableBase< N, DerivativeForm< 2, dim, spacedim > >, TableBase< N, double >, TableBase< N, float >, TableBase< N, int >, TableBase< N, internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< double > > >, TableBase< N, internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< Number > > >, TableBase< N, internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< typename LinearAlgebra::distributed::Vector< double > ::value_type > > >, TableBase< N, internal::MatrixFreeFunctions::UnivariateShapeData< Number > * >, TableBase< N, internal::MatrixFreeFunctions::UnivariateShapeData< VectorizedArray< double > > * >, TableBase< N, internal::MatrixFreeFunctions::UnivariateShapeData< VectorizedArray< Number > > * >, TableBase< N, internal::MatrixFreeFunctions::UnivariateShapeData< VectorizedArray< typename LinearAlgebra::distributed::Vector< double > ::value_type > > * >, TableBase< N, internal::MatrixFreeFunctions::UnivariateShapeData< VectorizedArrayType > * >, TableBase< N, inverse_type >, TableBase< N, InverseNumberType >, TableBase< N, Number >, TableBase< N, number >, TableBase< N, SmartPointer< BlockType, BlockMatrixBase< MatrixType > > >, TableBase< N, SmartPointer< BlockType, BlockMatrixBase< SparseMatrix > > >, TableBase< N, SmartPointer< BlockType, BlockMatrixBase< SparseMatrix< double > > > >, TableBase< N, SmartPointer< BlockType, BlockMatrixBase< SparseMatrix< number > > > >, TableBase< N, SmartPointer< DynamicSparsityPattern, BlockSparsityPatternBase< DynamicSparsityPattern > > >, TableBase< N, SmartPointer< SparsityPattern, BlockSparsityPatternBase< SparsityPattern > > >, TableBase< N, SmartPointer< SparsityPatternType, BlockSparsityPatternBase< SparsityPatternType > > >, TableBase< N, SparseMatrixEZ< Number > >, TableBase< N, std::unique_ptr< ::FEFaceValues< dim, dim > > >, TableBase< N, std::unique_ptr< ::FEFaceValues< dim, spacedim > > >, TableBase< N, std::unique_ptr< ::FEValues< dim, dim > > >, TableBase< N, std::unique_ptr< ::FEValues< dim, spacedim > > >, TableBase< N, std::unique_ptr< FEValuesType > >, TableBase< N, Tensor< 1, dim > >, TableBase< N, Tensor< 2, dim > >, TableBase< N, Tensor< 3, dim > >, TableBase< N, typename MatrixType::value_type >, TableBase< N, unsigned int >, TableBase< N, VectorizedArray< Number > >, TableBase< N, VectorizedArray< typename LinearAlgebra::distributed::Vector< double > ::value_type > >, TensorFunction< rank, dim, Number >, TensorFunction< 1, dim, double >, TensorFunction< rank, dim, double >, TimeStepBase, Triangulation< dim, spacedim >, Triangulation< 1, spacedim >, Triangulation< dim >, Triangulation< dim, dim >, Triangulation< dimension, space_dimension >, Triangulation< DoFHandler< dim > ::dimension, DoFHandler< dim > ::space_dimension >, Triangulation< DoFHandlerType::dimension, DoFHandlerType::space_dimension >, TrilinosWrappers::MPI::Vector, TrilinosWrappers::PreconditionBase, TrilinosWrappers::SparseMatrix, TrilinosWrappers::SparsityPattern, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< Number >, VectorMemory< VectorType >, VectorMemory< ::Vector< double > >, VectorMemory< BlockVector< number > >, VectorMemory< Vector< double > >, and VectorMemory< Vector< number > >.

Public Member Functions

 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&) noexcept
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&) noexcept
 
void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Private Types

using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 

Private Member Functions

void check_no_subscribers () const noexcept
 

Private Attributes

std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 

Static Private Attributes

static std::mutex mutex
 

Detailed Description

Handling of subscriptions.

This class, as a base class, allows to keep track of other objects using a specific object. It is used to avoid that pointers that point to an object of a class derived from Subscriptor are referenced after that object has been invalidated. Here, invalidation is assumend to happen when the object is moved from or destroyed. The mechanism works as follows: The member function subscribe() accepts a pointer to a boolean that is modified on invalidation. The object that owns this pointer (usually an object of class type SmartPointer) is then expected to check the state of the boolean before trying to access this class.

The utility of this class is even enhanced by providing identifying strings to the functions subscribe() and unsubscribe(). These strings are represented as const char pointers since the underlying buffer comes from (and is managed by) the run-time type information system: more exactly, these pointers are the result the function call typeid(x).name() where x is some object. Therefore, the pointers provided to subscribe() and to unsubscribe() must be the same. Strings with equal contents will not be recognized to be the same. The handling in SmartPointer will take care of this. The current subscribers to this class can be obtained by calling list_subscribers().

Author
Guido Kanschat, Daniel Arndt, 1998 - 2005, 2018

Definition at line 62 of file subscriptor.h.

Constructor & Destructor Documentation

◆ Subscriptor() [1/3]

Subscriptor::Subscriptor ( )
inline

Constructor setting the counter to zero.

Definition at line 268 of file subscriptor.h.

◆ Subscriptor() [2/3]

Subscriptor::Subscriptor ( const Subscriptor )
inline

Copy-constructor.

The counter of the copy is zero, since references point to the original object.

Definition at line 275 of file subscriptor.h.

◆ Subscriptor() [3/3]

Subscriptor::Subscriptor ( Subscriptor &&  subscriptor)
noexcept

Move constructor.

An object inheriting from Subscriptor can only be moved if no other objects are subscribing to it.

Definition at line 33 of file subscriptor.cc.

◆ ~Subscriptor()

Subscriptor::~Subscriptor ( )
virtual

Destructor, asserting that the counter is zero.

Definition at line 43 of file subscriptor.cc.

Member Function Documentation

◆ operator=() [1/2]

Subscriptor & Subscriptor::operator= ( const Subscriptor s)
inline

Assignment operator.

This has to be handled with care, too, because the counter has to remain the same. It therefore does nothing more than returning *this.

Definition at line 283 of file subscriptor.h.

◆ operator=() [2/2]

Subscriptor & Subscriptor::operator= ( Subscriptor &&  s)
noexcept

Move assignment operator. Only invalidates the object moved from.

Definition at line 123 of file subscriptor.cc.

◆ subscribe()

void Subscriptor::subscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const

Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.

Definition at line 134 of file subscriptor.cc.

◆ unsubscribe()

void Subscriptor::unsubscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const

Unsubscribes a user from the object.

Note
The identifier and the validity pointer must be the same as the one supplied to subscribe().

Definition at line 154 of file subscriptor.cc.

◆ n_subscriptions()

unsigned int Subscriptor::n_subscriptions ( ) const
inline

Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.

Definition at line 292 of file subscriptor.h.

◆ list_subscribers() [1/2]

template<typename StreamType >
void Subscriptor::list_subscribers ( StreamType &  stream) const
inline

List the subscribers to the input stream.

Definition at line 309 of file subscriptor.h.

◆ list_subscribers() [2/2]

void Subscriptor::list_subscribers ( ) const

List the subscribers to deallog.

Definition at line 202 of file subscriptor.cc.


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