aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate/algo_factory.h
blob: 5a00f3b5567ec730a61e3ef6b3d413982b977672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Algorithm Factory
* (C) 2008 Jack Lloyd
*/

#ifndef BOTAN_ALGORITHM_FACTORY_H__
#define BOTAN_ALGORITHM_FACTORY_H__

#include <botan/mutex.h>
#include <botan/hash.h>
#include <string>
#include <vector>

namespace Botan {

/**
* Algorithm Factory
*/
class BOTAN_DLL Algorithm_Factory
   {
   public:
      Algorithm_Factory(Mutex* m) : mutex(m) {}
      ~Algorithm_Factory();

      const HashFunction* prototype_hash_function(const std::string& algo_spec);

      void add_engine(class Engine*);

      class BOTAN_DLL Engine_Iterator
         {
         public:
            class Engine* next() { return af.get_engine_n(n++); }
            Engine_Iterator(const Algorithm_Factory& a) : af(a) { n = 0; }
         private:
            const Algorithm_Factory& af;
            u32bit n;
         };
      friend class Engine_Iterator;

   private:
      class Engine* get_engine_n(u32bit) const;

      Mutex* mutex;
      std::vector<class Engine*> engines;
   };

}

#endif