Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
HashAlgorithmServices.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* HashAlgorithmServices.h (C) 2000-2023 */
9/* */
10/* Hash calculation services. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/IOException.h"
15#include "arcane/utils/Array.h"
16#include "arcane/utils/TraceInfo.h"
17#include "arcane/utils/SHA3HashAlgorithm.h"
18#include "arcane/utils/SHA1HashAlgorithm.h"
19#include "arcane/utils/MD5HashAlgorithm.h"
20
21#include "arcane/core/AbstractService.h"
22#include "arcane/core/ServiceBuildInfo.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34template <typename HashAlgoImplementation>
35class GenericHashAlgorithmService
36: public AbstractService
37, public HashAlgoImplementation
38{
39 public:
40
41 explicit GenericHashAlgorithmService(const ServiceBuildInfo& sbi)
42 : AbstractService(sbi)
43 , m_name(sbi.serviceInfo()->localName())
44 {
45 }
46
47 public:
48
49 String name() const override { return m_name; }
50
51 private:
52
53 String m_name;
54};
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59using SHA3_256HashAlgorithmService = GenericHashAlgorithmService<SHA3_256HashAlgorithm>;
60using SHA3_224HashAlgorithmService = GenericHashAlgorithmService<SHA3_224HashAlgorithm>;
61using SHA3_384HashAlgorithmService = GenericHashAlgorithmService<SHA3_384HashAlgorithm>;
62using SHA3_512HashAlgorithmService = GenericHashAlgorithmService<SHA3_512HashAlgorithm>;
63using MD5HashAlgorithmService = GenericHashAlgorithmService<MD5HashAlgorithm>;
64using SHA1HashAlgorithmService = GenericHashAlgorithmService<SHA1HashAlgorithm>;
65
66ARCANE_REGISTER_SERVICE(SHA3_256HashAlgorithmService,
67 ServiceProperty("SHA3_256HashAlgorithm", ST_Application | ST_CaseOption),
69
70ARCANE_REGISTER_SERVICE(SHA3_224HashAlgorithmService,
71 ServiceProperty("SHA3_224HashAlgorithm", ST_Application | ST_CaseOption),
73
74ARCANE_REGISTER_SERVICE(SHA3_384HashAlgorithmService,
75 ServiceProperty("SHA3_384HashAlgorithm", ST_Application | ST_CaseOption),
77
78ARCANE_REGISTER_SERVICE(SHA3_512HashAlgorithmService,
79 ServiceProperty("SHA3_512HashAlgorithm", ST_Application | ST_CaseOption),
81
82ARCANE_REGISTER_SERVICE(MD5HashAlgorithmService,
83 ServiceProperty("MD5HashAlgorithm", ST_Application | ST_CaseOption),
85
86ARCANE_REGISTER_SERVICE(SHA1HashAlgorithmService,
87 ServiceProperty("SHA1HashAlgorithm", ST_Application | ST_CaseOption),
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93} // End namespace Arcane
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
This file contains the various service factories and macros for registering services.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
Interface of a hashing algorithm.
virtual String localName() const =0
Local part of the service name.
Structure containing the information to create a service.
IServiceInfo * serviceInfo() const
Access to the associated IServiceInfo.
Service creation properties.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ ST_Application
The service is used at the application level.
@ ST_CaseOption
The service is used at the dataset level.