1 /*=========================================================================
3 Module: $RCSfile: bbtkConfigurationFile.h,v $
5 Date: $Date: 2008/10/17 08:18:13 $
6 Version: $Revision: 1.10 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 *\brief Class bbtk::ConfigurationFile
36 *\class bbtk::ConfigurationFile
41 #ifndef __bbtkConfigurationFile_h__
42 #define __bbtkConfigurationFile_h__
44 #include "bbtkSystem.h"
49 #define _CRT_SECURE_NO_DEPRECATE
62 //==========================================================================
63 class BBTK_EXPORT ConfigurationException
66 ConfigurationException(const std::string& message) : mMessage(message) {}
70 //==========================================================================
72 //==========================================================================
73 class BBTK_EXPORT ConfigurationFile
77 static ConfigurationFile& GetInstance()
79 static ConfigurationFile f;
90 void GetHelp(int level) const;
92 inline const std::string& Get_description() const
93 { return mDescription;}
94 // inline const std::string& Get_url() const
96 inline const std::string& Get_data_path() const
98 inline const std::string& Get_file_separator() const
99 { return mFile_separator;}
101 inline const std::string& Get_bin_path() const
103 inline const std::string& Get_install_path() const
104 { return mInstall_path;}
105 inline const std::string& Get_doc_path() const
107 inline const std::string& Get_rsc_path() const
110 inline const std::string& Get_root_bbs_path() const
112 inline const std::vector<std::string>& Get_bbs_paths() const
113 { return mBbs_paths;}
114 inline const std::vector<std::string>& Get_package_paths() const
115 { return mPackage_paths;}
116 inline const std::string& Get_config_xml_full_path() const
117 { return mConfig_xml_full_path;}
118 inline const std::string& Get_default_temp_dir() const
119 { return mDefault_temp_dir;}
121 bool AddPackagePathsAndWrite( const std::string& package_root_path );
124 void Read(const std::string& fileName);
125 std::string GetExecutablePath();
126 void CreateConfigXML( char *rootDirectory );
130 std::string mDescription;
131 /// Where is the file bbtk_config.xml
132 std::string mConfig_xml_full_path;
134 /// Set automatically :
135 /// The path to the executable (usually bbi)
136 std::string mBin_path;
137 /// The path to the install prefix (=mBinPath+"/..")
138 std::string mInstall_path;
139 /// The relative path to the doc folder (=BBTK_DOC_REL_PATH)
140 std::string mDoc_rel_path;
141 /// The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
142 std::string mDoc_path;
143 /// The relative path to the doc folder (=BBTK_BBS_REL_PATH)
144 std::string mBbs_rel_path;
145 /// The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
146 std::string mBbs_path;
147 /// The relative path to the rsc folder (=BBTK_RSC_REL_PATH)
148 std::string mRsc_rel_path;
149 /// The path to the rsc folder (=mInstall_path+"/"+mRsc_rel_path)
150 std::string mRsc_path;
151 /// The path to the bbtk data folder
152 /// Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH
153 /// But can be overriden by value read from bbtk_config.xml
154 std::string mData_path;
156 /// / or \, depending on the OS
157 std::string mFile_separator;
159 /// Read from bbtk_config.xml file
163 std::vector<std::string> mBbs_paths;
165 std::vector<std::string> mPackage_paths;
166 /// If Packages link against extern dlls
167 std::vector<std::string> mExt_dll_paths;
168 /// Temp directory for generated data
169 std::string mDefault_temp_dir;