![]() |
Reference documentation for deal.II version 8.1.0
|
#include <subscriptor.h>
Inherited by Algorithms::Operator< VECTOR >, Algorithms::OutputOperator< VECTOR >, Algorithms::TimestepControl, ArpackSolver, BlockDiagonalMatrix< MATRIX >, BlockIndices, BlockInfo, BlockList, 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 >, ChunkSparseMatrix< number > [virtual]
, ChunkSparsityPattern, CompressedSetSparsityPattern, CompressedSimpleSparsityPattern, CompressedSparsityPattern, ConstraintMatrix, DataPostprocessor< dim >, DataPostprocessor< DH::space_dimension >, DoFHandler< dim, spacedim >, hp::DoFHandler< dim >, DoFHandler< dim >, hp::FECollection< dim, FEValues::space_dimension >, hp::FECollection< dim,::FEFaceValues< dim, spacedim >::space_dimension >, hp::FECollection< dim,::FESubfaceValues< dim, spacedim >::space_dimension >, hp::FECollection< dim,::FEValues< dim, spacedim >::space_dimension >, FEValuesBase< dim, spacedim >, FilteredMatrix< VECTOR >, FiniteElement< dim, spacedim >, FiniteElement< dim >, Function< dim >, Function< 2 >, hp::DoFHandler< dim, spacedim >, hp::FECollection< dim, spacedim >, hp::MappingCollection< dim, spacedim >, hp::QCollection< dim >, InterGridMap< GridClass >, InverseMatrixRichardson< VECTOR >, IterativeInverse< VECTOR >, LogStream, Mapping< dim, spacedim >, Mapping< dim, spacedim >::InternalDataBase, Mapping< dim >, hp::MappingCollection< dim, FEValues::space_dimension >, hp::MappingCollection< dim,::FEFaceValues< dim, spacedim >::space_dimension >, hp::MappingCollection< dim,::FESubfaceValues< dim, spacedim >::space_dimension >, hp::MappingCollection< dim,::FEValues< dim, spacedim >::space_dimension >, MatrixBlock< MATRIX >, MatrixBlock< FullMatrix< number > >, MeanValueFilter, MeshWorker::LocalIntegrator< dim, spacedim, number >, MeshWorker::VectorSelector, mg::SparseMatrixCollection< number >, MGCoarseGridBase< VECTOR >, MGConstrainedDoFs, MGLevelObject< Object >, MGLevelObject< MATRIX >, MGLevelObject< MatrixBlock< MATRIX > >, MGLevelObject< PointerMatrix< MATRIX, BlockVector< number > > >, MGLevelObject< PointerMatrix< MATRIX, VECTOR > >, MGLevelObject< PointerMatrix< RELAX, BlockVector< number > > >, MGLevelObject< PRECONDITIONER >, MGLevelObject< RELAX >, MGLevelObject< SparseMatrix< number > >, MGLevelObject< SparsityPattern >, MGLevelObject< std_cxx1x::shared_ptr< PointerMatrixBase< VECTOR > > >, MGLevelObject< VECTOR >, MGMatrixBase< VECTOR >, MGMatrixBase< Vector< number > >, MGMatrixBlockVector< MATRIX >, MGSmootherBase< VECTOR >, MGSmootherBase< BlockVector< number > >, MGTransferBase< VECTOR >, MGTransferBase< BlockVector< number > >, MGTransferBase< Vector< number > >, Multigrid< VECTOR >, NamedData< DATA >, NamedData< BlockVector< number > * >, NamedData< MGLevelObject< MatrixBlock< MATRIX > > >, NamedData< SmartPointer< const MGLevelObject< VECTOR >, MeshWorker::MGVectorData< VECTOR, dim, spacedim > > >, NamedData< SmartPointer< const VECTOR, MeshWorker::VectorData< VECTOR, dim, spacedim > > >, NamedData< SmartPointer< VECTOR, MeshWorker::Assembler::ResidualLocalBlocksToGlobalBlocks< VECTOR > > >, NamedData< SmartPointer< VECTOR, MeshWorker::Assembler::ResidualSimple< VECTOR > > >, NamedData< std_cxx1x::shared_ptr< MatrixBlock< MATRIX > > >, parallel::distributed::Vector< Number >, ParameterHandler, PETScWrappers::MatrixBase, PETScWrappers::VectorBase, Polynomials::PiecewisePolynomial< double >, PointerMatrixBase< VECTOR >, PointerMatrixBase< Vector< number > >, PointerMatrixBase< Vector< vector_number > >, Polynomials::Polynomial< double >, Polynomials::PiecewisePolynomial< number >, Polynomials::Polynomial< number >, PreconditionBlock< MATRIX, inverse_type > [virtual]
, PreconditionBlockJacobi< MATRIX, inverse_type > [virtual]
, PreconditionBlockSOR< MATRIX, inverse_type > [virtual]
, PreconditionBlockSSOR< MATRIX, inverse_type > [virtual]
, PreconditionChebyshev< MATRIX, VECTOR >, 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< dim-1 >, hp::QCollection< q_dim >, Quadrature< dim >, Quadrature< dim-1 >, RelaxationBlock< MATRIX, inverse_type >::AdditionalData, RelaxationBlockJacobi< MATRIX, inverse_type > [virtual]
, RelaxationBlockSOR< MATRIX, inverse_type > [virtual]
, RelaxationBlockSSOR< MATRIX, inverse_type > [virtual]
, ScaledMatrix< VECTOR >, SchurMatrix< MA_inverse, MB, MDt, MC >, Solver< VECTOR >, SolverControl, SolverSelector< VECTOR >, SparseDirectUMFPACK, SparseLUDecomposition< number > [virtual]
, SparseMatrix< number > [virtual]
, SparseMatrixEZ< number >, SparsityPattern, TableBase< N, T >, TableBase< 1, T >, TableBase< 2, inverse_type >, TableBase< 2, number >, TableBase< 2, T >, TableBase< 3, T >, TableBase< 4, T >, TableBase< 5, T >, TableBase< 6, T >, TableBase< 7, T >, TensorFunction< rank, dim >, TensorFunction< 1, dim >, TimeStepBase, Triangulation< dim, spacedim >, Triangulation< 1, spacedim >, Triangulation< DH::dimension, DH::space_dimension >, Triangulation< dim, dim >, TrilinosWrappers::PreconditionBase, TrilinosWrappers::SparseMatrix, TrilinosWrappers::SparsityPattern, TrilinosWrappers::VectorBase, Vector< Number >, Vector< double >, Vector< number >, Vector< typename VECTOR::value_type >, VectorMemory< VECTOR >, VectorMemory< BlockVector< double > >, VectorMemory< BlockVector< number > >, VectorMemory< Vector >, and VectorMemory< Vector< number > >.
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 |
DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects.\n"<< "(Additional information: "<< arg3<< ")\n"<< "Note the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "more information on what this error means.") | |
DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier \""<< arg2<< "\" did subscribe to this object of class "<< arg1) | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
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 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 off if multithreading is used.Definition at line 57 of file subscriptor.h.
|
private |
The data type used in counter_map.
Definition at line 188 of file subscriptor.h.
|
private |
The iterator type used in counter_map.
Definition at line 195 of file subscriptor.h.
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 |
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
.
void Subscriptor::subscribe | ( | const char * | identifier = 0 | ) | const |
Subscribes a user of the object. The subscriber may be identified by text supplied as identifier
.
void Subscriptor::unsubscribe | ( | const char * | identifier = 0 | ) | const |
Unsubscribes a user from the object.
identifier
must be the same pointer as the one supplied to subscribe(), not just the same text. unsigned int Subscriptor::n_subscriptions | ( | ) | const |
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
.
|
inline |
Read or write the data of this object to or from a stream for the purpose of serialization.
This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.
Definition at line 256 of file subscriptor.h.
|
mutableprivate |
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.
Definition at line 227 of file subscriptor.h.
|
mutableprivate |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 235 of file subscriptor.h.
|
mutableprivate |
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.
Definition at line 248 of file subscriptor.h.