C++ main module for stochmagnet Package  1.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CORE_OutputFile Class Reference

this class describes a writing file More...

#include <CORE_OutputFile.h>

Inheritance diagram for CORE_OutputFile:
Inheritance graph
[legend]
Collaboration diagram for CORE_OutputFile:
Collaboration graph
[legend]

Public Member Functions

 CORE_OutputFile ()
 build a CORE_OutputClass object More...
 
virtual ~CORE_OutputFile (void)
 destroy a CORE_OutputClass object More...
 
virtual tMemSize getMemorySize () const override
 return the memory size of the class More...
 
void setPrecision (const tUSInt &p)
 set precision More...
 
tBoolean open (const tString &fileName)
 open file fileName for writing More...
 
tBoolean append (const tString &fileName)
 open file fileName for appending More...
 
void close ()
 close the file More...
 
tULInt getCurrentIndex () const
 get the current index of the file More...
 
tBoolean moveTo (const tULInt &index)
 move the current index position of the file to index More...
 
tBoolean translate (const tLInt &dx)
 translate the current index position of the file More...
 
tBoolean isEndOfFile () const
 test if the cursor is at the end of file More...
 
template<class T >
CORE_OutputFileoperator<< (const T &obj)
 writing operator More...
 
template<class T >
std::shared_ptr< T > getSharedPointer ()
 return the shared pointer for this More...
 
template<class T >
std::shared_ptr< const T > getConstSharedPointer () const
 return a const shared pointer for this More...
 
virtual tMemSize getContentsMemorySize () const
 return nthe memory size of the included associations More...
 
template<class T >
tBoolean isInstanceOf () const
 test if the clas T is an instance of this class More...
 
tString getClassName () const
 return the name of the class More...
 
tString getPointerString () const
 retrun the pointer of the class as a string More...
 
tString getIdentityString () const
 retrun the string identification of the class More...
 
virtual tString toString () const
 return the string representation of the object node More...
 

Static Public Member Functions

static CORE_UniquePointer< CORE_OutputFileNew ()
 create a new instance of CORE_OutputFile class More...
 
static tBoolean IsFile (const tString &f)
 return true if the file is a regular file More...
 
static tBoolean IsPath (const tString &p)
 return true if the path designed by p is a path More...
 
static tBoolean Exists (const tString &f)
 return true if the file or the path exists More...
 
static tBoolean CreatePath (const tString &path)
 create a path More...
 
static tBoolean Rename (const tString &file, const tString &newFile)
 
static tBoolean RemovePath (const tString &path, const tBoolean &force)
 remove a path More...
 
static tBoolean RemovePath (const tString &path)
 remove an empty path More...
 
static tBoolean RemoveFile (const tString &file)
 remove a file More...
 
static void RemoveAllFiles (const tString &path)
 remove all files within a path More...
 
static void RemoveAllFiles (const tString &path, const tString &exts)
 remove all files with extension within the path More...
 
static tString GetSystemPath (const tString &posix_path)
 get the system path corresponding to posix path More...
 
static void GetPaths (const tString &path, std::vector< tString > &paths)
 get all the paths within the directory More...
 
static tString GetPathName (const tString &aPath)
 get all the paths within the directory More...
 
static void GetFiles (const tString &path, std::vector< tString > &files)
 get all the files within the directory More...
 
static void GetFiles (const tString &path, const tString &exts, std::vector< tString > &files)
 get all the files within the directory with extension of the form .ext More...
 
static tBoolean CopyFiles (const tString &sourcePath, const tString &exts, const tString &destPath, const tBoolean &overwrite)
 copy all the files with extension within the directory to destination path More...
 
static tBoolean CopyFiles (const tString &sourcePath, const tString &destPath, const tBoolean &overwrite)
 copy all the files within the directory to destination path More...
 
static tBoolean CopyFile (const tString &source, const tString &dest, const tBoolean &overwrite)
 copy file More...
 
static tBoolean CopyFile (const tString &source, const tString &dest)
 copy file More...
 
static tBoolean CopyPath (const tString &sourcePath, const tString &destPath)
 copy path More...
 
