2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkConfigurationFile.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.13 $
34 =========================================================================*/
40 *\brief Class bbtk::ConfigurationFile
43 *\class bbtk::ConfigurationFile
48 #ifndef __bbtkConfigurationFile_h__
49 #define __bbtkConfigurationFile_h__
51 #include "bbtkSystem.h"
56 #if __VISUALC__ < 1400
57 #define _CRT_SECURE_NO_DEPRECATE
71 //==========================================================================
72 class BBTK_EXPORT ConfigurationException
75 ConfigurationException(const std::string& message) : mMessage(message) {}
79 //==========================================================================
81 //==========================================================================
82 class BBTK_EXPORT ConfigurationFile
86 static ConfigurationFile& GetInstance()
88 static ConfigurationFile f;
94 void GetHelp(int level) const;
96 /// Returns true iff the directory .bbtk has been created on construction
97 inline bool DotBbtkIsNew() { return mDot_bbtk_is_new; }
99 inline const std::string& Get_description() const
100 { return mDescription;}
102 inline const std::string& Get_data_path() const
103 { return mData_path;}
104 inline const std::string& Get_file_separator() const
105 { return mFile_separator;}
107 inline const std::string& Get_dot_bbtk_path() const
108 { return mDot_bbtk_path;}
109 inline const std::string& Get_bin_path() const
111 inline const std::string& Get_install_path() const
112 { return mInstall_path;}
113 inline const std::string& Get_doc_path() const
116 inline const std::string& Get_root_bbs_path() const
118 inline const std::vector<std::string>& Get_bbs_paths() const
119 { return mBbs_paths;}
120 inline const std::vector<std::string>& Get_package_paths() const
121 { return mPackage_paths;}
122 inline const std::string& Get_config_xml_full_path() const
123 { return mConfig_xml_full_path;}
124 inline const std::string& Get_default_temp_dir() const
125 { return mTemp_path;}
127 bool AddPackagePathsAndWrite( const std::string& package_root_path );
132 void Read(const std::string& fileName);
133 void CreateConfigXML( char *rootDirectory );
134 void InitializeDotBbtkStructure();
137 std::string mDescription;
138 /// Where is the file bbtk_config.xml
139 std::string mConfig_xml_full_path;
141 /// Set automatically :
142 /// The path to the executable (usually bbi)
143 std::string mBin_path;
144 /// The path to the .bbtk user's dir (e.g. /home/username/.bbtk)
145 std::string mDot_bbtk_path;
146 /// The path to the install prefix (=mBinPath+"/..")
147 std::string mInstall_path;
148 /// The path to the doc folder (=mDot_bbtk_path+"/doc")
149 std::string mDoc_path;
150 /// Temp directory for generated data (=mDot_bbtk_path+"/tmp")
151 std::string mTemp_path;
152 /// The relative path to the doc folder (=BBTK_BBS_REL_PATH)
153 std::string mBbs_rel_path;
154 /// The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
155 std::string mBbs_path;
156 /// The path to the bbtk data folder
157 /// Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH
158 /// But can be overriden by value read from bbtk_config.xml
159 std::string mData_path;
161 /// / or \, depending on the OS
162 std::string mFile_separator;
164 /// Read from bbtk_config.xml file
168 std::vector<std::string> mBbs_paths;
170 std::vector<std::string> mPackage_paths;
171 /// If Packages link against extern dlls
172 std::vector<std::string> mExt_dll_paths;
175 /// Set to true by InitializeDotBbtkStructure() if .bbtk has been newly
177 bool mDot_bbtk_is_new;