monotone

monotone Mtn Source Tree

Root/botan/libstate.h

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

Archive Download this file

Branches

Tags

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