static void GetContent (const tString &path, std::vector< tString > &content)
 get all the content files or paths within the directory More...
 
static tString GetCurrentPath ()
 get the current path More...
 
static tString GetAbsolutePath (const tString &path)
 get the absolute path of the path More...
 
static tString GetBaseName (const tString &file)
 get base name of the file More...
 
static tString GetExtension (const tString &file)
 get extension of the file More...
 
static tString GetPath (const tString &file)
 get path containing the file More...
 
static tString GetFileName (const tString &file)
 get path containing the file More...
 
static tBoolean EnableMemoryStack (const tBoolean &isMemoryChecked)
 enable the memory stack More...
 
static void EnableMemoryStack ()
 enable the memory stack More...
 
static void DisableMemoryStack ()
 disable the memory stack More...
 
static tBoolean IsMemoryStackEnabled ()
 return trur if the memory stack is enabled More...
 
static tString MemoryStackToString ()
 get the memory stack in string More...
 
static tIndex GetRegisteredClassesNumber ()
 get the memory stack in string More...
 

Private Member Functions

template<class T >
std::shared_ptr< T > setThis (std::unique_ptr< T, CORE_Object::Delete > &up)
 set the shared pointer from an unique pointer More...
 

Private Attributes

tULInt mLength
 
std::unique_ptr< std::ofstream > mFile
 
std::weak_ptr< CORE_ObjectmThis
 

Detailed Description

this class describes a writing file

Constructor & Destructor Documentation

◆ CORE_OutputFile()

CORE_OutputFile::CORE_OutputFile ( )
inline

build a CORE_OutputClass object

References mLength.

Referenced by New().

Here is the caller graph for this function:

◆ ~CORE_OutputFile()

virtual CORE_OutputFile::~CORE_OutputFile ( void  )
inlinevirtual

destroy a CORE_OutputClass object

References close().

Here is the call graph for this function:

Member Function Documentation

◆ append()

tBoolean CORE_OutputFile::append ( const tString fileName)
inline

open file fileName for appending

Parameters
fileNamethe name of the file to write return false

References close(), mFile, and mLength.

Here is the call graph for this function:

◆ close()

void CORE_OutputFile::close ( )
inline

close the file

References mFile.

Referenced by append(), SM_XDMF::close(), open(), and ~CORE_OutputFile().

Here is the caller graph for this function:

◆ CopyFile() [1/2]

static tBoolean CORE_IO::CopyFile ( const tString source,
const tString dest 
)
inlinestaticinherited

copy file

Parameters
[in]sourcesource file
[in]destdestfile
[in]overwrite: true to erase old file
Returns
true if thecopy has succeeds

References CORE_IO::CopyFile().

Here is the call graph for this function:

◆ CopyFile() [2/2]

static tBoolean CORE_IO::CopyFile ( const tString source,
const tString dest,
const tBoolean overwrite 
)
inlinestaticinherited

copy file

Parameters
[in]sourcesource file
[in]destdestfile
[in]overwrite: true to erase old file
Returns
true if thecopy has succeeds

Referenced by CORE_IO::CopyFile().

Here is the caller graph for this function:

◆ CopyFiles() [1/2]

static tBoolean CORE_IO::CopyFiles ( const tString sourcePath,
const tString destPath,
const tBoolean overwrite 
)
inlinestaticinherited

copy all the files within the directory to destination path

Parameters
[in]sourcePathpath to get the files with extension ext
[in]destPathdestinaton path
[in]overwrite: true to erase old file
Returns
true if the paths exists

◆ CopyFiles() [2/2]

static tBoolean CORE_IO::CopyFiles ( const tString sourcePath,
const tString exts,
const tString destPath,
const tBoolean overwrite 
)
inlinestaticinherited

copy all the files with extension within the directory to destination path

Parameters
[in]sourcePathpath to get the files with extension ext
[in]exts:xtensions of the file to search for example ".mov .avi "
[in]destPathdestinaton path
[in]overwrite: true to erase old file
Returns
true if the paths exist

References CORE_IO::GetExtension(), core_functions::toLower(), and tString.

