Elements
6.2
A C++ base framework for the Euclid Software.
|
Core CMake, C++ and Python utilities. More...
Namespaces | |
Elements | |
Classes | |
class | BoostTestAdapter |
class | GoogleMockSetupFixture |
class | Elements::Environment::Variable |
proxy class to overload the assignment More... | |
class | Elements::Environment |
Python dictionary-like Environment interface. More... | |
class | Elements::Exception |
Elements base exception class. More... | |
class | Elements::Logging |
Logging API of the Elements framework. More... | |
class | Elements::Program |
Abstract class for all Elements programs. More... | |
class | Elements::ProgramManager |
Class for managing all Elements programs. More... | |
Enumerations | |
enum | Elements::ExitCode : int { Elements::ExitCode::OK = 0, Elements::ExitCode::NOT_OK = 1, Elements::ExitCode::USAGE = 64, Elements::ExitCode::DATAERR = 65, Elements::ExitCode::NOINPUT = 66, Elements::ExitCode::NOUSER = 67, Elements::ExitCode::NOHOST = 68, Elements::ExitCode::UNAVAILABLE = 69, Elements::ExitCode::SOFTWARE = 70, Elements::ExitCode::OSERR = 71, Elements::ExitCode::OSFILE = 72, Elements::ExitCode::CANTCREAT = 73, Elements::ExitCode::IOERR = 74, Elements::ExitCode::TEMPFAIL = 75, Elements::ExitCode::PROTOCOL = 76, Elements::ExitCode::NOPERM = 77, Elements::ExitCode::CONFIG = 78 } |
Strongly typed exit numbers. More... | |
Functions | |
ELEMENTS_API std::string | Elements::Kernel::getAuxiliaryVariableName () |
retrieve the variable name used for the auxiliary file lookup More... | |
ELEMENTS_API std::string | Elements::Kernel::Auxiliary::getVariableName () |
alias for the getAuxiliaryVariableName function More... | |
template<typename T > | |
ELEMENTS_API Path::Item | Elements::Kernel::Auxiliary::getPath (const T &file_name, bool raise_exception=true) |
alias for the getAuxiliaryPath function More... | |
ELEMENTS_API std::vector< Path::Item > | Elements::Kernel::Auxiliary::getLocations (bool exist_only=false) |
alias for the getAuxiliaryLocations function More... | |
ELEMENTS_API std::string | Elements::Kernel::getConfigurationVariableName () |
retrieve the variable name used for the configuration file lookup More... | |
ELEMENTS_API std::string | Elements::Kernel::Configuration::getVariableName () |
alias for the getAuxiliaryVariableName function More... | |
template<typename T > | |
ELEMENTS_API Path::Item | Elements::Kernel::Configuration::getPath (const T &file_name, bool raise_exception=true) |
alias for the getAuxiliaryPath function More... | |
ELEMENTS_API std::vector< Path::Item > | Elements::Kernel::Configuration::getLocations (bool exist_only=false) |
alias for the getConfigurationLocations function More... | |
static void | Elements::Environment::checkOutOfRange (const std::string &) |
check that the variable is in the environment More... | |
template<typename DESTPTR , typename SRCPTR > | |
DESTPTR | Elements::System::FuncPtrCast (SRCPTR ptr) |
Cast from void * to function pointer. More... | |
template<typename TargetType , typename SourceType > | |
ELEMENTS_API TargetType | Elements::numberCast (const SourceType &s) |
this function is a number cast. It behaves exactly as a static_cast except when casting from a floating point number to an integral one. This one is doing the correct rounding. More... | |
ELEMENTS_API std::vector< Item > | Elements::Kernel::Path::getLocationsFromEnv (const std::string &path_variable, bool exist_only=false) |
function to get the locations from an environment variable More... | |
ELEMENTS_API std::vector< Item > | Elements::Kernel::Path::getLocations (const Type &path_type, bool exist_only=false) |
function to get the locations for the specific type More... | |
template<typename T , typename U > | |
ELEMENTS_API Item | Elements::Kernel::Path::getPathFromLocations (const T &file_name, const std::vector< U > &locations) |
retrieve path from a file name and a set of location to look into More... | |
template<typename T , typename U > | |
ELEMENTS_API std::vector< Item > | Elements::Kernel::Path::getAllPathFromLocations (const T &file_name, const std::vector< U > &locations) |
retrieve all the paths from a file name and a set of location to look into More... | |
template<typename T > | |
ELEMENTS_API Item | Elements::Kernel::Path::getPathFromEnvVariable (const T &file_name, const std::string &path_variable) |
retrieve path from a file name and an environment variable to look into More... | |
template<typename T > | |
ELEMENTS_API std::string | Elements::Kernel::Path::joinPath (const std::vector< T > &path_list) |
collate a vector of path into a string using PATH_SEP More... | |
template<typename... Args> | |
ELEMENTS_API auto | Elements::Kernel::Path::join (Args &&... args) -> decltype(joinPath(std::forward< Args >(args)...)) |
alias for the joinPath function More... | |
ELEMENTS_API std::vector< Item > | Elements::Kernel::Path::splitPath (const std::string &path_string) |
split a string into a vector of path using PATH_SEP More... | |
template<typename... Args> | |
ELEMENTS_API auto | Elements::Kernel::Path::split (Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...)) |
alias for the splitPath function More... | |
template<typename T , typename U > | |
ELEMENTS_API std::vector< Item > | Elements::Kernel::Path::multiPathAppend (const std::vector< T > &initial_locations, const std::vector< U > &suffixes) |
path join each suffix to each initial locations More... | |
template<typename T > | |
ELEMENTS_API std::vector< Item > | Elements::Kernel::Path::removeDuplicates (const std::vector< T > &path_list) |
remove duplicated paths keeping the order More... | |
template<typename T > | |
ELEMENTS_API std::vector< T > | Elements::Kernel::pathSearch (const std::string &searched_name, T directory, SearchType search_type) |
Searches for a file or a directory in a directory. The search can be recursive (SearchType.Recursive) and in that case more than one results can be return. More... | |
static const ModuleInfo & | Elements::System::getThisModuleInfo () |
function to retrieve the current module More... | |
constexpr std::uint_least64_t | CALC_PROJECT_VERSION (const std::uint_least64_t maj, const std::uint_least64_t min, const std::uint_least64_t pat) |
Mangle major, minor and patch version number into a single integer. More... | |
ELEMENTS_API std::string | Elements::getVersionFromSvnKeywords (const std::string &svnUrl, const std::string &svnId) |
Function returning a version string extracted from SVN keywords. More... | |
ELEMENTS_API std::string | Elements::getVersionString (const unsigned short major, const unsigned short minor, const unsigned short patch=0) |
Function converting the version numbers into a string. More... | |
Variables | |
const ELEMENTS_API std::string | Elements::Kernel::Path::PATH_SEP {":"} |
Separator of path entries. Usually ":" on Unix. More... | |
const ELEMENTS_API std::map< Type, const std::string > | Elements::Kernel::Path::VARIABLE |
map containing the name of the path variable for each type More... | |
const ELEMENTS_API std::map< Type, const std::vector< std::string > > | Elements::Kernel::Path::SUFFIXES |
map containing the default project installation suffixes for each variable More... | |
const ELEMENTS_API std::map< Type, const std::vector< std::string > > | Elements::Kernel::Path::DEFAULT_LOCATIONS |
map containing the default external locations for each variable More... | |
const ELEMENTS_API std::map< Type, const bool > | Elements::Kernel::Path::HAS_SUBLEVELS |
map containing the sub-level property of the path components More... | |
Core CMake, C++ and Python utilities.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#define __attribute__ | ( | x | ) |
Definition at line 32 of file Attribute.h.
#define _str | ( | s | ) | #s |
Macro to convert a preprocessor constant into a string.
Definition at line 40 of file Stringify.h.
#define _xstr | ( | s | ) | str(s) |
helper macro
Definition at line 34 of file Stringify.h.
#define CREATE_MANAGER | ( | ELEMENTS_PROGRAM_NAME, | |
MANAGER | |||
) | CREATE_MANAGER_WITH_ARGS(MANAGER, ELEMENTS_PROGRAM_NAME, ) |
Macro that declares a program manager with all the needed arguments. It is typically called from the MAIN_FOR(ELEMENTS_PROGRAM_NAME, MANAGER) macro.
ELEMENTS_PROGRAM_NAME | name of the main program class, derived from the class Elements::Program class. |
MANAGER | name of the manager variable to be created. |
#define CREATE_MANAGER_WITH_ARGS | ( | MANAGER, | |
ELEMENTS_PROGRAM, | |||
... | |||
) |
Macro that declares a program manager with custom constructor arguments. It is typically called from the MAIN_FOR(ELEMENTS_PROGRAM_NAME, MANAGER) macro.
ELEMENTS_PROGRAM | call of the main program constructor, derived from the class Elements::Program class. |
MANAGER | name of the manager variable to be created. |
#define ELEMENTS_API |
#define ELEMENTS_DEPRECATED __attribute__((__deprecated__)) |
This macro create a warning message for a deprecated function or class
Definition at line 35 of file Deprecated.h.
#define ELEMENTS_DEPRECATED_MSG | ( | msg | ) | __attribute__((__deprecated__(msg))) |
This macro create a warning message for a deprecated function or class This version takes a msg as argument. This message will be displayed together with the deprecation warning.
Definition at line 44 of file Deprecated.h.
#define ELEMENTS_UNUSED __attribute__((unused)) |
This macro is there to
#define ELEMENTSKERNEL_ELEMENTSKERNEL_AUXILIARY_IMPL_ |
Definition at line 104 of file Auxiliary.h.
#define ELEMENTSKERNEL_ELEMENTSKERNEL_CONFIGURATION_IMPL_ |
Definition at line 100 of file Configuration.h.
#define ELEMENTSKERNEL_ELEMENTSKERNEL_PATHSEARCH_IMPL_ |
Definition at line 90 of file PathSearch.h.
#define LIKELY | ( | x | ) | x |
#define MAIN | ( | ELEMENTS_PROGRAM | ) |
Macro which must be used to create a main in classes that derived from Elements::SimpleProgram, i.e., these derived classes must end with the following line:
.
ELEMENTS_PROGRAM | name of the main program class, derived from the class Elements::SimpleProgram class. |
Definition at line 79 of file SimpleProgram.h.
#define MAIN_FOR | ( | ELEMENTS_PROGRAM_NAME | ) | MAIN_FOR_WITH_ARGS(ELEMENTS_PROGRAM_NAME, ) |
Macro which must be used to create a main in classes that derived from Elements::Program, i.e., these derived classes must end with the following line:
The macro is equipped with a set_terminate placed just before the main function definition:
That handler will do a smooth catching of any exception raised in the run part of the program and call std::abort().
ELEMENTS_PROGRAM_NAME | name of the main program class, derived from the class Elements::Program class. |
#define MAIN_FOR_WITH_ARGS | ( | ELEMENTS_PROGRAM, | |
... | |||
) |
Macro which must be used to create a main in classes that derived from Elements::Program, i.e., these derived classes must end with the following line:
. The macro is equiped with a set_terminate placed just before the main function definition:
That handler will do a smooth catching of any exception raised in the run part of the program and call std::abort(). This version allows the passing of the Elements::Program constructor arguments
ELEMENTS_PROGRAM | name of the main program class, derived from the class Elements::Program class. |
#define UNLIKELY | ( | x | ) | x |
|
strong |
Strongly typed exit numbers.
This has to be used with the MAIN_FOR macro There is no clear universal specification for exit codes. Every system has more or less its convention. Please have a look at http://en.wikipedia.org/wiki/Exit_status. These exit codes do exist for this very documentation. They allow a minimal communication with the batch framework. This gives a clear answer to the caller without the need of parsing the output of the executable. Notes:
|
constexpr |
|
staticprivate |
check that the variable is in the environment
Definition at line 286 of file Environment.cpp.
References Elements::Environment::hasKey(), and std::stringstream::str().
Referenced by Elements::Environment::unSet().
|
inline |
Cast from void * to function pointer.
Small helper function that allows the cast from void * to function pointer and vice versa without the message
* warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object *
It is an ugly trick but works. See:
ptr | pointer address to convert |
SRCPTR | source pointer type |
DESTPTR | destination pointer type |
Definition at line 55 of file FuncPtrCast.h.
ELEMENTS_API std::vector<Item> Elements::Kernel::Path::getAllPathFromLocations | ( | const T & | file_name, |
const std::vector< U > & | locations | ||
) |
retrieve all the paths from a file name and a set of location to look into
file_name | file name to look for. Can be of the form "Some.txt" or "Place/Some.txt" |
locations | vector of locations to look into |
T | type of the file name. Can be anything that can be converted to a boost filesystem path. In principle either std::string or path. |
U | type of the location. Can be anything that can be converted to a boost filesystem path. In principle either std::string or path. |
string Elements::Kernel::getAuxiliaryVariableName | ( | ) |
retrieve the variable name used for the auxiliary file lookup
Definition at line 41 of file Auxiliary.cpp.
References Elements::Kernel::Path::auxiliary, and Elements::Kernel::Path::VARIABLE.
Referenced by Elements::Kernel::Auxiliary::getVariableName().
string Elements::Kernel::getConfigurationVariableName | ( | ) |
retrieve the variable name used for the configuration file lookup
Definition at line 41 of file Configuration.cpp.
References Elements::Kernel::Path::configuration, and Elements::Kernel::Path::VARIABLE.
Referenced by Elements::Kernel::Configuration::getVariableName().
std::vector< Path::Item > Elements::Kernel::Configuration::getLocations | ( | bool | exist_only = false | ) |
alias for the getConfigurationLocations function
Definition at line 76 of file Configuration.cpp.
References Elements::Kernel::getConfigurationLocations().
std::vector< Path::Item > Elements::Kernel::Auxiliary::getLocations | ( | bool | exist_only = false | ) |
alias for the getAuxiliaryLocations function
Definition at line 80 of file Auxiliary.cpp.
References Elements::Kernel::getAuxiliaryLocations().
vector< Item > Elements::Kernel::Path::getLocations | ( | const Type & | path_type, |
bool | exist_only = false |
||
) |
function to get the locations for the specific type
This function return the raw locations for the given type. It doesn't add the internal locations which are not in the variable (like /usr/lib for the library type)
path_type | type of the path |
exist_only | if true returns only existing locations. by default it is set to false. |
Definition at line 88 of file Path.cpp.
References Elements::Kernel::Path::getLocationsFromEnv(), and Elements::Kernel::Path::VARIABLE.
Referenced by Elements::Kernel::getAuxiliaryLocations(), and Elements::Kernel::getConfigurationLocations().
vector< Item > Elements::Kernel::Path::getLocationsFromEnv | ( | const std::string & | path_variable, |
bool | exist_only = false |
||
) |
function to get the locations from an environment variable
This function return the raw locations pointed by the environment variable. It doesn't add the internal locations which are not in the variable (like /usr/lib for the LD_LIBRARY_PATH environment variable)
path_variable | name of the environment variable |
exist_only | if true returns only existing locations. by default it is set to false. |
Definition at line 70 of file Path.cpp.
References std::vector< T >::begin(), std::vector< T >::end(), std::vector< T >::erase(), std::remove_if(), and Elements::Kernel::Path::split().
Referenced by Elements::Kernel::Path::getLocations().
ELEMENTS_API Path::Item Elements::Kernel::Auxiliary::getPath | ( | const T & | file_name, |
bool | raise_exception = true |
||
) |
alias for the getAuxiliaryPath function
file_name | file name of the auxiliary file to be found. |
raise_exception | enable the raising of an exception if the file is not found |
Referenced by Elements::Services::DataSync::confFilePath(), and Elements::Examples::CCfits::mainMethod().
ELEMENTS_API Path::Item Elements::Kernel::Configuration::getPath | ( | const T & | file_name, |
bool | raise_exception = true |
||
) |
alias for the getAuxiliaryPath function
file_name | file name of the configuration file to be found. |
raise_exception | enable the raising of an exception if the file is not found |
ELEMENTS_API Item Elements::Kernel::Path::getPathFromEnvVariable | ( | const T & | file_name, |
const std::string & | path_variable | ||
) |
retrieve path from a file name and an environment variable to look into
file_name | file name to look for. Can be of the form "Some.txt" or "Place/Some.txt" |
path_variable | name of the environment variable |
T | type of the file name. Can be anything that can be converted to a boost filesystem path. In principle either std::string or path. |
ELEMENTS_API Item Elements::Kernel::Path::getPathFromLocations | ( | const T & | file_name, |
const std::vector< U > & | locations | ||
) |
retrieve path from a file name and a set of location to look into
file_name | file name to look for. Can be of the form "Some.txt" or "Place/Some.txt" |
locations | vector of locations to look into |
T | type of the file name. Can be anything that can be converted to a boost filesystem path. In principle either std::string or path. |
U | type of the location. Can be anything that can be converted to a boost filesystem path. In principle either std::string or path. |
|
inlinestatic |
function to retrieve the current module
It has to be included in the target source and compiled within the module to be identified.
Definition at line 41 of file ThisModule.h.
References Elements::System::ModuleInfo::isEmpty().
Referenced by Elements::Examples::getModuleInfo().
string Elements::Kernel::Configuration::getVariableName | ( | ) |
alias for the getAuxiliaryVariableName function
Definition at line 68 of file Configuration.cpp.
References Elements::Kernel::getConfigurationVariableName().
string Elements::Kernel::Auxiliary::getVariableName | ( | ) |
alias for the getAuxiliaryVariableName function
Definition at line 72 of file Auxiliary.cpp.
References Elements::Kernel::getAuxiliaryVariableName().
string Elements::getVersionFromSvnKeywords | ( | const std::string & | svnUrl, |
const std::string & | svnId | ||
) |
Function returning a version string extracted from SVN keywords.
ElementsExample/src/program/Program.cpp shows how to use this method to implement a getVersion in a prgram
svnUrl | This is a string that can be filled with the HeadURL svn keywords. Writing #define SVN_URL "SVN $HeadURL$ in a file. |
svnId | This is a string that can be filled with the Id svn keywords. Writing #define SVN_ID "SVN $Id$ in a file. |
the svn keywords will be expanded upon the next commit if the svn client is instructed to do this with svn propset svn:keywords 'Id Revision HeadURL' Program.cpp
Definition at line 34 of file Version.cpp.
References Elements::Kernel::Path::split().
string Elements::getVersionString | ( | const unsigned short | major, |
const unsigned short | minor, | ||
const unsigned short | patch = 0 |
||
) |
Function converting the version numbers into a string.
This function return either 2 numbers separated with a "." if the patch number is zero. Or 3 numbers separated with a "." if the patch is not zero.
major | Major version number |
minor | Minor version number |
patch | Patch version number |
Definition at line 67 of file Version.cpp.
References std::to_string().
ELEMENTS_API auto Elements::Kernel::Path::join | ( | Args &&... | args | ) | -> decltype(joinPath(std::forward< Args >(args)...)) |
alias for the joinPath function
args | Forward arguments |
ELEMENTS_API std::string Elements::Kernel::Path::joinPath | ( | const std::vector< T > & | path_list | ) |
collate a vector of path into a string using PATH_SEP
path_list | list of path to be joined. |
Referenced by Elements::ProgramManager::bootstrapEnvironment().
ELEMENTS_API std::vector<Item> Elements::Kernel::Path::multiPathAppend | ( | const std::vector< T > & | initial_locations, |
const std::vector< U > & | suffixes | ||
) |
path join each suffix to each initial locations
initial_locations | list of initial locations. |
suffixes | list of suffixes |
Referenced by Elements::ProgramManager::bootstrapEnvironment().
ELEMENTS_API TargetType Elements::numberCast | ( | const SourceType & | s | ) |
this function is a number cast. It behaves exactly as a static_cast except when casting from a floating point number to an integral one. This one is doing the correct rounding.
s | number to cast |
Definition at line 48 of file Number.h.
References std::round(), and Elements::Kernel::Units::s.
ELEMENTS_API std::vector<T> Elements::Kernel::pathSearch | ( | const std::string & | searched_name, |
T | directory, | ||
SearchType | search_type | ||
) |
Searches for a file or a directory in a directory. The search can be recursive (SearchType.Recursive) and in that case more than one results can be return.
searched_name | Name of the searched file or directory |
T | input type string or Boost path of the directory in which the search is carried out |
directory | The directory where the search is performed. |
search_type | Two options: SearchType.Local search in directory only SearchType.Recursive search in sub-directories too |
Referenced by Elements::Kernel::pathSearchInEnvVariable().
ELEMENTS_API std::vector<Item> Elements::Kernel::Path::removeDuplicates | ( | const std::vector< T > & | path_list | ) |
remove duplicated paths keeping the order
path_list | list of path to uniquify. |
ELEMENTS_API auto Elements::Kernel::Path::split | ( | Args &&... | args | ) | -> decltype(splitPath(std::forward< Args >(args)...)) |
alias for the splitPath function
args | Forward arguments |
Referenced by Elements::Kernel::Path::getLocationsFromEnv(), Elements::getVersionFromSvnKeywords(), Elements::Kernel::pathSearchInEnvVariable(), and Elements::Kernel::Path::splitPath().
vector< Item > Elements::Kernel::Path::splitPath | ( | const std::string & | path_string | ) |
split a string into a vector of path using PATH_SEP
path_string | string containing a list of path separated by PATH_SEP |
Definition at line 92 of file Path.cpp.
References std::vector< T >::begin(), std::vector< T >::cbegin(), std::vector< T >::cend(), Elements::Kernel::Path::PATH_SEP, Elements::Kernel::Units::s, std::vector< T >::size(), Elements::Kernel::Path::split(), and std::transform().
map containing the default external locations for each variable
const string Elements::Kernel::Path::PATH_SEP {":"} |
Separator of path entries. Usually ":" on Unix.
Definition at line 44 of file Path.cpp.
Referenced by Elements::ProgramManager::bootstrapEnvironment(), and Elements::Kernel::Path::splitPath().
map containing the default project installation suffixes for each variable
Definition at line 52 of file Path.cpp.
Referenced by Elements::ProgramManager::bootstrapEnvironment().
map containing the name of the path variable for each type
Definition at line 46 of file Path.cpp.
Referenced by Elements::ProgramManager::bootstrapEnvironment(), Elements::Kernel::getAuxiliaryVariableName(), Elements::Kernel::getConfigurationVariableName(), Elements::Kernel::Path::getLocations(), and Elements::ProgramManager::logTheEnvironment().