47e81a6d7c6e0ec961b8acfe389b785f132f0348
[AXE.git] / src / configuration.h
1 /**************************************************************************
2 **  (c) Copyright 2002, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
6 **      FILE NAME      : configuration.h
7 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
8 **      VERSION NUMBER : $Revision: 1.2 $
9 **
10 **  DESCRIPTION      : Definition of configuration class 
11 **
12 **  EXPORTED OBJECTS : class configuration
13 **  LOCAL    OBJECTS : 
14 **  MODULES  USED    : String
15 ***************************************************************************
16 **  ADMINISTRATIVE INFORMATION *
17 ********************************
18 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
19 **      CREATION DATE   : Jul 24, 2002
20 **      LAST UPDATE     : 
21 **      MODIFICATIONS   : 
22 **************************************************************************/
23
24 /*****************************
25    $Log: configuration.h,v $
26    Revision 1.2  2002-09-02 06:18:20  arjen
27    Fixed some date and time conversion functions
28
29    Revision 1.1  2002/07/25 08:01:26  arjen
30    First checkin, AXE release 0.2
31
32 *****************************/
33
34 /* static const char *RCSID = "$Id: configuration.h,v 1.2 2002-09-02 06:18:20 arjen Exp $"; */
35
36 #ifndef CONFIGURATION_H
37 #define CONFIGURATION_H
38
39 #include <parser.h>   // usually in /usr/include/gnome-xml, see xml-config
40
41 #include "String.h"
42
43 /*
44 ///////////////////////////////////////////////////////////////////////////
45 //  NAME           : configuration
46 //  BASECLASS      :
47 //  MEMBERS        : 
48 //  OPERATORS      :
49 //  METHODS        : read
50 //                   find_parameter
51 //
52 //  DESCRIPTION    : Handle configurational parameters for the application.
53 //                   Many applications need some permanently stored configurational
54 //                   data. The information is usually stored in two places: A system-
55 //                   wide configuration file and a configuration file per user.
56 //                   The content of the configuration file is in XML format.
57 //                   The configuration base class takes care of finding the configuration
58 //                   files, e.g. in /etc/app.conf or in /usr/local/etc/app.conf, along
59 //                   with the configuration file in the user's home directory.
60 //                   The config files are parsed with the gnome XML parser and a
61 //                   framework is provided to find configurational items.
62 //
63 //  RELATIONS      : 
64 //  SEE ALSO       :
65 //  LAST MODIFIED  : Jul 24, 2002
66 ///////////////////////////////////////////////////////////////////////////
67 */
68
69 class configuration
70 {
71
72    xmlDocPtr     system;   // The system-wide config tree
73    xmlDocPtr     user;     // User-specific config tree
74    String        app_name; // Name of the application and XML root element
75
76    xmlNodePtr    xmlFindTag(xmlNodePtr, const String);
77
78 public:
79
80    configuration()
81    {
82       system  = NULL;
83       user    = NULL;
84       app_name = "AXE";
85    }
86
87    //  Find the config files and parse the XML
88
89    bool read(const String name);
90
91    //  Return the value of a config parameter
92
93    String find_parameter(const String section, const String parameter);
94
95 };
96
97 #endif // CONFIGURATION_H