Here is the call graph for this function:

◆ CopyPath()

static tBoolean CORE_IO::CopyPath ( const tString sourcePath,
const tString destPath 
)
inlinestaticinherited

copy path

Parameters
[in]sourcePathpath to get the files with extension ext
[in]destPathdestinaton path
Returns
true if the paths exists

◆ CreatePath()

static tBoolean CORE_IO::CreatePath ( const tString path)
inlinestaticinherited

create a path

Parameters
[in]pathcreate the path
Returns
true if the path has been created correctly

Referenced by CORE_Test::testIO().

Here is the caller graph for this function:

◆ DisableMemoryStack()

static void CORE_Object::DisableMemoryStack ( )
inlinestaticinherited

disable the memory stack

Referenced by CORE_Object::EnableMemoryStack().

Here is the caller graph for this function:

◆ EnableMemoryStack() [1/2]

static void CORE_Object::EnableMemoryStack ( )
inlinestaticinherited

enable the memory stack

Referenced by CORE_Object::EnableMemoryStack(), and CORE_Run::SetDebugOptions().

Here is the caller graph for this function:

◆ EnableMemoryStack() [2/2]

static tBoolean CORE_Object::EnableMemoryStack ( const tBoolean isMemoryChecked)
inlinestaticinherited

enable the memory stack

Parameters
[in]isMemoryChecked: true to verify memory allocation of CORE_Object classes
Returns
true if the memroy is checked

References CORE_Object::DisableMemoryStack(), CORE_Object::EnableMemoryStack(), and CORE_Object::IsMemoryStackEnabled().

Here is the call graph for this function:

◆ Exists()

static tBoolean CORE_IO::Exists ( const tString f)
inlinestaticinherited

return true if the file or the path exists

Parameters
[in]ffile or path to verify the existence
Returns
true if the file/path exists

Referenced by CORE_IO::Rename().

Here is the caller graph for this function:

◆ GetAbsolutePath()

static tString CORE_IO::GetAbsolutePath ( const tString path)
inlinestaticinherited

get the absolute path of the path

Parameters
[in]pathpath to get the absolute path
Returns
the absolute path of the path

Referenced by CORE_OptionsReader::ReadPath().

Here is the caller graph for this function:

◆ GetBaseName()

static tString CORE_IO::GetBaseName ( const tString file)
inlinestaticinherited

get base name of the file

Parameters
[in]file: name of the file
Returns
the base name of the file

Referenced by CORE_Test::testIO().

Here is the caller graph for this function:

◆ getClassName()

tString CORE_Object::getClassName ( ) const
inlineinherited

return the name of the class

Returns
the string name of the class

Referenced by CORE_Object::getIdentityString(), and CORE_Test::testTypes().

Here is the caller graph for this function:

◆ getConstSharedPointer()

template<class T >
std::shared_ptr<const T> CORE_Object::getConstSharedPointer ( ) const
inlineinherited

return a const shared pointer for this

Returns
the shared pointer as a type T

References CORE_Object::mThis.

◆ GetContent()

static void CORE_IO::GetContent ( const tString path,
std::vector< tString > &  content 
)
inlinestaticinherited

get all the content files or paths within the directory

Parameters
[in]pathpath to get the content
[out]content: all the content of the path files of paths

◆ getContentsMemorySize()

virtual tMemSize CORE_Object::getContentsMemorySize ( ) const
inlinevirtualinherited

return nthe memory size of the included associations

Returns
the memory size of the storage in bytes 1 Kb = 1024 bytes 1 Mb = 1024 Kb 1 Gb = 1024 Mb 1 Tb = 1024 Gb 1 Hb = 1024 Tb

