summaryrefslogtreecommitdiff
path: root/lib/parameters.h
blob: df7994b25d7b5d70e109d4e41e6b4c1a0fa0c86b (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
/*
 * parameters.h
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef __PARAMETERS_H
#define __PARAMETERS_H

#include "db.h"

//***************************************************************************
// Parameters
//***************************************************************************

class cParameters
{
   public:

      enum Type
      {
         ptNum,
         ptTime,     // unix time
         ptBool,
         ptAscii
      };

      struct Parameter
      {
         const char* owner;
         const char* name;
         int type;
         const char* def;
         const char* regexp;
         int readonly;
         int visible;
      };

      cParameters();

      int initDb(cDbConnection* connection);
      int exitDb();

      int getParameter(const char* owner, const char* name, char* value = 0);
      int getParameter(const char* owner, const char* name, long int& value);
      int setParameter(const char* owner, const char* name, const char* value);
      int setParameter(const char* owner, const char* name, long int value);

   protected:

      cDbTable* parametersDb;
      cDbStatement* selectParameters;

      static Parameter parameters[];
      static Parameter* getDefinition(const char* owner, const char* name);
};

#endif // __PARAMETERS_H