Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cHashTypeDef.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cHashTypeDef_H
6 #define _INC_cHashTypeDef_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 #include "cHashCode.h"
14 
15 namespace GrayLib
16 {
18  class cHashBase;
19 
21  {
25 
26  public:
28  const size_t m_nHashSize;
29 
30  public:
31  cHashTypeDef(SSL_Hash_TYPE eHashType, const char* pszName, size_t nHashSize) noexcept
32  : cObjectFactory(pszName,typeid(cHashTypeDef))
33  , m_eHashType(eHashType)
34  , m_nHashSize(nHashSize)
35  {
36  }
37  virtual ~cHashTypeDef()
38  {
39  }
40 
41  SSL_Hash_TYPE get_HashType() const noexcept
42  {
44  return this->m_eHashType;
45  }
46  SSL_Hash_TYPE get_HashCode() const noexcept
47  {
49  return this->m_eHashType;
50  }
51 
52  size_t get_HashSize() const noexcept
53  {
55  return this->m_nHashSize;
56  }
57 
58  // Allocate a new context
59  virtual cHashBase* AllocHash(void) const = 0;
60 
61  virtual CObject* CreateObject(void) const override;
62 
63  // Generic digest function
64  virtual size_t ComputeHash(BYTE* pOutput, const BYTE* pInput, size_t nInputSize) const = 0;
65 
67  };
68 
69  class GRAYLIB_LINK cHashTypeMgr : public cSingleton<cHashTypeMgr>
70  {
73  private:
75  public:
76  cHashTypeMgr();
77  void AddHashType(const cHashTypeDef* pDef)
78  {
79  m_a.Add(pDef);
80  }
81  const cHashTypeDef* GetHashType(SSL_Hash_TYPE e) const noexcept
82  {
83  return m_a.FindArgForKey(e);
84  }
85  const cHashTypeDef* GetHashTypeBySize(size_t nSizeMin) const;
86 
87  void InitAllHashTypes();
88  };
89 }
90 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Definition: cHashBase.h:20
Definition: cHashTypeDef.h:21
size_t get_HashSize() const noexcept
Definition: cHashTypeDef.h:52
const SSL_Hash_TYPE m_eHashType
Digest identifier from SSL_Hash_TYPE.
Definition: cHashTypeDef.h:27
UNITTEST_FRIEND(cHashTypeDef)
cHashTypeDef(SSL_Hash_TYPE eHashType, const char *pszName, size_t nHashSize) noexcept
Definition: cHashTypeDef.h:31
virtual ~cHashTypeDef()
Definition: cHashTypeDef.h:37
virtual size_t ComputeHash(BYTE *pOutput, const BYTE *pInput, size_t nInputSize) const =0
SSL_Hash_TYPE get_HashCode() const noexcept
Definition: cHashTypeDef.h:46
virtual cHashBase * AllocHash(void) const =0
SSL_Hash_TYPE get_HashType() const noexcept
Definition: cHashTypeDef.h:41
const size_t m_nHashSize
size_t // Output length of the digest function. (bytes)
Definition: cHashTypeDef.h:28
Definition: cHashTypeDef.h:70
const cHashTypeDef * GetHashType(SSL_Hash_TYPE e) const noexcept
Definition: cHashTypeDef.h:81
void AddHashType(const cHashTypeDef *pDef)
Definition: cHashTypeDef.h:77
Definition: cObject.h:67
TYPE_PTR FindArgForKey(TYPE_KEY key1) const noexcept
Definition: cArraySort.h:455
Definition: cArraySort.h:613
ITERATE_t Add(TYPE_ARG pNew)
Definition: cArraySort.h:186
Definition: cObjectFactory.h:17
Definition: cSingleton.h:127
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
SSL_Hash_TYPE
Definition: cHashCode.h:23