summaryrefslogtreecommitdiff
path: root/parameters.h
blob: 7d45b0b34c3faee54f81bf767b43f7d8921791e4 (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 "lib/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