EMAN2
emcache.h
Go to the documentation of this file.
1/*
2 * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32
33#ifdef IMAGEIO_CACHE
34#ifndef eman__emcache__h__
35#define eman__emcache__h__ 1
36
37#include <cstdlib>
38#include <string>
39#include <map>
40using std::string;
41using std::map;
42
43namespace EMAN
44{
45 class ImageIO;
46
47 /* GlobalCache is a Singleton class that handles cache across EMAN. */
48 class GlobalCache
49 {
50 public:
51 static GlobalCache *instance();
52 ImageIO *get_imageio(const string & filename, int rw);
53 int contains(const string & filename);
54 void add_imageio(const string & filename, int rw, int persist, ImageIO * io);
55 void close_imageio(const string & filename);
56 void delete_imageio(const string & filename);
57 void clean();
58
59 private:
60 pthread_mutex_t mutex;
61 static GlobalCache *global_cache;
62 map < string, ImageIO* >file_imageio;
63 map < string, int >file_rw;
64 map < string, int >file_ref;
65 map < string, int >file_time;
66 map < string, int >file_persist;
67
68 GlobalCache();
69 ~GlobalCache();
70
71 };
72
73}
74
75#endif // Header check
76#endif // IMAGEIO_CACHE
E2Exception class.
Definition: aligner.h:40