1 /*=========================================================================
3 Module: $RCSfile: bbtkConfigurationFile.h,v $
5 Date: $Date: 2009/01/27 14:22:56 $
6 Version: $Revision: 1.11 $
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;
85 void GetHelp(int level) const;
87 /// Returns true iff the directory .bbtk has been created on construction
88 inline bool DotBbtkIsNew() { return mDot_bbtk_is_new; }
90 inline const std::string& Get_description() const
91 { return mDescription;}
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_dot_bbtk_path() const
99 { return mDot_bbtk_path;}
100 inline const std::string& Get_bin_path() const
102 inline const std::string& Get_install_path() const
103 { return mInstall_path;}
104 inline const std::string& Get_doc_path() const
107 inline const std::string& Get_root_bbs_path() const
109 inline const std::vector<std::string>& Get_bbs_paths() const
110 { return mBbs_paths;}
111 inline const std::vector<std::string>& Get_package_paths() const
112 { return mPackage_paths;}
113 inline const std::string& Get_config_xml_full_path() const
114 { return mConfig_xml_full_path;}
115 inline const std::string& Get_default_temp_dir() const
116 { return mTemp_path;}
118 bool AddPackagePathsAndWrite( const std::string& package_root_path );
123 void Read(const std::string& fileName);
124 void CreateConfigXML( char *rootDirectory );
125 void InitializeDotBbtkStructure();
128 std::string mDescription;
129 /// Where is the file bbtk_config.xml
130 std::string mConfig_xml_full_path;
132 /// Set automatically :
133 /// The path to the executable (usually bbi)
134 std::string mBin_path;
135 /// The path to the .bbtk user's dir (e.g. /home/username/.bbtk)
136 std::string mDot_bbtk_path;
137 /// The path to the install prefix (=mBinPath+"/..")
138 std::string mInstall_path;
139 /// The path to the doc folder (=mDot_bbtk_path+"/doc")
140 std::string mDoc_path;
141 /// Temp directory for generated data (=mDot_bbtk_path+"/tmp")
142 std::string mTemp_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 path to the bbtk data folder
148 /// Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH
149 /// But can be overriden by value read from bbtk_config.xml
150 std::string mData_path;
152 /// / or \, depending on the OS
153 std::string mFile_separator;
155 /// Read from bbtk_config.xml file
159 std::vector<std::string> mBbs_paths;
161 std::vector<std::string> mPackage_paths;
162 /// If Packages link against extern dlls
163 std::vector<std::string> mExt_dll_paths;
166 /// Set to true by InitializeDotBbtkStructure() if .bbtk has been newly
168 bool mDot_bbtk_is_new;