24 #ifdef CASToR_USE_CMAKE
25 #include "oCASToRConfig.hh"
36 if (code!=0)
Cerr(
"***** Exit function called. Abort with code " << code <<
"." << endl);
66 cout << std::scientific;
68 cerr << std::setprecision(std::numeric_limits<FLTNB>::digits10+1);
105 if (
m_verbose>=3)
Cout(
"sOutputManager::CheckConfigDir() -> Directory selected from option as '" << a_path <<
"'" << endl);
111 #ifdef CASToR_USE_CMAKE
112 string tmp_path = CASTOR_CONFIG;
113 if (tmp_path.empty())
114 #elif defined(CASTOR_USE_MINGW)
119 if (tmp_path.empty())
123 When cross-compiling, you must define the CASTOR_CONFIG environment variable before that. This compilation error you are seeing is normal!
126 char* tmp_path = getenv(
"CASTOR_CONFIG");
130 Cerr(
"***** sOutputManager::CheckConfigDir() -> No path nor CASTOR_CONFIG variable provided !" << endl);
133 if (
m_verbose>=3)
Cout(
"sOutputManager::CheckConfigDir() -> Directory selected from environment variable as '" << ((
string)tmp_path) <<
"'" << endl);
161 if (
m_verbose>=3)
Cout(
"sOutputManager::GetPathToConfigDir ..."<< endl);
163 #if defined(CASToR_USE_CMAKE)
164 string tmp_path = CASTOR_CONFIG;
165 if (tmp_path.empty())
166 #elif defined(CASTOR_USE_MINGW)
171 if (tmp_path.empty())
175 When cross-compiling, you must define the CASTOR_CONFIG environment variable before that. This compilation error you are seeing is normal!
178 char* tmp_path = getenv(
"CASTOR_CONFIG");
182 Cerr(
"***** sOutputManager::CheckConfigDir() -> No path nor CASTOR_CONFIG variable provided ! Try working directory instead." << endl);
186 #if defined(CASToR_USE_CMAKE) || defined(CASTOR_USE_MINGW)
211 #ifdef CASTOR_VERBOSE
212 if (
m_verbose>=4)
Cout(
"+++++ sOutputManager::InitOutputDirectory() -> Enter"<< endl);
216 if (a_pathFout!=
"" && a_pathDout!=
"")
218 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Either a file path (-fout) or a directory path (dout) should be provided. cannot be both provided, make your choice !" << endl);
223 string the_path = a_pathFout;
224 if (a_pathDout!=
"") the_path = a_pathDout;
225 string last_char = the_path.substr(the_path.length()-1);
226 if (last_char==
"." || last_char==
OS_SEP)
228 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Please provide a path not finishing by '.', '"<<
OS_SEP <<
"' character !" << endl);
233 if (
m_verbose>=1)
Cout(
"sOutputManager::InitOutputDirectory() -> Output path is '" << a_pathFout << a_pathDout <<
"'" << endl);
242 size_t last_slash_pos = a_pathFout.find_last_of(
OS_SEP);
244 if (last_slash_pos==string::npos)
253 m_pathName = a_pathFout.substr(0,last_slash_pos+1);
255 m_baseName = a_pathFout.substr(last_slash_pos+1);
263 else if (a_pathDout!=
"")
266 size_t last_slash_pos = a_pathDout.find_last_of(
OS_SEP);
268 if (last_slash_pos==string::npos)
279 m_baseName = a_pathDout.substr(last_slash_pos+1);
287 string instruction =
"mkdir -p " +
m_pathName;
289 int error = system(instruction.c_str());
292 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Failed to create output directory with name '" << m_pathName <<
"' !" << endl);
313 Cerr(
"***** sOutputManager::InitOutputDirectory() -> Failed to create output log file as '" << log_file_name <<
"' ! Are you sure the provided output path exists ?" << endl);
329 if (
m_verbose>=3)
Cout(
"sOutputManager::LogCommandLine() -> Write command line into the log file"<< endl);
336 m_logFile <<
"==================================================================================================" << endl;
337 m_logFile <<
" COMMAND LINE CONTEXT" << endl;
338 m_logFile <<
"==================================================================================================" << endl;
341 for (
int i=0; i<argc; i++)
m_logFile << argv[i] <<
" ";
345 GetCurrentDirectory(MAX_PATH,pwd);
346 m_logFile <<
"Working directory: " << pwd << endl;
348 m_logFile <<
"Working directory: " << getenv(
"PWD") << endl;
350 m_logFile <<
"Date of execution (since Epoch): " << time(NULL) << endl;
351 m_logFile <<
"Float numbers precision in bytes (for computation): " <<
sizeof(
FLTNB) << endl;
352 m_logFile <<
"Float numbers precision in bytes (for datafile reading/writing): " <<
sizeof(
FLTNBDATA) << endl;
353 m_logFile <<
"Float numbers precision in bytes (for scanner LUT reading/writing): " <<
sizeof(
FLTNBLUT) << endl;
355 m_logFile <<
"==================================================================================================" << endl << flush;
string ConvertAllSlashOccurrencesToBackSlash(const string &a_path)
Declaration of class oImageDimensionsAndQuantification.
sOutputManager()
sOutputManager constructor.
bool m_mergeOutputDynImgFlag
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.