summaryrefslogtreecommitdiff
path: root/ndb/src/common/mgmcommon/ConfigInfo.hpp
blob: 43041a3f772fe7eb2ee53a38296d1309b1debee2 (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
112
113
114
115
116
117
118
119
120
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef ConfigInfo_H
#define ConfigInfo_H

#include <kernel_types.h>
#include <Properties.hpp>
#include <ndb_limits.h>
#include <NdbOut.hpp>
#include "InitConfigFileParser.hpp"

/**
 * A MANDATORY parameters must be specified in the config file
 * An UNDEFINED parameter may or may not be specified in the config file
 */
static const Uint32 MANDATORY = ~0;     // Default value for mandatory params.
static const Uint32 UNDEFINED = (~0)-1; // Default value for undefined params.

/**
 * @class  ConfigInfo
 * @brief  Metainformation about ALL cluster configuration parameters 
 *
 * Use the getters to find out metainformation about parameters.
 */
class ConfigInfo {
public:
  enum Type        {BOOL, INT, STRING};
  enum Status      {USED,            ///< Active
		    DEPRICATED,      ///< Can be, but should not be used anymore
		    NOTIMPLEMENTED,  ///< Can not be used currently. Is ignored.
                    INTERNAL         ///< Not configurable by the user
  };

  /**
   *   Entry for one configuration parameter
   */
  struct ParamInfo {
    const char*    _fname;   
    const char*    _pname;
    const char*    _section;
    const char*    _description;
    Status         _status;
    bool           _updateable;    
    Type           _type;          
    Uint32         _default;
    Uint32         _min;
    Uint32         _max;
  };

  /**
   * Entry for one section rule
   */
  struct SectionRule {
    const char * m_section;
    bool (* m_sectionRule)(struct InitConfigFileParser::Context &, 
			   const char * m_ruleData);
    const char * m_ruleData;
  };
  
  ConfigInfo();

  /**
   *   Checks if the suggested value is valid for the suggested parameter
   *   (i.e. if it is >= than min and <= than max).
   *
   *   @param  section  Init Config file section name
   *   @param  fname    Name of parameter
   *   @param  value    Value to check
   *   @return true if parameter value is valid.
   * 
   *   @note Result is not defined if section/name are wrong!
   */
  bool verify(const Properties* section, const char* fname, Uint32 value) const;
  bool isSection(const char*) const;

  const char*  getPName(const Properties * section, const char* fname) const;
  const char*  getDescription(const Properties * section, const char* fname) const;
  Type         getType(const Properties * section, const char* fname) const;
  Status       getStatus(const Properties* section, const char* fname) const;
  Uint32       getMin(const Properties * section, const char* fname) const;
  Uint32       getMax(const Properties * section, const char* fname) const;
  Uint32       getDefault(const Properties * section, const char* fname) const;
  
  const Properties * getInfo(const char * section) const;
  const Properties * getDefaults(const char * section) const;
  
  void print() const;
  void print(const char* section) const;
  void print(const Properties * section, const char* parameter) const;

private:
  Properties               m_info;
  Properties               m_systemDefaults;

  static const ParamInfo   m_ParamInfo[];
  static const int         m_NoOfParams;
  
  static const char*       m_sectionNames[];
  static const int         m_noOfSectionNames;

public:
  static const SectionRule m_SectionRules[];
  static const int         m_NoOfRules;
};

#endif // ConfigInfo_H