Inherited by BlockDiagonalMatrix< MATRIX >, BlockMatrixArray< number >, BlockMatrixBase< MatrixType >, BlockMatrixBase< PETScWrappers::SparseMatrix >, BlockMatrixBase< SparseMatrix >, BlockMatrixBase< SparseMatrix< number > >, BlockSparseMatrixEZ< Number >, BlockSparsityPatternBase< SparsityPatternBase >, BlockSparsityPatternBase< CompressedSetSparsityPattern >, BlockSparsityPatternBase< CompressedSimpleSparsityPattern >, BlockSparsityPatternBase< CompressedSparsityPattern >, BlockSparsityPatternBase< SparsityPattern >, BlockVectorBase< VectorType >, BlockVectorBase< Vector >, BlockVectorBase< Vector< Number > >, Boundary< dim, spacedim >, Boundary< dim, dim >, Boundary< spacedim, spacedim >, ChunkSparseMatrix< number > [virtual]
, ChunkSparsityPattern, CompressedSetSparsityPattern, CompressedSimpleSparsityPattern, CompressedSparsityPattern, ConstraintMatrix, DataPostprocessor< dim >, DataPostprocessor< DH::space_dimension >, DoFHandler< dim, spacedim >, DoFHandler< dim >, DoFHandler< dim, dim >, hp::FECollection< dim, FEValues::space_dimension >, hp::FECollection< dim,::FEFaceValues< dim >::space_dimension >, hp::FECollection< dim,::FESubfaceValues< dim >::space_dimension >, hp::FECollection< dim,::FEValues< dim, spacedim >::space_dimension >, FEValuesBase< dim, spacedim >, FEValuesBase< dim, dim >, FilteredMatrix< VECTOR >, FiniteElement< dim, spacedim >, FiniteElement< dim, dim >, Function< dim >, Function< 2 >, hp::DoFHandler< dim, spacedim >, hp::FECollection< dim, spacedim >, hp::MappingCollection< dim, spacedim >, hp::QCollection< dim >, InverseMatrixRichardson< VECTOR >, Mapping< dim, spacedim >, Mapping< dim, spacedim >::InternalDataBase, Mapping< dim >, hp::MappingCollection< dim, FEValues::space_dimension >, hp::MappingCollection< dim,::FEFaceValues< dim >::space_dimension >, hp::MappingCollection< dim,::FESubfaceValues< dim >::space_dimension >, hp::MappingCollection< dim,::FEValues< dim, spacedim >::space_dimension >, MeanValueFilter, MGCoarseGridBase< VECTOR >, MGLevelObject< Object >, MGLevelObject< MATRIX >, MGLevelObject< PointerMatrix< MATRIX, BlockVector< number > > >, MGLevelObject< PointerMatrix< MATRIX, VECTOR > >, MGLevelObject< PointerMatrix< RELAX, BlockVector< number > > >, MGLevelObject< RELAX >, MGLevelObject< VECTOR >, MGMatrixBase< VECTOR >, MGMatrixBase< Vector< number > >, MGSmootherBase< VECTOR >, MGSmootherBase< BlockVector< number > >, MGTransferBase< VECTOR >, MGTransferBase< BlockVector< number > >, MGTransferBase< Vector< number > >, Multigrid< VECTOR >, ParameterHandler, PETScWrappers::MatrixBase, PointerMatrixBase< VECTOR >, PointerMatrixBase< Vector< number > >, PointerMatrixBase< Vector< vector_number > >, Polynomials::Polynomial< double >, Polynomials::Polynomial< number >, PreconditionBlock< MATRIX, inverse_type > [virtual]
, PreconditionBlockJacobi< MATRIX, inverse_type > [virtual]
, PreconditionBlockSOR< MATRIX, inverse_type > [virtual]
, PreconditionBlockSSOR< MATRIX, inverse_type > [virtual]
, PreconditionedMatrix< MATRIX, PRECOND, VECTOR >, PreconditionIdentity, PreconditionLACSolver< SOLVER, MATRIX, PRECONDITION >, PreconditionLU< number >, PreconditionMG< dim, VECTOR, TRANSFER >, PreconditionRelaxation< MATRIX >, PreconditionRichardson, PreconditionSelector< Matrix, Vector >, PreconditionUseMatrix< MATRIX, VECTOR >, hp::QCollection< q_dim >, Quadrature< dim >, Quadrature< dim-1 >, ScaledMatrix< VECTOR >, SchurMatrix< MA_inverse, MB, MDt, MC >, Solver< VECTOR >, SolverControl, SolverSelector< VECTOR >, SparseDirectMA27, SparseDirectMA47, SparseDirectUMFPACK, SparseLUDecomposition< number > [virtual]
, SparseMatrix< number > [virtual]
, SparseMatrix< double > [virtual]
, SparseMatrixEZ< number >, SparseMatrixEZ< Number >, SparsityPattern, TableBase< N, T >, TableBase< 1, T >, TableBase< 2, number >, TableBase< 2, T >, TableBase< 3, T >, TableBase< 4, T >, TableBase< 5, T >, TableBase< 6, T >, TableBase< 7, T >, TableBase< N, bool >, TableBase< N, double >, TableBase< N, float >, TableBase< N, int >, TableBase< N, inverse_type >, TableBase< N, number >, TableBase< N, SmartPointer< BlockType > >, TableBase< N, SmartPointer< CompressedSetSparsityPattern > >, TableBase< N, SmartPointer< CompressedSimpleSparsityPattern > >, TableBase< N, SmartPointer< CompressedSparsityPattern > >, TableBase< N, SmartPointer< SparsityPattern > >, TableBase< N, SmartPointer< SparsityPatternBase > >, TableBase< N, SparseMatrixEZ< Number > >, TableBase< N, std_cxx1x::shared_ptr< ::FEFaceValues< dim > > >, TableBase< N, std_cxx1x::shared_ptr< ::FESubfaceValues< dim > > >, TableBase< N, std_cxx1x::shared_ptr< ::FEValues< dim, spacedim > > >, TableBase< N, std_cxx1x::shared_ptr< FEValues > >, TensorFunction< rank, dim >, TimeStepBase, Triangulation< dim, spacedim >, Triangulation< dim >, Triangulation< dim, dim >, TrilinosWrappers::PreconditionBase, TrilinosWrappers::PreconditionBlockBase, TrilinosWrappers::SparseMatrix, TrilinosWrappers::SparsityPattern, TrilinosWrappers::VectorBase, Vector< Number >, Vector< double >, Vector< number >, VectorMemory< VECTOR >, VectorMemory< BlockVector< double > >, VectorMemory< BlockVector< number > >, VectorMemory< Vector< number > >, and VectorMemory< VectorType >.
Classes | |
class | ExcInUse |
class | ExcNoSubscriber |
class | ExcNotUsed |
Public Member Functions | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
void | subscribe (const char *identifier=0) const |
void | unsubscribe (const char *identifier=0) const |
unsigned int | n_subscriptions () const |
void | list_subscribers () const |
Private Types | |
typedef std::map< const char *, unsigned int >::value_type | map_value_type |
typedef std::map< const char *, unsigned int >::iterator | map_iterator |
Private Member Functions | |
void | do_subscribe (const char *id) const |
void | do_unsubscribe (const char *id) const |
Private Attributes | |
DEAL_VOLATILE unsigned int | counter |
std::map< const char *, unsigned int > | counter_map |
const std::type_info * | object_info |
Handling of subscriptions.
This class, as a base class, allows to keep track of other objects using a specific object. It is used, when an object, given to a constructor by reference, is stored. Then, the original object may not be deleted before the dependent object is deleted. You can assert this constraint by letting the object passed be derived from this class and let the user subscribe() to this object. The destructor the used object inherits from the Subscriptor class then will lead to an error when destruction is attempted while there are still subscriptions.
The utility of this class is even enhanced by providing identifying strings to the functions subscribe() and unsubscribe(). In case of a hanging subscription during destruction, this string will be listed in the exception's message. For reasons of efficiency, these strings are handled as const char*
. 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.
volatile
declarations, this additional feature is switched of if multithreading is used.typedef std::map<const char*, unsigned int>::value_type Subscriptor::map_value_type [private] |
The data type used in counter_map.
typedef std::map<const char*, unsigned int>::iterator Subscriptor::map_iterator [private] |
The iterator type used in counter_map.
Subscriptor::Subscriptor | ( | ) |
Constructor setting the counter to zero.
Subscriptor::Subscriptor | ( | const Subscriptor & | ) |
Copy-constructor.
The counter of the copy is zero, since references point to the original object.
virtual Subscriptor::~Subscriptor | ( | ) | [virtual] |
Destructor, asserting that the counter is zero.
Subscriptor& Subscriptor::operator= | ( | const Subscriptor & | ) |
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
.
Reimplemented in Function< dim >, ParameterHandler, Quadrature< dim >, TableBase< N, T >, TableBase< N, T >, BlockSparseMatrix< number >, BlockSparseMatrixEZ< Number >, BlockSparsityPatternBase< SparsityPatternBase >, BlockVector< Number >, BlockVector< Number >, BlockVectorBase< VectorType >, BlockVectorBase< VectorType >, ChunkSparseMatrix< number >, ChunkSparsityPattern, CompressedSetSparsityPattern, CompressedSimpleSparsityPattern, CompressedSparsityPattern, FilteredMatrix< VECTOR >, FullMatrix< number >, FullMatrix< number >, LAPACKFullMatrix< number >, PETScWrappers::BlockSparseMatrix, PETScWrappers::BlockVector, PETScWrappers::MPI::BlockSparseMatrix, PETScWrappers::MPI::BlockVector, SchurMatrix< MA_inverse, MB, MDt, MC >, SparseMatrix< number >, SparseMatrixEZ< number >, SparsityPattern, SwappableVector< number >, TrilinosWrappers::BlockSparseMatrix, TrilinosWrappers::MPI::BlockVector, TrilinosWrappers::BlockVector, TrilinosWrappers::MPI::Vector, TrilinosWrappers::Vector, TrilinosWrappers::VectorBase, Vector< Number >, Vector< Number >, DoFHandler< dim, spacedim >, hp::DoFHandler< dim, spacedim >, FEValuesBase< dim, spacedim >, TimeStepBase, TableBase< N, number >, TableBase< N, std_cxx1x::shared_ptr< ::FEFaceValues< dim > > >, TableBase< N, std_cxx1x::shared_ptr< FEValues > >, TableBase< N, SmartPointer< SparsityPattern > >, TableBase< N, bool >, TableBase< N, SmartPointer< CompressedSetSparsityPattern > >, TableBase< N, std_cxx1x::shared_ptr< ::FEValues< dim, spacedim > > >, TableBase< N, int >, TableBase< N, SmartPointer< SparsityPatternBase > >, TableBase< N, SparseMatrixEZ< Number > >, TableBase< N, SmartPointer< CompressedSimpleSparsityPattern > >, TableBase< N, SmartPointer< BlockType > >, TableBase< N, std_cxx1x::shared_ptr< ::FESubfaceValues< dim > > >, TableBase< N, float >, TableBase< N, double >, TableBase< N, inverse_type >, TableBase< N, SmartPointer< CompressedSparsityPattern > >, FullMatrix< double >, FullMatrix< inverse_type >, SparseMatrix< double >, SparseMatrixEZ< Number >, Vector< double >, and Vector< number >.
void Subscriptor::subscribe | ( | const char * | identifier = 0 |
) | const [inline] |
Subscribes a user of the object. The subscriber may be identified by text supplied as identifier
.
References do_subscribe().
void Subscriptor::unsubscribe | ( | const char * | identifier = 0 |
) | const [inline] |
Unsubscribes a user from the object.
identifier
must be the same pointer as the one supplied to subscribe(), not just the same text. References do_unsubscribe().
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.
void Subscriptor::list_subscribers | ( | ) | const |
List the subscribers to deallog.
void Subscriptor::do_subscribe | ( | const char * | id | ) | const [private] |
Register a subscriber for debugging purposes. Called by subscribe() in debug mode.
Referenced by subscribe().
void Subscriptor::do_unsubscribe | ( | const char * | id | ) | const [private] |
Deregister a subscriber for debugging purposes. Called by unsubscribe() in debug mode.
Referenced by unsubscribe().
DEAL_VOLATILE unsigned int Subscriptor::counter [mutable, private] |
Store the number of objects which subscribed to this object. Initialally, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).
The creator (and owner) of an object is counted in the map below if HE manages to supply identification.
We use the mutable
keyword in order to allow subscription to constant objects also.
In multithreaded mode, this counter may be modified by different threads. We thus have to mark it volatile
. However, this is counter-productive in non-MT mode since it may pessimize code. So use the macro defined above to selectively add volatility.
std::map<const char*, unsigned int> Subscriptor::counter_map [mutable, private] |
In this map, we count subscriptions for each different identification strig supplied to subscribe().
const std::type_info* Subscriptor::object_info [mutable, private] |
Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.