36 #ifdef CASToR_USE_CMAKE 48 if (code!=0)
Cerr(
"***** Exit function called. Abort with code " << code <<
"." << endl);
79 cout << std::scientific;
80 cerr << std::setprecision(std::numeric_limits<FLTNB>::digits10+1);
117 if (
m_verbose>=3)
Cout(
"sOutputManager::CheckConfigDir() -> Directory selected from option as '" << a_path <<
"'" << endl);
123 #ifdef CASToR_USE_CMAKE 125 if (tmp_path.empty())
126 #elif defined(CASTOR_USE_MINGW)
131 if (tmp_path.empty())
135 When cross-compiling, you must define the
CASTOR_CONFIG environment variable before that. This compilation error you are seeing is normal!
138 char* tmp_path = getenv(
"CASTOR_CONFIG");
142 Cerr(
"***** sOutputManager::CheckConfigDir() -> No path for CASTOR_CONFIG variable provided !" << endl);
145 if (
m_verbose>=3)
Cout(
"sOutputManager::CheckConfigDir() -> Directory selected from environment variable as '" << ((
string)tmp_path) <<
"'" << endl);
173 if (
m_verbose>=3)
Cout(
"sOutputManager::GetPathToConfigDir ..."<< endl);
175 #if defined(CASToR_USE_CMAKE) 177 if (tmp_path.empty())
178 #elif defined(CASTOR_USE_MINGW)
183 if (tmp_path.empty())
187 When cross-compiling, you must define the
CASTOR_CONFIG environment variable before that. This compilation error you are seeing is normal!
190 char* tmp_path = getenv(
"CASTOR_CONFIG");
194 Cerr(
"***** sOutputManager::CheckConfigDir() -> No path nor CASTOR_CONFIG variable provided ! Try working directory instead." << endl);
198 #if defined(CASToR_USE_CMAKE) || defined(CASTOR_USE_MINGW) 223 #ifdef CASTOR_VERBOSE 224 if (
m_verbose>=4)
Cout(
"+++++ sOutputManager::InitOutputDirectory() -> Enter"<< endl);
228 if (a_pathFout!=
"" && a_pathDout!=
"")
230 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Either a file path (-fout) or a directory path (dout) should be provided. cannot be both provided, make your choice !" << endl);
235 string the_path = a_pathFout;
236 if (a_pathDout!=
"") the_path = a_pathDout;
237 string last_char = the_path.substr(the_path.length()-1);
238 if (last_char==
"." || last_char==
OS_SEP)
240 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Please provide a path not finishing by '.', '"<<
OS_SEP <<
"' character !" << endl);
245 if (
m_verbose>=1)
Cout(
"sOutputManager::InitOutputDirectory() -> Output path is '" << a_pathFout << a_pathDout <<
"'" << endl);
254 size_t last_slash_pos = a_pathFout.find_last_of(
OS_SEP);
256 if (last_slash_pos==string::npos)
265 m_pathName = a_pathFout.substr(0,last_slash_pos+1);
267 m_baseName = a_pathFout.substr(last_slash_pos+1);
275 else if (a_pathDout!=
"")
278 size_t last_slash_pos = a_pathDout.find_last_of(
OS_SEP);
280 if (last_slash_pos==string::npos)
291 m_baseName = a_pathDout.substr(last_slash_pos+1);
299 string instruction =
"mkdir -p " +
m_pathName;
301 int error = system(instruction.c_str());
304 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Failed to create output directory with name '" << m_pathName <<
"' !" << endl);
325 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Failed to create output log file as '" << log_file_name <<
"' ! Are you sure the provided output path exists ?" << endl);
341 if (
m_verbose>=3)
Cout(
"sOutputManager::LogCommandLine() -> Write command line into the log file"<< endl);
348 m_logFile <<
"==================================================================================================" << endl;
349 m_logFile <<
" COMMAND LINE CONTEXT" << endl;
350 m_logFile <<
"==================================================================================================" << endl;
353 for (
int i=0; i<argc; i++)
m_logFile << argv[i] <<
" ";
357 GetCurrentDirectory(MAX_PATH,pwd);
358 m_logFile <<
"Working directory: " << pwd << endl;
360 m_logFile <<
"Working directory: " << getenv(
"PWD") << endl;
362 std::time_t date_of_execution = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
363 m_logFile <<
"Data of execution: " << std::ctime(&date_of_execution);
364 m_logFile <<
"Float numbers precision in bytes (for matrices and some computations): " <<
sizeof(
FLTNB) << endl;
365 m_logFile <<
"Float numbers precision in bytes (for sensitive computations that require at least double precision): " <<
sizeof(
HPFLTNB) << endl;
366 m_logFile <<
"Float numbers precision in bytes (for datafile reading/writing): " <<
sizeof(
FLTNBDATA) << endl;
367 m_logFile <<
"Float numbers precision in bytes (for scanner LUT reading/writing): " <<
sizeof(
FLTNBLUT) << endl;
369 m_logFile <<
"==================================================================================================" << endl << flush;
395 string option =
"-onbc";
398 size_t pos = a_format.find_first_of(
",");
399 if (pos == string::npos)
401 Cerr(
"***** sOutputManager::SetOutNbPrec() -> Error, format must be (format,precision) (e.g = (f,5) or (s,0)!" << endl);
405 format = a_format.substr(0,pos);
411 Cerr(
"***** sOutputManager::SetOutNbPrec() -> Invalid argument " << a_format <<
" for option " << option <<
" !" << endl);
412 Cerr(
"***** sOutputManager::SetOutNbPrec() -> Format must be (format,precision) (e.g = (f,5) or (s,0)!" << endl);
417 cout << std::setprecision(precision);
419 cout << std::setprecision(std::numeric_limits<FLTNB>::digits10+1);
string ConvertAllSlashOccurrencesToBackSlash(const string &a_path)
Declaration of class oImageDimensionsAndQuantification.
vector< string > mp_dataFileName
sOutputManager()
sOutputManager constructor.
bool m_mergeOutputDynImgFlag
int SetOutNbPrec(string a_format)
Set the output format and precision used for numeric display.
int LogCommandLine(int argc, char **argv)
Write log file header with the provided command line options and different informations.
int CheckConfigDir(const string &a_path)
Set the path to the CASTOR config directory from the given path if not empty or through the existence...
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
const string & GetPathToConfigDir()
Return the path to the CASTOR config directory.
static sOutputManager * mp_Instance
Declaration of class oImageSpace.
Declaration of class sOutputManager.
int InitOutputDirectory(const string &a_pathFout, const string &a_pathDout)
Create the output directory if any, extract the base name and create the log file.
~sOutputManager()
sOutputManager destructor.
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.