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

This class is a Run class for core package. More...

#include <CORE_OptionsReader.h>

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

Public Member Functions

 CORE_OptionsReader (void)
 create More...
 
virtual ~CORE_OptionsReader (void)
 destroy More...
 
virtual tMemSize getMemorySize () const override
 return the memory size of the class 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 tBoolean ReadOptions (const tString &fileName, std::map< tString, tString > &options)
 read the options from a file More...
 
static void ReadOptions (int argc, char *argv[], std::map< tString, tString > &options)
 read all the options from the command line More...
 
static tBoolean ReadOption (int nArgs, char *argv[], const tString &optionName, tString &optionValue)
 read the only the option with optionName in command line More...
 
template<typename T , std::enable_if_t< std::is_floating_point_v< T >> * = nullptr>
static T ReadNumericValue (const tString &strValue)
 read a numeric value of type T More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >> * = nullptr>
static T ReadNumericValue (const tString &strValue)
 read a numeric value of type T More...
 
static tReal ReadReal (const tString &strValue)
 read areal More...
 
static tInteger ReadInteger (const tString &strValue)
 read a natural integer More...
 
static tInteger ReadRelativeInteger (const tString &strValue)
 read a relative integer More...
 
static tInt ReadInt (const tString &strValue)
 read an int More...
 
static tBoolean ReadBoolean (const tString &strValue)
 read the boolean from option More...
 
template<class T >
static tBoolean ReadVector (tString &current, std::vector< T > &values)
 
template<class T , tIndex N>
static tBoolean ReadArray (tString &current, std::array< T, N > &values)
 
static tString ReadPath (const tString &value)
 read a path from a string More...
 
static tBoolean SaveOptionsToFile (const std::map< tString, std::map< tString, tString > > &manOptions, const std::map< tString, tString > &options)
 save the options to the file More...
 
static tBoolean SaveOptionsToFile (const tString &fileName, const std::map< tString, std::map< tString, tString > > &manOptions, const std::map< tString, tString > &options)
 save the options to the file by theme More...
 
static CORE_OutPrintOptions (CORE_Out &out, const std::map< tString, tString > &options)
 print the options 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...
 

Static Private Member Functions

static void RegisterOption (tString &arg, std::map< tString, tString > &options)
 register the option More...
 
static void ReadOptionValue (tString &optionValue)
 read the option value More...
 

Private Attributes

std::weak_ptr< CORE_ObjectmThis
 

Detailed Description

This class is a Run class for core package.

The program is launch as follow:

core.exe [options] make [args]

with options:

wuih type:

execute core.exe –help to show the man

Author
Stephane Despreaux
Version
2.0

Constructor & Destructor Documentation

◆ CORE_OptionsReader()

CORE_OptionsReader::CORE_OptionsReader ( void  )
inline

create

◆ ~CORE_OptionsReader()

virtual CORE_OptionsReader::~CORE_OptionsReader ( void  )
inlinevirtual

destroy

Member Function Documentation

◆ 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:

◆ 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.

◆ 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(), getMemorySize(), CORE_OutputFile::getMemorySize(), and CORE_Test::getMemorySize().

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_OptionsReader::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_Object.

References CORE_Object::getContentsMemorySize().

Here is the call 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.

◆ 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:

◆ 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:

◆ PrintOptions()

static CORE_Out& CORE_OptionsReader::PrintOptions ( CORE_Out out,
const std::map< tString, tString > &  options 
)
inlinestatic

print the options

Parameters
[in,out]outthe output stream
[in]optionsthe options to save in file options["name"]="value"
Returns
the output stream

Referenced by SM_Run::run().

Here is the caller graph for this function:

◆ ReadArray()

template<class T , tIndex N>
static tBoolean CORE_OptionsReader::ReadArray ( tString current,
std::array< T, N > &  values 
)
inlinestatic

References core_functions::parse(), tIndex, and tString.

Here is the call graph for this function:

◆ ReadBoolean()

static tBoolean CORE_OptionsReader::ReadBoolean ( const tString strValue)
inlinestatic

read the boolean from option

Parameters
[in]strValue: option value
Returns
true if the option is empty or true

References core_functions::toLower(), core_functions::trim(), and tString.

Referenced by SM_Run::loadBeamFromOptions(), CORE_Run::SetDebugOptions(), and CORE_Run::SetOutputOptions().

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

◆ ReadInt()

static tInt CORE_OptionsReader::ReadInt ( const tString strValue)
inlinestatic

read an int

Parameters
[in]strValue: value as a string
Returns
an int

◆ ReadInteger()

static tInteger CORE_OptionsReader::ReadInteger ( const tString strValue)
inlinestatic

read a natural integer

Parameters
[in]strValue: value as a string
Returns
a natural integer

◆ ReadNumericValue() [1/2]

template<typename T , std::enable_if_t< std::is_floating_point_v< T >> * = nullptr>
static T CORE_OptionsReader::ReadNumericValue ( const tString strValue)
inlinestatic

