PerSt Pile   version 0.0.1
Persistent storage pile used for storing key/value pairs
perst_factory.h
1 
10 #ifndef GUARD_PERST_FACTORY_H_INCLUDE
11 #define GUARD_PERST_FACTORY_H_INCLUDE
12 
13 #include <perst/perst-config.h>
14 
15 class PerSt;
16 struct PerStProvider;
17 
19 class PERST_EXPORT PerStFactory {
20 
21 public:
22 
24  typedef PerSt * (*kbCreate) (
25  const PERST_STRING & name,
26  const PERST_STRING & value,
27  void * user_data);
28 
30  typedef bool (*kbForEach) (
31  int index,
32  const PERST_STRING & name,
33  kbCreate kb,
34  void * user_data,
35  void * for_each_user_data);
36 
37 private:
38  PerStFactory();
39  PerStFactory(const PerStFactory & other);
40  ~PerStFactory();
41 
42 public:
43 
45  static void
46  init ();
47 
49  static void
50  end ();
51 
53  static PerSt *
54  create (
55  const PERST_STRING & name,
56  const PERST_STRING & value);
57 
59  static bool
60  addProvider (
61  const PERST_STRING & name,
62  kbCreate kb,
63  void * user_data);
64 
66  static bool
67  delProvider (
68  const PERST_STRING & name);
69 
71  static bool
72  hasProvider (
73  const PERST_STRING & name);
74 
76  static bool
77  forEachProvider (
78  kbForEach kb,
79  void * for_each_user_data);
80 
81 private:
82 
84  static void
85  autocreate();
86 
89  find (
90  const PERST_STRING & name);
91 
92  std::list<PerStProvider*> providers_;
93  static PerStFactory * singleton_;
94 };
95 
96 #endif // GUARD_PERST_FACTORY_H_INCLUDE
A provider.
Definition: perst_factory.cc:23
Interface class for persistent storage.
Definition: perst.h:17
Factory class that produces PerSt instances.
Definition: perst_factory.h:19