datapool.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_core_datapool_hh
22 #define mia_core_datapool_hh
23 
24 #include <map>
25 #include <boost/any.hpp>
26 
27 #include <mia/core/defines.hh>
28 #include <tbb/recursive_mutex.h>
29 
30 
32 
51 public:
52 
58  void add(const std::string& key, boost::any value);
63  boost::any get(const std::string& key) const;
64 
70  boost::any get_and_remove(const std::string& key);
71 
76  bool has_key(const std::string& key) const;
80  static CDatapool& instance();
81 
86  bool has_unused_data() const;
87 
91  void clear();
92 private:
93 
94  CDatapool();
95  CDatapool(const CDatapool& other);
96  typedef std::map<std::string, boost::any> Anymap;
97  typedef Anymap::const_iterator const_iterator;
98  const_iterator get_iterator(const std::string& key) const;
99  Anymap m_map;
100  typedef std::map<std::string,bool> Usagemap;
101  mutable Usagemap m_usage;
102  static tbb::recursive_mutex m_mutex;
103 };
104 
106 
107 #endif