4753cdb5b3243219ad798d1581df74ee2beab986
[gssweb.git] / json_gssapi / src / cache / GSSNameCache.h
1 /*
2  * Copyright (c) 2014 <copyright holder> <email>
3  *
4  * For license details, see the LICENSE file in the root of this project.
5  *
6  */
7
8 #ifndef GSSNAMECACHE_H
9 #define GSSNAMECACHE_H
10
11 #include <map>
12 #include <string>
13
14 #include "datamodel/GSSName.h"
15
16 typedef std::map<std::string, GSSName*> NameMap;
17
18 class GSSNameCache
19 {
20 public:
21     static GSSNameCache* instance();
22     ~GSSNameCache();
23     GSSNameCache& operator= ( const GSSNameCache& other );
24     
25     std::string store(GSSName &data, const std::string key = "");
26     GSSName &retrieve(std::string key);
27     NameMap getNames() { return(names); };
28
29 protected:
30     GSSNameCache();
31     GSSNameCache ( const GSSNameCache& other );
32
33 private:
34     NameMap names;
35     
36     bool generateKey(std::string &key);
37     static GSSNameCache* _instance;
38 };
39
40 #endif // GSSNAMECACHE_H