h5cpp  0.5.1
A modern C++ wrapper for the HDF5 C library
context.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5pp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Author: Martin Shetty <martin.shetty@esss.se>
23 //
24 #pragma once
25 
26 #include <h5cpp/core/object_id.hpp>
27 #include <map>
28 #include <mutex>
29 
30 namespace hdf5
31 {
32 
33 class Context
34 {
35  public:
36  void open(const hid_t&);
37  bool is_open(const hid_t&) const;
38  void close(const hid_t&);
39 
40  private:
41  mutable std::mutex mutex_;
42  std::map<id, hid_t> objects_;
43 
44  void close(const id&);
45 
46  //singleton assurance
47  public:
48  static Context& singleton()
49  {
50  static Context singleton_instance;
51  return singleton_instance;
52  }
53 
54  Context(Context const&) = delete;
55  void operator=(Context const&) = delete;
56 
57  private:
58  Context() {}
59  ~Context();
60 };
61 
62 
63 }
Definition: context.hpp:34
bool is_open(const hid_t &) const
Context(Context const &)=delete
void operator=(Context const &)=delete
void close(const hid_t &)
void open(const hid_t &)
static Context & singleton()
Definition: context.hpp:48
top-level namespace of the entire library
Definition: attribute.hpp:45