dune-fem  2.8-git
idprovider.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_IDPROVIDER_HH
2 #define DUNE_FEM_IDPROVIDER_HH
3 
4 #include <cstdlib>
5 
7 
8 namespace Dune
9 {
10 
11  namespace Fem
12  {
13 
15  class IdProvider
16  {
17  public:
18  friend class Dune::Fem::Singleton< IdProvider >;
19 
21  static IdProvider& instance()
22  {
24  }
25 
28  size_t newId() { return lowestFreeId_++; }
29 
32  lowestFreeId_(0)
33  {}
34 
35  private:
36  IdProvider(const IdProvider&);
37  IdProvider& operator=(const IdProvider&);
38 
39  private:
40  size_t lowestFreeId_;
41  };
42 
43  } // namespace Fem
44 
45 } // namespace Dune
46 
47 #endif // #ifndef DUNE_FEM_IDPROVIDER_HH
Definition: bindguard.hh:11
Singleton that manages a globally unique identifier.
Definition: idprovider.hh:16
IdProvider()
Constructor (for the singleton object)
Definition: idprovider.hh:31
size_t newId()
Definition: idprovider.hh:28
static IdProvider & instance()
Access to the singleton object.
Definition: idprovider.hh:21
return singleton instance of given Object type.
Definition: singleton.hh:71
static Object & instance(Args &&... args)
return singleton instance of given Object type.
Definition: singleton.hh:101