welding in a virtual unix root for windoze
[feisty_meow.git] / nucleus / library / configuration / application_configuration.h
1 #ifndef APPLICATION_CONFIGURATION_GROUP
2 #define APPLICATION_CONFIGURATION_GROUP
3
4 /**
5  * Name: path configuration definitions
6  * Author: Chris Koeritz
7  ****
8  * Copyright (c) 2000-$now By Author.  This program is free software; you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation; either version 2 of
11  * the License or (at your option) any later version.  This is online at:
12  *     http://www.fsf.org/copyleft/gpl.html
13  * Please send any updates to: fred@gruntose.com
14  */
15
16 #include <basis/astring.h>
17 #include <basis/definitions.h>
18 #include <structures/version_record.h>
19
20 namespace configuration {
21
22 //! Defines installation-specific locations in the file system.
23
24 class application_configuration : public virtual basis::root_object
25 {
26 public:
27   virtual ~application_configuration() {}
28
29   // these methods are mainly about the application itself.
30
31   static basis::astring application_name();
32     //!< returns the full name of the current application.
33
34   static basis::astring application_directory();
35     //!< returns the directory name where this application is running from.
36
37   static basis::un_int process_id();
38     //!< returns the process id for this task, if that's relevant on the OS.
39
40   // these interface with the operating system.
41
42   static structures::version get_OS_version();
43     //!< returns the operating system's version information.
44     /*!< for linux, this has: major/minor/release/revision as components.
45     for ms-windows, this has: major/minor/platform_ID/build_number. */
46
47   static basis::astring current_directory();
48     //!< returns the current directory as reported by the operating system.
49
50   // the following are more about the installation than this application...
51
52   static const char *software_product_name();
53     //!< This global function is available to the system at large for branding info.
54
55 //  static basis::astring installation_root();
56     //!< returns the top-level directory of this installation.
57     /*!< returns the folder containing the application directory (usually) as
58     well as the other folders of configuration information and fonts and
59     such needed by this installation. */
60
61   static const char *APPLICATION_CONFIGURATION_FILENAME();
62     //!< the configuration file provides a set of paths needed here.
63     /*!< this file stores paths that the low-level libraries need for
64     proper operation.  this is just the base filename; the fully qualified
65     path to the path configuration file is provided below. */
66
67   static basis::astring application_configuration_file();
68     //!< the fully specified path to the main path configuration file.
69     /*!< the location of this file is determined by the directory where this
70     executable is running.  this is the only configuration file that should
71     reside there, given the itchy vista compliance needs. */
72
73 ////  static basis::astring core_bin_directory();
74     //!< retrieves the core binary directory location from paths.ini.
75
76   static basis::astring get_logging_directory();
77     //!< returns the folder where the log files for the feisty meow system are stored.
78     /*!< any log files should be written to this folder by the rest of the codebase,
79     unless there are special purposes for those log files.  but logs from general
80     operation of feisty meow should be written in this directory. */
81
82   static basis::astring get_virtual_unix_root();
83     //!< returns the path to the unix root, which may be simulated.
84     /*!< on unix, this will just return '/'.  on win32 with cygwin installed,
85     this will return the cygwin path for '/' that was detected at build time.
86     this is often "c:/cygwin", which we use as a default if the path isn't
87     detected properly. */ 
88
89   // the following are key names within the main configuration file.
90   // not generally for external use.
91
92   static const basis::astring &GLOBAL_SECTION_NAME();
93     //!< the root section name for our configuration items in the main ini file.
94     /*!< within the configuration file, there is a section named as above.
95     this section should only be used to define path configuration entries that
96     affect the general operation of the system.  entries that are specific
97     to particular programs or subsystems should be contained in their own
98     section. */
99
100 ///  static const basis::astring &LOCAL_FOLDER_NAME();
101     //!< entry name in the config file that points at the installation root.
102     /*!< this is where all files for this product are stored on "this" machine. */
103
104   static const basis::astring &LOGGING_FOLDER_NAME();
105     //!< the tag used for finding our logging path in the paths config file.
106
107   static const basis::astring &WINDOZE_VIRTUAL_ROOT_NAME();
108     //!< the tag used for looking up the virtual windows path in the paths config file.
109
110   static const basis::astring &DEFAULT_VIRTUAL_UNIX_ROOT();
111     //!< default value if we don't find our setting for virtual root.
112     /*!< this is bound to fail on many occasions if it's actually used on
113     windoze for the default, but if we don't have good information ready,
114     we can't just intuit the virtual unix root; we are not kreskin.  the
115     virtual unix environment could be MSYS, Cygwin, or others.  Currently,
116     if Cygwin is used during the build process, then the default should
117     never be needed.  support for other systems will be added as time
118     permits and users clamor for them. */
119
120   // helper methods.
121
122   static basis::astring read_item(const basis::astring &key_name);
123     //!< returns the entry listed under the "key_name".
124     /*!< if the "key_name" is valid for the root configuration file, then this
125     should always return an appropriate value.  a failure is denoted by return
126     of an empty string. */
127
128   static basis::astring make_logfile_name(const basis::astring &base_name);
129     //!< generates an installation appropriate log file name from "base_name".
130     /*!< creates and returns a full path name for a log file with the
131     "base_name" specified, using the LOGGING_FOLDER_NAME() entry as the
132     directory name.  if the logging directory does not exist, it is created if
133     that is possible.  the returned name is suitable for logging mechanisms that
134     need a filename.  an empty string is returned on failure to create the
135     directory. */
136
137 #if defined(__UNIX__) || defined(__GNU_WINDOWS__)
138   #ifdef __APPLE__
139     static basis::astring get_cmdline_for_apple();
140   #endif
141   static basis::astring get_cmdline_from_proc();
142     //!< retrieves the command line from the /proc hierarchy on linux.
143   static basis::astring query_for_process_info();
144     //!< seeks out process info for a particular process.
145 #endif
146 };
147
148 } // namespace.
149
150 #endif
151