Reimplemented in CORE_VectorList< T, I >, CORE_VectorList< tString, CORE_StringsList >, CORE_ValArray< T, I >, CORE_ValArray< T, CORE_StdValArray< T > >, CORE_Run, CORE_PtrArray< T, I >, CORE_PtrArray< T, CORE_StdPtrArray< T > >, CORE_Field< T, K, D, S, I >, CORE_Field< T, K, D, CORE_StdPtrArray< T >, CORE_StdPtrField< T, K, D > >, CORE_Field< T, K, D, CORE_StdValArray< T >, CORE_StdValField< T, K, D > >, CORE_ClassFactory, SMS_STDUniformFunction, SMS_STDNormalFunction, SMS_BoostUniformFunction, SMS_BoostNormalFunction, SM_ZeemanOperator, SM_XDMF, SM_VTK, SM_System, SM_Output, SM_Operator, SM_Network, SM_DemagnetizedOperator, SM_Beam, CORE_StringsList, and CORE_Out.

Referenced by CORE_Out::getContentsMemorySize(), SM_Beam::getContentsMemorySize(), SM_Network::getContentsMemorySize(), SM_Operator::getContentsMemorySize(), SM_Output::getContentsMemorySize(), SM_System::getContentsMemorySize(), SM_VTK::getContentsMemorySize(), SMS_BoostNormalFunction::getContentsMemorySize(), SMS_BoostUniformFunction::getContentsMemorySize(), SMS_STDNormalFunction::getContentsMemorySize(), SMS_STDUniformFunction::getContentsMemorySize(), CORE_ClassFactory::getContentsMemorySize(), CORE_PtrArray< T, I >::getContentsMemorySize(), CORE_ValArray< T, I >::getContentsMemorySize(), CORE_VectorList< T, I >::getContentsMemorySize(), CORE_Object::getMemorySize(), SM_ConstantNoiseRateFunction::getMemorySize(), SM_InverseNoiseRateFunction::getMemorySize(), SM_LandauLifschitzFunction::getMemorySize(), SM_NoiseRateFunction::getMemorySize(), SM_Object::getMemorySize(), SM_StochasticFunction::getMemorySize(), SM_TemplatedNoiseRateFunction< DerivedClass >::getMemorySize(), SM_TimeStepper::getMemorySize(), SMS_BoostRandomFunction::getMemorySize(), CORE_Array< T, I >::getMemorySize(), CORE_Chrono::getMemorySize(), CORE_Collection< T, I >::getMemorySize(), CORE_IO::getMemorySize(), CORE_List< T, K, I >::getMemorySize(), CORE_OptionsReader::getMemorySize(), getMemorySize(), and CORE_Test::getMemorySize().

Here is the caller graph for this function:

◆ getCurrentIndex()

tULInt CORE_OutputFile::getCurrentIndex ( ) const
inline

get the current index of the file

Returns
the current index of the file

References mFile.

Referenced by translate().

Here is the caller graph for this function:

◆ GetCurrentPath()

static tString CORE_IO::GetCurrentPath ( )
inlinestaticinherited

get the current path

Returns
the current path

◆ GetExtension()

static tString CORE_IO::GetExtension ( const tString file)
inlinestaticinherited

get extension of the file

Parameters
[in]file: name of the file
Returns
the extention of the file of the form .ext

Referenced by CORE_IO::CopyFiles(), CORE_IO::GetFiles(), and CORE_Test::testIO().

Here is the caller graph for this function:

◆ GetFileName()

static tString CORE_IO::GetFileName ( const tString file)
inlinestaticinherited

get path containing the file

Parameters
[in]file: name of the file
Returns
the path containing the file

◆ GetFiles() [1/2]

static void CORE_IO::GetFiles ( const tString path,
const tString exts,
std::vector< tString > &  files 
)
inlinestaticinherited

get all the files within the directory with extension of the form .ext

Parameters
[in]pathpath to get the content
[in]extsextensions of the file to search for example ".mov .avi "
[out]files: all the files within the path

References CORE_IO::GetExtension(), core_functions::toLower(), and tString.

Here is the call graph for this function:

◆ GetFiles() [2/2]

static void CORE_IO::GetFiles ( const tString path,
std::vector< tString > &  files 
)
inlinestaticinherited

get all the files within the directory

Parameters
[in]pathpath to get the content
[out]files: all the files within the path

Referenced by CORE_IO::RemoveAllFiles(), and CORE_Test::testIO().

Here is the caller graph for this function:

◆ getIdentityString()

