core package package contains all core classes used in all modules.
core package package contains all core classes used in all modules.
UML Convention
It contains templated functions:
- shared_pointer.h : templated functions ofr shared pointers maniplations
- types.h : the definition of types use in the programs
- functions_types.h : the templated required funtions
- functions_numeric.h : templated functions for numerics methods
- functions_string.h : templated functions for string maniplations
- functions_complex.h : templated functons for math complex manipulations
- functions_array.h : templated functions for std::array std::val_array manipulations
- functions_bit.h : templated functions for bit manipulations
- functions_grid.h : templated functions for grid indices manipulations
- functions_constants.h : the constant values for all packages
It contains utility classes:
This package in DEBUG mode enable a memory stack to ensure all created objects has been destoyed at the end. Note that the memory stack is also disabled in OpenMP module manged by the OMP_Thread class
A class contains:
- data attributes which are primive attributes which not change during the simulation
- a state attributes which are primive attributes which may change during the simulation
- an aggegate association of a class which is not used by other class modelized by a CORE_UniquePointer association class.
- a simple association of a class which can be used by other classes modelized by a CORE_SharedPointer association class.
The coding conventions:
- name conventions:
- static methods or static attributes begins with an upper case
- static constants are all in upper case
- private attribute or association is precceeding by 'm' like my
- a name of a class is as follow [PACKAGE]_ClassName
- the attributes and associations are defined at the begining of the class definition and are all private.
- All the attributes/associations are suffixed by the character ’m’ like my.
- the methods follow the attributes & associations definition. Public methods are the first methods followed by protected and private methods used in the public/protected methods
- all classes have:
- a default constructor
- a default copy constructor and default operator = (private if if should not to be used even it it is not implemented or decaled as delete A(const A& a) = delete;
- a default virtual destructor
- all constructors with arguments are defined with 'explicit' keyword in order not to allowed undesired convertion.
- a constructor calls no virtual methods.
- The methods organizations:
- declaration of virtual method ends with either final or override method.
- method which does not modify the attribute of the class is a const mehod
The smart pointer definition :
- a class with protected construction can only be created with an unique pointer std::unique_ptr(T,CORE_Object::Delete)
- if the construction is public , the class is supposed to be created only by reference (no new called)
- a shared pointer of a class can only be created with the CORE_ClassFactory::NewSharedInstance() from an Unique pointer. (this functionality excludes the using of the std::enable_shared_from_this [CORE_Object] class.
- instead of testing if a pointer is not null use gsl::not_null(T) t=getToto() t is a T which are supposed not to be null
- to oblige a pointer to be delete use gsl::owner(T) t=new ...
All the used types are defined in a types.h
To cast the variable from type to another use static_cast : Q j=static_cast[Q](i); or one of them:
- dynamic_cast to cast a based pointer to its derivative pointer
- reinterpret_cast to turn a memory space of a type T to a new type Q
- const_cast : to supress the constance of a variable
using of constexpr for a variable instead of #define or const for expression evaluated at compilation.
- a function can returned a constexpr when all its argument are constexpr
- if constexpr when the argument of the if is compuated at compilation
- static_asset() : asserting on expression evalued at compmilmation
using for ( const type iter : values) when values is a class containing begin() and end() and iter is an iterator
For looping when begin() and end() it is possible to use: for (const auto & e : elements) { } when data has a begin & end funtcion std::for_each(begin(),end(),[parameters](const T& v){lambda function where v in [begin(),end()[;}); std::sort(begin(),end(),[](const T& a,const T& b){ return (a>b);});
parameters:
- [] no parameters
- [&] all variables by reference
- [=] all variables by value
- [=,&j] all variables by value except j by reference
- [&,j] all variables by reference except j by value
We can define a lambda funtion outside the key word auto lambdaF = [parameters](args){body}; auto lambdaF =[](const auto & val){cout<<val<<"\n";};
list std::tuple<T1,T2,T3> tuple(a,b,c);
- get std::get<index>(tuple);
- auto [ a, b c, ] = typle. Automatically a,b c is a automatically a type
list std::variant<T1,T2,T3> var(a,b,c);
- get std::get<index>(var);
- get std::get<T1>(var);
- get std::get_if<T1>(&var);
- auto [ a, b c, ] = typle. Automatically a,b c is a automatically a type
For testing the template attributes it is possible to use:
For primary types:
- template <class T> struct is_void;
- template <class T> struct is_null_pointer;
- template <class T> struct is_integral;
- template <class T> struct is_floating_point;
- template <class T> struct is_array;
- template <class T> struct is_pointer;
- template <class T> struct is_lvalue_reference;
- template <class T> struct is_rvalue_reference;
- template <class T> struct is_member_object_pointer;
- template <class T> struct is_member_function_pointer;
- template <class T> struct is_enum;
- template <class T> struct is_union;
- template <class T> struct is_class;
- template <class T> struct is_function;
For categories types:
- template <class T> struct is_reference;
- template <class T> struct is_arithmetic;
- template <class T> struct is_fundamental;
- template <class T> struct is_object;
- template <class T> struct is_scalar;
- template <class T> struct is_compound;
- template <class T> struct is_member_pointer;
For properties type:
- template <class T> struct is_const;
- template <class T> struct is_volatile;
- template <class T> struct is_trivial;
- template <class T> struct is_trivially_copyable;
- template <class T> struct is_standard_layout;
- template <class T> struct is_pod;
- template <class T> struct is_literal_type;
- template <class T> struct is_empty;
- template <class T> struct is_polymorphic;
- template <class T> struct is_abstract;
- template <class T> struct is_signed;
- template <class T> struct is_unsigned;
- template <class T, class... Args> struct is_constructible;
- template <class T> struct is_default_constructible;
- template <class T> struct is_copy_constructible;
- template <class T> struct is_move_constructible;
- template <class T, class U> struct is_assignable;
- template <class T> struct is_copy_assignable;
- template <class T> struct is_move_assignable;
- template <class T> struct is_destructible;
- template <class T, class... Args> struct is_trivially_constructible;
- template <class T> struct is_trivially_default_constructible;
- template <class T> struct is_trivially_copy_constructible;
- template <class T> struct is_trivially_move_constructible;
- template <class T, class U> struct is_trivially_assignable;
- template <class T> struct is_trivially_copy_assignable;
- template <class T> struct is_trivially_move_assignable;
- template <class T> struct is_trivially_destructible;
- template <class T, class... Args> struct is_nothrow_constructible;
- template <class T> struct is_nothrow_default_constructible;
- template <class T> struct is_nothrow_copy_constructible;
- template <class T> struct is_nothrow_move_constructible;
- template <class T, class U> struct is_nothrow_assignable;
- template <class T> struct is_nothrow_copy_assignable;
- template <class T> struct is_nothrow_move_assignable;
- template <class T> struct is_nothrow_destructible;
- template <class T> struct has_virtual_destructor;
For relations type:
- template <class T, class U> struct is_same;
- template <class Base, class Derived> struct is_base_of;
- template <class From, class To> struct is_convertible;
- Note
- { In debug mode, a list of classes in memory is maintened in order to be sure that at end of running all the class is destroyed ie the list is empty. This list is maintained by the CORE_Class in core package which is a base class of all the classes of the program. }
The organization of this package is as follow: