1 /*=========================================================================
4 Module: $RCSfile: bbtkConfigurationFile.h,v $
6 Date: $Date: 2008/03/10 06:24:12 $
7 Version: $Revision: 1.6 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See doc/license.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 *\brief Class bbtk::ConfigurationFile
23 *\class bbtk::ConfigurationFile
28 #ifndef __bbtkConfigurationFile_h__
29 #define __bbtkConfigurationFile_h__
31 #include "bbtkSystem.h"
36 #define _CRT_SECURE_NO_DEPRECATE
48 #define VALID_FILE_SEPARATOR "\\"
49 #define INVALID_FILE_SEPARATOR "/"
51 #define INVALID_FILE_SEPARATOR "\\"
52 #define VALID_FILE_SEPARATOR "/"
59 //==========================================================================
60 class BBTK_EXPORT ConfigurationException
63 ConfigurationException(const std::string& message) : mMessage(message) {}
67 //==========================================================================
69 //==========================================================================
70 class BBTK_EXPORT ConfigurationFile
74 static ConfigurationFile const &GetInstance()
76 static ConfigurationFile f;
87 void GetHelp(int level) const;
89 inline const std::string& Get_description() const
90 { return mDescription;}
91 // inline const std::string& Get_url() const
93 inline const std::string& Get_data_path() const
95 inline const std::string& Get_file_separator() const
96 { return mFile_separator;}
98 inline const std::string& Get_bin_path() const
100 inline const std::string& Get_install_path() const
101 { return mInstall_path;}
102 inline const std::string& Get_doc_path() const
104 inline const std::string& Get_rsc_path() const
107 inline const std::vector<std::string>& Get_bbs_paths() const
108 { return mBbs_paths;}
109 inline const std::vector<std::string>& Get_package_paths() const
110 { return mPackage_paths;}
111 inline const std::string& Get_config_xml_full_path() const
112 { return mConfig_xml_full_path;}
113 inline const std::string& Get_default_temp_dir() const
114 { return mDefault_temp_dir;}
117 void Read(const std::string& fileName);
118 std::string GetExecutablePath();
119 void CreateConfigXML( char *rootDirectory );
123 std::string mDescription;
124 /// Where is the file bbtk_config.xml
125 std::string mConfig_xml_full_path;
127 /// Set automatically :
128 /// The path to the executable (usually bbi)
129 std::string mBin_path;
130 /// The path to the install prefix (=mBinPath+"/..")
131 std::string mInstall_path;
132 /// The relative path to the doc folder (=BBTK_DOC_REL_PATH)
133 std::string mDoc_rel_path;
134 /// The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
135 std::string mDoc_path;
136 /// The relative path to the doc folder (=BBTK_BBS_REL_PATH)
137 std::string mBbs_rel_path;
138 /// The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
139 std::string mBbs_path;
140 /// The relative path to the rsc folder (=BBTK_RSC_REL_PATH)
141 std::string mRsc_rel_path;
142 /// The path to the rsc folder (=mInstall_path+"/"+mRsc_rel_path)
143 std::string mRsc_path;
144 /// The path to the bbtk data folder
145 /// Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH
146 /// But can be overriden by value read from bbtk_config.xml
147 std::string mData_path;
149 /// / or \, depending on the OS
150 std::string mFile_separator;
152 /// Read from bbtk_config.xml file
156 std::vector<std::string> mBbs_paths;
158 std::vector<std::string> mPackage_paths;
159 /// If Packages link against extern dlls
160 std::vector<std::string> mExt_dll_paths;
161 /// Temp directory for generated data
162 std::string mDefault_temp_dir;