tString CORE_Object::getIdentityString ( ) const
inlineinherited

retrun the string identification of the class

Returns
the string identity of the class

References CORE_Object::getClassName(), and core_functions::pointerToString().

Referenced by CORE_Test::testArray(), CORE_Test::testField(), CORE_Test::testTypes(), CORE_Object::toString(), CORE_ClassFactory::toString(), and CORE_Field< T, K, D, S, I >::toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMemorySize()

virtual tMemSize CORE_OutputFile::getMemorySize ( ) const
inlineoverridevirtual

return the memory size of the class

Returns
the memory size of the class in bytes 1 octet = 1 byte 1 Ko = 1024 bytes 1 Mo = 1024 Ko 1 Go = 1024 Mo

Reimplemented from CORE_IO.

References CORE_Object::getContentsMemorySize().

Here is the call graph for this function:

◆ GetPath()

static tString CORE_IO::GetPath ( const tString file)
inlinestaticinherited

get path containing the file

Parameters
[in]file: name of the file
Returns
the path containing the file

Referenced by CORE_Test::testIO().

Here is the caller graph for this function:

◆ GetPathName()

static tString CORE_IO::GetPathName ( const tString aPath)
inlinestaticinherited

get all the paths within the directory

Parameters
[in]aPathabsolute path to get the content
Returns
the name of the aPath

◆ GetPaths()

static void CORE_IO::GetPaths ( const tString path,
std::vector< tString > &  paths 
)
inlinestaticinherited

get all the paths within the directory

Parameters
[in]pathpath to get the content
[out]pathsall the paths within the path

Referenced by CORE_Test::testIO().

Here is the caller graph for this function:

◆ getPointerString()

tString CORE_Object::getPointerString ( ) const
inlineinherited

retrun the pointer of the class as a string

Returns
the pointer of the calss as a string

References core_functions::pointerToString().

Here is the call graph for this function:

◆ GetRegisteredClassesNumber()

static tIndex CORE_Object::GetRegisteredClassesNumber ( )
inlinestaticinherited

get the memory stack in string

Returns
the string representation of the memory stack

◆ getSharedPointer()

template<class T >
std::shared_ptr<T> CORE_Object::getSharedPointer ( )
inlineinherited

return the shared pointer for this

Returns
the shared pointer as a type T

References CORE_Object::mThis.

◆ GetSystemPath()

static tString CORE_IO::GetSystemPath ( const tString posix_path)
inlinestaticinherited

get the system path corresponding to posix path

Returns
ystem path corresponding to posix path '/'->'\' for windows unchange for linux/mac

◆ isEndOfFile()

tBoolean CORE_OutputFile::isEndOfFile ( ) const
inline

test if the cursor is at the end of file

Returns
true if the end of file is reached

References mFile.

◆ IsFile()

static tBoolean CORE_IO::IsFile ( const tString f)
inlinestaticinherited

return true if the file is a regular file

Parameters
[in]ffile to test
Returns
true if the file is regular

◆ isInstanceOf()

template<class T >
tBoolean CORE_Object::isInstanceOf ( ) const
inlineinherited

test if the clas T is an instance of this class

Returns
true if the object is an instance of T

Referenced by SM_Beam::templatedSimulate().

Here is the caller graph for this function:

◆ IsMemoryStackEnabled()

static tBoolean CORE_Object::IsMemoryStackEnabled ( )
inlinestaticinherited

return trur if the memory stack is enabled

Referenced by CORE_Object::EnableMemoryStack(), and main().

Here is the caller graph for this function:

◆ IsPath()

static tBoolean CORE_IO::IsPath ( const tString p)
inlinestaticinherited

return true if the path designed by p is a path

Parameters
[in]ppath to test
Returns
true if the path is regular

◆ MemoryStackToString()

static tString CORE_Object::MemoryStackToString ( )
inlinestaticinherited

get the memory stack in string

Returns
the string representation of the memory stack

Referenced by main().

Here is the caller graph for this function:

◆ moveTo()

tBoolean CORE_OutputFile::moveTo ( const tULInt index)
inline

move the current index position of the file to index

