9c59c8709b395a3b950231718fc69e5c10e1db3a
[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.3 $
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   : Nov 02, 2002
20 **      LAST UPDATE     : 
21 **      MODIFICATIONS   : 
22 **************************************************************************/
23
24 /*****************************
25    $Log: configuration.h,v $
26    Revision 1.3  2002-11-02 14:35:15  arjen
27    Uses the XML2 library
28    BugFix: segfault when finding a parameters that is not in the user-sepcific
29    config tree.
30
31    Revision 1.2  2002/09/02 06:18:20  arjen
32    Fixed some date and time conversion functions
33
34    Revision 1.1  2002/07/25 08:01:26  arjen
35    First checkin, AXE release 0.2
36
37 *****************************/
38
39 /* static const char *RCSID = "$Id: configuration.h,v 1.3 2002-11-02 14:35:15 arjen Exp $"; */
40
41 #ifndef CONFIGURATION_H
42 #define CONFIGURATION_H
43
44 #include <libxml/parser.h>   // usually in /usr/include/libxml2, see xml2-config
45
46 #include "String.h"
47
48 /*
49 ///////////////////////////////////////////////////////////////////////////
50 //  NAME           : configuration
51 //  BASECLASS      :
52 //  MEMBERS        : 
53 //  OPERATORS      :
54 //  METHODS        : read
55 //                   find_parameter
56 //
57 //  DESCRIPTION    : Handle configurational parameters for the application.
58 //                   Many applications need some permanently stored configurational
59 //                   data. The information is usually stored in two places: A system-
60 //                   wide configuration file and a configuration file per user.
61 //                   The content of the configuration file is in XML format.
62 //                   The configuration base class takes care of finding the configuration
63 //                   files, e.g. in /etc/app.conf or in /usr/local/etc/app.conf, along
64 //                   with the configuration file in the user's home directory.
65 //                   The config files are parsed with the gnome XML parser and a
66 //                   framework is provided to find configurational items.
67 //
68 //  RELATIONS      : 
69 //  SEE ALSO       :
70 //  LAST MODIFIED  : Jul 24, 2002
71 ///////////////////////////////////////////////////////////////////////////
72 */
73
74 class configuration
75 {
76
77    xmlDocPtr     system;   // The system-wide config tree
78    xmlDocPtr     user;     // User-specific config tree
79    String        app_name; // Name of the application and XML root element
80
81    xmlNodePtr    xmlFindTag(xmlNodePtr, const String);
82
83 public:
84
85    configuration()
86    {
87       system  = NULL;
88       user    = NULL;
89       app_name = "AXE";
90    }
91
92    //  Find the config files and parse the XML
93
94    bool read(const String name);
95
96    //  Return the value of a config parameter
97
98    String find_parameter(const String section, const String parameter);
99
100 };
101
102 #endif // CONFIGURATION_H