DOLFIN
DOLFIN C++ interface
UniqueIdGenerator.h
1 // Copyright (C) 2010 Garth N. Wells
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2010-12-05
19 // Last changed:
20 
21 #ifndef __UNIQUE_ID_GENERATOR_H
22 #define __UNIQUE_ID_GENERATOR_H
23 
24 #include <cstddef>
25 
26 namespace dolfin
27 {
28 
29  // FIXME: Make a base class that classes can inherit from
30 
33 
35  {
36  public:
37 
39 
41  static std::size_t id();
42 
43  private:
44 
45  // Singleton instance
46  static UniqueIdGenerator unique_id_generator;
47 
48  // Next ID to be returned
49  std::size_t next_id;
50 
51  };
52 
53 }
54 
55 #endif
Definition: adapt.h:29
Definition: UniqueIdGenerator.h:34
static std::size_t id()
Generate a unique ID.
Definition: UniqueIdGenerator.cpp:34