Parameters
[in]indexnew index to go
Returns
true if he moving succeeds

References mFile, and mLength.

Referenced by translate().

Here is the caller graph for this function:

◆ New()

static CORE_UniquePointer<CORE_OutputFile> CORE_OutputFile::New ( )
inlinestatic

create a new instance of CORE_OutputFile class

References CORE_OutputFile().

Referenced by SM_XDMF::SM_XDMF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

tBoolean CORE_OutputFile::open ( const tString fileName)
inline

open file fileName for writing

Parameters
[in]fileNamethe name of the file to write return false if the file name can not be opened

References close(), mFile, and mLength.

Here is the call graph for this function:

◆ operator<<()

template<class T >
CORE_OutputFile& CORE_OutputFile::operator<< ( const T &  obj)
inline

writing operator

Parameters
[in]objthe object to write into file

References ASSERT_IN, mFile, and mLength.

◆ RemoveAllFiles() [1/2]

static void CORE_IO::RemoveAllFiles ( const tString path)
inlinestaticinherited

remove all files within a path

Parameters
[in]pathpath in which the fils has to be remove remove
Returns
true if the file has been removed correctly

References CORE_IO::GetFiles().

Here is the call graph for this function:

◆ RemoveAllFiles() [2/2]

static void CORE_IO::RemoveAllFiles ( const tString path,
const tString exts 
)
inlinestaticinherited

remove all files with extension within the path

Parameters
[in]pathpath in which the fils has to be remove remove
[in]extsextension of files to remove
Returns
true if the file has been removed correctly

References CORE_IO::GetFiles().

Here is the call graph for this function:

◆ RemoveFile()

static tBoolean CORE_IO::RemoveFile ( const tString file)
inlinestaticinherited

remove a file

Parameters
[in]filefile to remove
Returns
true if the file has been removed correctly

◆ RemovePath() [1/2]

static tBoolean CORE_IO::RemovePath ( const tString path)
inlinestaticinherited

remove an empty path

Parameters
[in]pathpath to remove
Returns
true if the path has been removed correctly

References CORE_IO::RemovePath().

Here is the call graph for this function:

◆ RemovePath() [2/2]

static tBoolean CORE_IO::RemovePath ( const tString path,
const tBoolean force 
)
inlinestaticinherited

remove a path

Parameters
[in]pathpath to remove
[in]forcetrue to remove the path even if not empty
Returns
true if the path has been removed correctly

Referenced by CORE_IO::RemovePath(), and CORE_Test::testIO().

Here is the caller graph for this function:

◆ Rename()

static tBoolean CORE_IO::Rename ( const tString file,
const tString newFile 
)
inlinestaticinherited

_breif mov ethe path or file to another path or file

Parameters
[in]filefile to rename
[in]newFile: new full name

References CORE_IO::Exists().

Here is the call graph for this function:

◆ setPrecision()

void CORE_OutputFile::setPrecision ( const tUSInt p)
inline

set precision

Parameters
[in]p: precision for writting file

◆ setThis()

template<class T >
std::shared_ptr<T> CORE_Object::setThis ( std::unique_ptr< T, CORE_Object::Delete > &  up)
inlineprivateinherited

set the shared pointer from an unique pointer

Parameters
[in,out]upunique pointer of the class at input, points to null pointer at output
Returns
the shared pointer of the class

Method only calledby the friend class CORE_ClassFactory::NewSharedInstance()

References CORE_Object::mThis.

◆ toString()

virtual tString CORE_Object::toString ( ) const
inlinevirtualinherited

◆ translate()

tBoolean CORE_OutputFile::translate ( const tLInt dx)
inline

translate the current index position of the file

Parameters
dxtranslator index
Returns
true if the translating succeeds

References getCurrentIndex(), and moveTo().

Here is the call graph for this function:

Member Data Documentation

◆ mFile

std::unique_ptr<std::ofstream> CORE_OutputFile::mFile
private

◆ mLength

tULInt CORE_OutputFile::mLength
private

◆ mThis

std::weak_ptr<CORE_Object> CORE_Object::mThis
privateinherited

The documentation for this class was generated from the following file: