monotone

monotone Mtn Source Tree

Root/botan/libstate.h

1/*************************************************
2* Library Internal/Global State Header File *
3* (C) 1999-2006 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_LIB_STATE_H__
7#define BOTAN_LIB_STATE_H__
8
9#include <botan/base.h>
10#include <botan/enums.h>
11#include <botan/ui.h>
12#include <string>
13#include <vector>
14#include <map>
15
16namespace Botan {
17
18/*************************************************
19* Global State Container Base *
20*************************************************/
21class Library_State
22 {
23 public:
24 class Engine_Iterator
25 {
26 public:
27 class Engine* next();
28 Engine_Iterator(const Library_State& l) : lib(l) { n = 0; }
29 private:
30 const Library_State& lib;
31 u32bit n;
32 };
33 friend class Engine_Iterator;
34
35 class UI
36 {
37 public:
38 virtual void pulse(Pulse_Type) {}
39 virtual ~UI() {}
40 };
41
42 Allocator* get_allocator(const std::string& = "") const;
43 void add_allocator(Allocator*);
44 void set_default_allocator(const std::string&) const;
45
46 bool rng_is_seeded() const { return rng->is_seeded(); }
47 void randomize(byte[], u32bit);
48
49 void set_prng(RandomNumberGenerator*);
50 void add_entropy_source(EntropySource*, bool = true);
51 void add_entropy(const byte[], u32bit);
52 void add_entropy(EntropySource&, bool);
53 u32bit seed_prng(bool, u32bit);
54
55 void load(class Modules&);
56
57 void set_timer(class Timer*);
58 u64bit system_clock() const;
59
60 class Config& config() const;
61
62 void add_engine(class Engine*);
63
64 class Mutex* get_mutex() const;
65 class Mutex* get_named_mutex(const std::string&);
66
67 void set_x509_state(class X509_GlobalState*);
68 class X509_GlobalState& x509_state();
69
70 void pulse(Pulse_Type) const;
71 void set_ui(UI*);
72
73 void set_transcoder(class Charset_Transcoder*);
74 std::string transcode(const std::string,
75 Character_Set, Character_Set) const;
76
77 Library_State(class Mutex_Factory*);
78 ~Library_State();
79 private:
80 Library_State(const Library_State&) {}
81 Library_State& operator=(const Library_State&) { return (*this); }
82
83 class Engine* get_engine_n(u32bit) const;
84
85 class Mutex_Factory* mutex_factory;
86 class Timer* timer;
87 class Config* config_obj;
88 class X509_GlobalState* x509_state_obj;
89
90 std::map<std::string, class Mutex*> locks;
91 std::map<std::string, Allocator*> alloc_factory;
92 mutable Allocator* cached_default_allocator;
93
94 UI* ui;
95 class Charset_Transcoder* transcoder;
96 RandomNumberGenerator* rng;
97 std::vector<Allocator*> allocators;
98 std::vector<EntropySource*> entropy_sources;
99 std::vector<class Engine*> engines;
100 };
101
102/*************************************************
103* Global State *
104*************************************************/
105Library_State& global_state();
106void set_global_state(Library_State*);
107Library_State* swap_global_state(Library_State*);
108
109}
110
111#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status