6 #include "CORE_Object.h"
9 #include "shared_pointer.h"
18 #include "CORE_Exception.h"
69 tString mOutputFileName;
70 tString mOutputFileName_back;
73 std::ofstream *mOutputFileStream;
78 tUCInt mOutputFileMode;
82 tFlag mOutputFileMode_back;
92 mOutputFileStream=
null;
117 inline static CORE_UniquePointer<CORE_Out>
New() {
157 if (mOutputFileMode==
APPEND) {
158 mOutputFileStream=
new std::ofstream(mOutputFileName.c_str(),std::ios::app);
160 mOutputFileStream=
new std::ofstream(mOutputFileName.c_str(),std::ios::out);
162 if ((mOutputFileStream!=
null) && (!(*mOutputFileStream))) {
164 "impossible to write in output file "+mOutputFileName);
172 if (mOutputFileStream!=
null) {
173 mOutputFileStream->close();
174 delete mOutputFileStream;
175 mOutputFileStream=
null;
183 mOutputFileName=
"./core.log";
217 std::string::const_reverse_iterator iS=mode.rbegin();
218 while (iS!=mode.rend()) {
232 inline tBoolean
isOutput(
const tUCInt& mode)
const {
233 return ((mOutput & mode ) / mode == 1);
248 mOutputFileName=fileName;
249 mOutputFileMode=mode;
259 mOutputFileName=fileName;
268 return mOutputFileName;
274 mOutputFileMode_back= mOutputFileMode;
275 mOutputFileName_back= mOutputFileName;
276 mOutput_back= mOutput;
282 mOutputFileMode= mOutputFileMode_back;
283 mOutputFileName= mOutputFileName_back;
284 mOutput= mOutput_back;
300 inline void print(
const tString& msg) {
307 std::cerr<<msg<<std::flush<<
"\n";
316 const tInt& percent,tInt& oldPercent) {
317 if (percent>oldPercent) {
318 std::cout <<
"\r "<<message<<
" [" << std::setw(3) << percent <<
"%] "<<std::flush;
335 if (out.
isOutput(
FILE_OUTPUT) && (out.mOutputFileStream!=
null)) (*out.mOutputFileStream)<<obj<<std::flush;
345 std::stringstream sstr;
347 sstr<<
"\t"<<
" outputFileName:"<<mOutputFileName<<
"\n";
348 sstr<<
"\t"<<
" output Mode:"<<((int)mOutput)<<
"\n";
349 sstr<<
"\t"<<
" outputFileMode:"<<((int)mOutputFileMode)<<
"\n";
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
abstract base class for most classes.
Definition: CORE_Object.h:65
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:333
this class describes the output stream by default write on standart output
Definition: CORE_Out.h:28
void reset()
reset the state of the class
Definition: CORE_Out.h:180
virtual tMemSize getContentsMemorySize() const override
return nthe memory size of the included associations
Definition: CORE_Out.h:145
void restore()
restore the state after change
Definition: CORE_Out.h:281
void printError(const tString &msg)
print the message on error output
Definition: CORE_Out.h:306
static const tUCInt ALL_OUTPUT
for printing in all
Definition: CORE_Out.h:57
static void PrintProgressBar(const tString &message, const tInt &percent, tInt &oldPercent)
print a progress bar if percent greater than oldpercent
Definition: CORE_Out.h:315
void setOutput(const tUSInt &mode)
set outputType of the binary form v=2*f+s
Definition: CORE_Out.h:199
void setOutputFile(const tString &fileName)
set output file
Definition: CORE_Out.h:253
friend CORE_Out & operator<<(CORE_Out &out, const T &obj)
print Operators
Definition: CORE_Out.h:333
virtual tString toString() const override
return the string repreentation of the class
Definition: CORE_Out.h:344
void print(const tString &msg)
print the message
Definition: CORE_Out.h:300
virtual ~CORE_Out(void)
destroy a CORE_Out
Definition: CORE_Out.h:103
void release()
release the pointers
Definition: CORE_Out.h:171
static const tUCInt FILE_OUTPUT
for printing in file
Definition: CORE_Out.h:53
static CORE_UniquePointer< CORE_Out > New()
build a new instance of default output
Definition: CORE_Out.h:117
static const tUCInt SCREEN_OUTPUT
for printing in screen
Definition: CORE_Out.h:49
void println(const tString &msg)
print the message
Definition: CORE_Out.h:293
static const tFlag CREATE
output file mode : create file
Definition: CORE_Out.h:65
static const tUCInt NO_OUTPUT
for printing in screen
Definition: CORE_Out.h:45
tBoolean hasOutput() const
return true if the output is of the mode
Definition: CORE_Out.h:238
CORE_Out()
build a CORE_Out
Definition: CORE_Out.h:91
const tString & getOutputFileName() const
get the output file name
Definition: CORE_Out.h:267
void backup()
backup the state before change
Definition: CORE_Out.h:273
void setOutputFile(const tString &fileName, const tFlag &mode)
set output file
Definition: CORE_Out.h:247
void update()
update the state of the output
Definition: CORE_Out.h:151
void updateOutputFile(const tString &fileName)
update output file
Definition: CORE_Out.h:258
tBoolean isOutput(const tUCInt &mode) const
return true if the output is of the mode
Definition: CORE_Out.h:232
void setOutput(const tString &mode)
set outputType of the binary form v='FS'
Definition: CORE_Out.h:214
static const tFlag APPEND
output file mode : append to file
Definition: CORE_Out.h:61
virtual tMemSize getMemorySize() const override
return the memory size in byte
Definition: CORE_Out.h:134