summaryrefslogtreecommitdiff
path: root/htk_io/src/KaldiLib/UserInterface.h
blob: fa189e74a7fde6ac950441839593318dbb20cac7 (plain) (blame)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#ifndef TNet_UserInterface_h
#define TNet_UserInterface_h

#include <iostream>
#include <cstdlib>
#include <string>
#include <map>

namespace TNet 
{
  /** **************************************************************************
   ** **************************************************************************
   */
  class UserInterface 
  {
  public:
    struct ValueRecord {
      std::string   mValue;
      char          mOption;
      bool          mRead;
    };


    void InsertConfigParam(
      const char *param_name,
      const char *value,
      int optionChar);
    

    void 
    ReadConfig(const char *pFileName);


    void 
    CheckCommandLineParamUse();
    

    /** 
     * @brief Retreives the content of a parameter
     * @param pParamName Name of the parameter to look for
     * @return Returns the pointer to the ValueRecord structure if success,
     *         otherwise return NULL
     *
     *  We iteratively try to find the param name in the map. If an attempt 
     *  fails, we strip off all characters until the first occurance of ':' 
     *  and we search again
     */
    ValueRecord*
    GetParam(const char* pParamName);


    /** 
     * @brief Returns the parameter's value as string
     * 
     * @param param_name Parameter name
     * @param default_value Value, which is returned in case the parameter 
     * was not found
     * 
     * @return Pointer to the begining of the string if success, default_value
     * otherwise
     */
    const char* 
    GetStr( const char *param_name, const char *default_value);
    

    /** 
     * @brief Returns the parameter's value as int
     * 
     * @param param_name Parameter name
     * @param default_value Value, which is returned in case the parameter 
     * was not found
     * 
     * @return Returns the integer value if success, default_value
     * otherwise
     */
    long 
    GetInt( const char *param_name, long default_value);
    

    /** 
     * @brief Returns the parameter's value as float
     * 
     * @param param_name Parameter name
     * @param default_value Value, which is returned in case the parameter 
     * was not found
     * 
     * @return Returns the float value if success, default_value
     * otherwise
     */
    float 
    GetFlt( const char *param_name, float default_value);
    

    /** 
     * @brief Returns the parameter's value as bool
     * 
     * @param param_name Parameter name
     * @param default_value Value, which is returned in case the parameter 
     * was not found
     * 
     * @return Returns the bool value if success, default_value
     * otherwise
     *
     * Note that true is returned if the value is 'TRUE' or 'T', false is
     * returned if the value is 'FALSE' or 'F'. Otherwise exception is thrown
     */
    bool 
    GetBool(const char *param_name, bool default_value);
    

    /** 
     * @brief Returns the parameter's value as enum integer
     * 
     * @param param_name Parameter name
     * @param default_value Value, which is returned in case the parameter 
     * was not found
     * 
     * @return Returns the index value if success, default_value
     * otherwise
     *
     * Variable arguments specify the possible values of this parameter. If the
     * value does not match any of these, exception is thrown.
     */
    int 
    GetEnum( const char *param_name, int default_value, ...);
    

    int GetFeatureParams(
        int *derivOrder,
        int **derivWinLens,
        int *startFrmExt,
        int *endFrmExt,
        char **CMNPath,
        char **CMNFile,
        const char **CMNMask,
        char **CVNPath,
        char **CVNFile,
        const char **CVNMask,
        const char **CVGFile,
        const char *toolName,
        int pseudoModeule);
    

    int ParseOptions(
        int             argc,
        char*           argv[],
        const char*     optionMapping,
        const char*     toolName);


    /** 
     * @brief Send the defined paramaters to a stream
     * 
     * @param rStream stream to use
     */
    void
    PrintConfig(std::ostream& rStream);

  public:
    typedef std::map<std::string, ValueRecord> MapType;
    MapType             mMap;
  };
}

#endif