read a numeric value of type T

Parameters
[in]strValue: value as a string
Returns
a numeric value

◆ ReadNumericValue() [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >> * = nullptr>
static T CORE_OptionsReader::ReadNumericValue ( const tString strValue)
inlinestatic

read a numeric value of type T

Parameters
[in]strValue: value as a string
Returns
a numeric value

◆ ReadOption()

tBoolean CORE_OptionsReader::ReadOption ( int  nArgs,
char *  argv[],
const tString optionName,
tString optionValue 
)
static

read the only the option with optionName in command line

Parameters
[in]nArgsnumber of parameters of the command line
[in]argv: value of the parameters
[in]optionNamevalue of the option
[out]optionValue: value of the option
Returns
false if the option does not exists

References ReadOptionValue(), tIndex, and tString.

Referenced by CORE_Run::executeRun().

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

◆ ReadOptions() [1/2]

tBoolean CORE_OptionsReader::ReadOptions ( const tString fileName,
std::map< tString, tString > &  options 
)
static

read the options from a file

Parameters
[in]fileNamefile name of the options
[in]options: options values optName -> optValue as a string
Returns
false if the options reading failed

References RegisterOption(), tChar, tIndex, core_functions::trim(), tString, and tUSInt.

Referenced by CORE_Run::executeRun(), and CORE_Test::testCase().

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

◆ ReadOptions() [2/2]

void CORE_OptionsReader::ReadOptions ( int  argc,
char *  argv[],
std::map< tString, tString > &  options 
)
static

read all the options from the command line

Parameters
[in]argcnumber of parameter of the command line
[in]argv: value of the parameters
[in]options: options values optName -> optValue as a string

References RegisterOption(), tIndex, and tString.

Here is the call graph for this function:

◆ ReadOptionValue()

void CORE_OptionsReader::ReadOptionValue ( tString optionValue)
staticprivate

read the option value

Parameters
[in,out]optionValue: value of the option read the affectation value after '=' which is either:
  • ' ' -> value is null
  • =" value "
  • = value

References tIndex, and core_functions::trim().

Referenced by ReadOption(), and RegisterOption().

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

◆ ReadPath()

static tString CORE_OptionsReader::ReadPath ( const tString value)
inlinestatic

read a path from a string

Parameters
[in]value: value as a string

References CORE_IO::GetAbsolutePath().

Referenced by SM_Run::generateOutput(), SaveOptionsToFile(), CORE_Run::SetOutputOptions(), and CORE_Test::testCase().

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

◆ ReadReal()

static tReal CORE_OptionsReader::ReadReal ( const tString strValue)
inlinestatic

read areal

Parameters
[in]strValue: value as a string
Returns
a real

◆ ReadRelativeInteger()

static tInteger CORE_OptionsReader::ReadRelativeInteger ( const tString strValue)
inlinestatic

read a relative integer

Parameters
[in]strValue: value as a string
Returns
a relative integer

◆ ReadVector()

template<class T >
static tBoolean CORE_OptionsReader::ReadVector ( tString current,
std::vector< T > &  values 
)
inlinestatic

References core_functions::parse(), tIndex, and tString.

Referenced by SM_Run::generateOutput(), SM_Run::loadMagneticMomentFromOptions(), SM_Run::loadNetworkFromOptions(), and SM_Run::loadOperatorsFromOptions().

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

◆ RegisterOption()

void CORE_OptionsReader::RegisterOption ( tString arg,
std::map< tString, tString > &  options 
)
staticprivate

register the option

Parameters
[in]arg: argumen of the form:
  • key
  • key= value
  • key=" value "
[in,out]options(key,value) registered in options map

References ReadOptionValue(), tIndex, core_functions::trim(), and tString.

Referenced by ReadOptions().

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

◆ SaveOptionsToFile() [1/2]

static tBoolean CORE_OptionsReader::SaveOptionsToFile ( const std::map< tString, std::map< tString, tString > > &  manOptions,
const std::map< tString, tString > &  options 
)
inlinestatic

save the options to the file

Parameters
[in]manOptionsthe option descriptions
[in]optionsthe options to save in file

References ReadPath().

Referenced by SM_Run::makeRun().

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

◆ SaveOptionsToFile() [2/2]

tBoolean CORE_OptionsReader::SaveOptionsToFile ( const tString fileName,
const std::map< tString, std::map< tString, tString > > &  manOptions,
const std::map< tString, tString > &  options 
)
static

save the options to the file by theme

Parameters
[in]fileNamethe options file to save
[in]manOptionsexplanation of the options by theme manOptions["theme"]["name"]="explanation"
[in]optionsthe options to save in file options["name"]="value"

References CORE_Chrono::GetDate(), tBoolean, tIndex, and tString.

Here is the call graph for this function:

◆ 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

Member Data Documentation

◆ mThis

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

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