Reference documentation for deal.II version 8.5.1
subscriptor.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__subscriptor_h
17 #define dealii__subscriptor_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 
23 #include <typeinfo>
24 #include <map>
25 #include <string>
26 
27 DEAL_II_NAMESPACE_OPEN
28 
57 {
58 public:
62  Subscriptor();
63 
70  Subscriptor(const Subscriptor &);
71 
72 #ifdef DEAL_II_WITH_CXX11
73 
80 #endif
81 
85  virtual ~Subscriptor();
86 
94 
95 #ifdef DEAL_II_WITH_CXX11
96 
102 #endif
103 
108  void subscribe (const char *identifier = 0) const;
109 
116  void unsubscribe (const char *identifier = 0) const;
117 
123  unsigned int n_subscriptions () const;
124 
128  void list_subscribers () const;
129 
139  int, char *, std::string &,
140  << "Object of class " << arg2
141  << " is still used by " << arg1 << " other objects."
142  << "\n\n"
143  << "(Additional information: " << arg3 << ")\n\n"
144  << "See the entry in the Frequently Asked Questions of "
145  << "deal.II (linked to from http://www.dealii.org/) for "
146  << "a lot more information on what this error means and "
147  << "how to fix programs in which it happens.");
148 
153  DeclException2(ExcNoSubscriber, char *, char *,
154  << "No subscriber with identifier <" << arg2
155  << "> subscribes to this object of class " << arg1
156  << ". Consequently, it cannot be unsubscribed.");
158 
171  template <class Archive>
172  void serialize(Archive &ar, const unsigned int version);
173 
174 private:
178  typedef std::map<const char *, unsigned int>::value_type
180 
184  typedef std::map<const char *, unsigned int>::iterator
186 
203  mutable DEAL_VOLATILE unsigned int counter;
204 
209  mutable std::map<const char *, unsigned int> counter_map;
210 
217  mutable const std::type_info *object_info;
218 
224  void check_no_subscribers () const;
225 };
226 
227 //---------------------------------------------------------------------------
228 
229 template <class Archive>
230 inline
231 void
233  const unsigned int)
234 {
235  // do nothing, as explained in the
236  // documentation of this function
237 }
238 
239 DEAL_II_NAMESPACE_CLOSE
240 
241 #endif
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:576
const std::type_info * object_info
Definition: subscriptor.h:217
void check_no_subscribers() const
Definition: subscriptor.cc:90
Subscriptor & operator=(const Subscriptor &)
Definition: subscriptor.cc:154
static ::ExceptionBase & ExcInUse(int arg1, char *arg2, std::string &arg3)
DEAL_VOLATILE unsigned int counter
Definition: subscriptor.h:203
void subscribe(const char *identifier=0) const
Definition: subscriptor.cc:173
void list_subscribers() const
Definition: subscriptor.cc:234
void serialize(Archive &ar, const unsigned int version)
Definition: subscriptor.h:232
unsigned int n_subscriptions() const
Definition: subscriptor.cc:227
void unsubscribe(const char *identifier=0) const
Definition: subscriptor.cc:200
std::map< const char *, unsigned int > counter_map
Definition: subscriptor.h:209
std::map< const char *, unsigned int >::iterator map_iterator
Definition: subscriptor.h:185
virtual ~Subscriptor()
Definition: subscriptor.cc:78
std::map< const char *, unsigned int >::value_type map_value_type
Definition: subscriptor.h:179
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:588
static ::ExceptionBase & ExcNoSubscriber(char *arg1, char *arg2)