summaryrefslogtreecommitdiffstats
path: root/src/cipherssingleton.h
blob: 6286652400ed2df78fd088dba9d3609eb7c804a9 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef CIPHERSSINGLETON_H
#define CIPHERSSINGLETON_H

#include <QVector>
#include <QString>


/**
* \class CiphersSingleton
* \brief Singleton-Class to assign a short descriptive string and a number for all Ciphers.
*
* This Class, basically, provides an Array containing QStrings, each of which is used as
* description for an available cipher.
* The index of each QString is also used to describe the cipher.
* This is needed since sometimes ciphers need to be referred to by strings, and other times
* by integers.
* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
* \version 0.1
* \date 28.02.2013
*/
class CiphersSingleton
{
public: //Methods
    /**
    * \brief Method to fetch the Singleton-Instance of this class.
    *
    * The Assignments of QStrings to Integers (and vice versa) made in this Class is needed
    * throughout the entire program. This Method, therefore, returns a Singleton-instance of
    * this Class.
    * \returns A reference to the Singleton-instance of this Class
    */
    static CiphersSingleton & getInstance()
                                        { return instance; }



    /**
    * \brief Method to fetch a QString corresponding with the given Integer.
    *
    * For the given value, looks up what QString corresponds to it and returns that.
    * \param int value integer representing an algorithm
    * \returns QString corresponding to the given integer.
    */
    QString textFromValue ( int value );


    /**
    * \brief Method to fetch an Integer corresponding with the given QString.
    *
    * For the given QString, looks up what Integer corresponds to it and returns that.
    * \param QString& text QString representing an algorithm
    * \returns Integer corresponding to the given QString.
    */
    int valueFromText ( const QString& text );


    /**
    * \brief Method to fetch the number of supported symmetric Ciphers.
    *
    * Returns the number of supported symmetric Ciphers.
    * \returns The number of supported symmetric Ciphers.
    */
    int symmetricCiphersCount()
                                    { return m_symmetricCipherDescriptions.size(); }


    /**
    * \brief Method to fetch the number of supported asymmetric Ciphers.
    *
    * Returns the number of supported asymmetric Ciphers.
    * \returns The number of supported asymmetric Ciphers.
    */
    int asymmetricCiphersCount()
                                    { return m_asymmetricCipherDescriptions.size(); }


private: //Methods
    /**
    * \brief Class Constructor.
    *
    * Class Constructor. Initializes the Array containing the Cipher-Strings.
    */
    CiphersSingleton();



private: //Attributes
    /**
    * \brief Singleton-instance of this class.
    */
    static CiphersSingleton instance;



    /**
    * \brief QVector of QStrings assigning an integer to a String for each symmetric Cipher (and vice versa).
    *
    * \attention These Strings are used throughout the entire program to reference ciphers!
    */
    QVector<QString> m_symmetricCipherDescriptions;


    /**
    * \brief QVector of QStrings assigning an integer to a String for each asymmetric Cipher (and vice versa).
    *
    * \attention These Strings are used throughout the entire program to reference ciphers!
    */
    QVector<QString> m_asymmetricCipherDescriptions;
};

#endif // CIPHERSSINGLETON_H