ug4
Common Utilities

further general utilities More...

Modules

 String Utilities
 
 Common IO
 
 Common Types
 

Classes

struct  ug::BinomialCoefficient< n, k >
 
struct  ug::BinomialCoefficient< n, 0 >
 
struct  ug::BinomialCoefficient< n,-1 >
 
struct  ug::BinomialCoefficient< n,-2 >
 
struct  ug::BinomialCoefficient< n,-3 >
 
struct  ug::BinomialCoefficient< n,-4 >
 
class  CompareIndicesByClass< TCompareValues, bReverse >
 
class  CompareIndicesByClass2< TCompareValues, TCompare >
 
class  ConstSmartPtr< T, FreePolicy >
 
struct  ug::EmptyType
 
struct  ug::Factorial< n >
 
struct  ug::Factorial< 1 >
 
class  FreeArrayDelete< T >
 
class  FreeDelete< T >
 
class  FreeRelease< T >
 
struct  ug::Int2Type< N >
 
class  ug::LoaderObj
 
class  ug::MessageHub
 Allows to register callbacks and post messages to those callbacks. More...
 
class  NullSmartPtr
 Used to construct empty smart pointers. More...
 
class  ug::OwnedPtr< T >
 Holds and automatically deletes a pointer, similar to std::auto_ptr. USE WITH CARE! More...
 
class  ug::PathProvider
 Singleton which stores common paths and a stack of current paths. More...
 
struct  ug::Pointer2Value< T >
 
struct  ug::Pointer2Value< T * >
 
class  ug::PointerConstArray< TPtr >
 Container which holds an array of pointers. More...
 
struct  ug::Pow< n, d >
 
struct  ug::Pow< n, 0 >
 
class  ug::Provider< TClass >
 Provider, holding a single instance of an object. More...
 
class  ug::SectionContainer< TValue, TContainer >
 A container that is divided into different sections. More...
 
class  SmartPtr< T, FreePolicy >
 
struct  SortStruct< TIndex, TValue >
 
struct  ug::TypeList< T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >
 
struct  ug::TypeList< EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType, EmptyType >
 
struct  ug::TypeValueList< TTypeList >
 
struct  ug::TypeValueList< TypeList<> >
 
class  ug::UID
 supplies a unique ID. More...
 
class  ug::UniqueTypeIDProvider
 a singleton class that returns a new id for each type More...
 

Typedefs

typedef void * ug::DynLibHandle
 Defines a reference to a dynamically loaded library. More...
 
typedef SmartPtr< MessageHubug::SPMessageHub
 

Enumerations

enum  ug::PathTypes {
  ug::BIN_PATH = 0 , ug::SCRIPT_PATH , ug::ROOT_PATH , ug::PLUGIN_PATH ,
  ug::APPS_PATH , ug::MAX_PATH_CONSTANT
}
 Constants used by PathProvider. More...
 

Functions

bool boolstrcmp (const char *a, const char *b)
 
bool boolstrcmpReversed (const char *a, const char *b)
 
bool ug::CloseLibrary (DynLibHandle h)
 Frees a library. More...
 
template<typename TCompareValues >
CompareIndicesByClass< TCompareValues, false > CompareIndicesBy (const TCompareValues &values)
 
template<typename TCompareValues , typename TCompare >
CompareIndicesByClass2< TCompareValues, TCompare > CompareIndicesBy (const TCompareValues &values, TCompare comp)
 
template<typename TCompareValues >
CompareIndicesByClass< TCompareValues, true > CompareIndicesReversedBy (const TCompareValues &values)
 
uint32 ug::crc32 (const char *str)
 Calculates the crc32 for a null-terminated string. More...
 
bool ug::FindParam (const char *param, int argc, const char *const *argv)
 
template<typename TTarget , typename TSrc >
TTarget function_cast (TSrc src)
 Casts a function of one type to a function of another type. More...
 
const char * ug::GetDynamicLibraryPrefix ()
 returns the standard prefix of static and dynamic libraries on this os More...
 
const char * ug::GetDynamicLibrarySuffix ()
 returns the standard suffix of dynamic libraries on this os More...
 
void * ug::GetLibraryProcedure (DynLibHandle h, const char *procName)
 Returns the address of the specified procedure in the given library. More...
 
UG_API std::vector< std::string > ug::GetLoadedPlugins ()
 
int ug::GetParamIndex (const char *param, int argc, const char *const *argv)
 
const char * ug::GetPathSeparator ()
 returns a string containing the path-separator for the current os More...
 
template<typename TCompareValues >
std::vector< size_t > GetSortedIndices (const TCompareValues &values)
 
template<typename TCompareValues , typename TCompare >
std::vector< size_t > GetSortedIndices (const TCompareValues &values, TCompare comp)
 
template<typename TCompareValues >
void GetSortedIndices (std::vector< size_t > &indices, const TCompareValues &values, bool bReverse=false)
 
template<typename TCompareValues , typename TCompare >
void GetSortedIndices (std::vector< size_t > &indices, const TCompareValues &values, TCompare comp)
 
template<class TType >
size_t ug::GetUniqueTypeID ()
 This method associated a unique unsigned integer value with each type. More...
 
bool ug::IsBigEndian ()
 
bool ug::IsLittleEndian ()
 
UG_API bool ug::LoadPlugins (const char *pluginPath, std::string parentGroup, bridge::Registry &reg, bool bPrefixGroup=false)
 Loads all plugins in the given path. More...
 
DynLibHandle ug::OpenLibrary (const char *fileName)
 Loads a library and returns a handle. More...
 
double ug::ParamToDouble (const char *param, int argc, const char *const *argv, double dDefault)
 
bool ug::ParamToDouble (double &dOut, const char *param, int argc, const char *const *argv)
 
int ug::ParamToInt (const char *param, int argc, const char *const *argv, int iDefault)
 
bool ug::ParamToInt (int &iOut, const char *param, int argc, const char *const *argv)
 
bool ug::ParamToString (const char **strOut, const char *param, int argc, const char *const *argv)
 
UG_API bool ug::PluginLoaded (const std::string &name)
 
void ug::split_parameters (std::vector< std::string > &paramsOut, char *strParams, const char *delims=" ")
 fills paramsOut with the parameters that are seperated by the characters given in delim. More...
 
UG_API bool ug::UnloadPlugins ()
 

Variables

const NullSmartPtr SPNULL
 The equivalent to NULL for smart pointers. More...
 
template<typename TKey >
size_t ug::hash_key (const TKey &key)
 The hashing method can be specialized for different types. More...
 
template<class T >
T * ug::GetDataPtr (std::vector< T > &v)
 Returns a pointer to the array which is managed by the std::vector. More...
 
template<class T >
const T * ug::GetDataPtr (const std::vector< T > &v)
 Returns a pointer to the array which is managed by the std::vector. More...
 

Detailed Description

further general utilities

An associative container for key-value pairs, which provides fast access using hash-keys.

Typedef Documentation

◆ DynLibHandle

typedef void* ug::DynLibHandle

Defines a reference to a dynamically loaded library.

◆ SPMessageHub

Enumeration Type Documentation

◆ PathTypes

Constants used by PathProvider.

Enumerator
BIN_PATH 

path in which the binary lies

SCRIPT_PATH 
ROOT_PATH 
PLUGIN_PATH 
APPS_PATH 

path in which the application-scripts lie

MAX_PATH_CONSTANT 

Function Documentation

◆ boolstrcmp()

bool boolstrcmp ( const char *  a,
const char *  b 
)
inline

◆ boolstrcmpReversed()

bool boolstrcmpReversed ( const char *  a,
const char *  b 
)
inline

◆ CloseLibrary()

bool ug::CloseLibrary ( DynLibHandle  h)

Frees a library.

The method returns true if the operation was successful, false if not.

See also
OpenLibrary, GetLibraryProcedure

Referenced by ug::LoadPlugins(), ug::UnloadPlugins(), and ug::bridge::LUACompiler::~LUACompiler().

◆ CompareIndicesBy() [1/2]

template<typename TCompareValues >
CompareIndicesByClass<TCompareValues, false> CompareIndicesBy ( const TCompareValues &  values)
inline

Allows sorting of indices by their values in another array. example: int v[] = {1, 3, 2}; int pivot[] = {5, 2, 3, 1}; sort(v, v+3, CompareIndicesBy(pivot)); for(size_t i=0; i<3; i++) cout << v[i] << " = " << pivot[v[i]] << endl;

Referenced by ug::ParallelNodes::sort_by_global_id().

◆ CompareIndicesBy() [2/2]

template<typename TCompareValues , typename TCompare >
CompareIndicesByClass2<TCompareValues, TCompare> CompareIndicesBy ( const TCompareValues &  values,
TCompare  comp 
)
inline

Allows sorting of indices by their values in another array with a comp function

◆ CompareIndicesReversedBy()

template<typename TCompareValues >
CompareIndicesByClass<TCompareValues, true> CompareIndicesReversedBy ( const TCompareValues &  values)
inline

◆ crc32()

◆ FindParam()

UG_API bool ug::FindParam ( const char *  param,
int  argc,
const char *const *  argv 
)

searches argv for the given parameter and returns true if it is found.

References ug::GetParamIndex().

Referenced by ugshell_main().

◆ function_cast()

template<typename TTarget , typename TSrc >
TTarget function_cast ( TSrc  src)

Casts a function of one type to a function of another type.

ATTENTION: Use with care! This method should only be used on functions which have similar parameters, and where different parameters in TTarget and TSrc are pointers or references to types which are connected through inheritance.

The main purpose of this method is to make code readable and to allow more secure compiler dependent implementations.

Remarks
The cast is currently performed through a c-style cast, since a static_cast or reinterpret_cast for the described purpose is not raises a compile error in Microsoft Visual Studio 2010.

◆ GetDataPtr() [1/2]

template<class T >
const T* ug::GetDataPtr ( const std::vector< T > &  v)

Returns a pointer to the array which is managed by the std::vector.

Note that this pointer may be invalidated once new elements are added to the vector or old ones are removed.

The method returns NULL if the vector is empty.

◆ GetDataPtr() [2/2]

template<class T >
T* ug::GetDataPtr ( std::vector< T > &  v)

Returns a pointer to the array which is managed by the std::vector.

Note that this pointer may be invalidated once new elements are added to the vector or old ones are removed.

The method returns NULL if the vector is empty.

Referenced by pcl::ProcessCommunicator::allgatherv(), ug::BinaryBuffer::buffer(), ug::BinaryStreamBuffer::buffer(), pcl::CommunicateInvolvedProcesses(), pcl::ProcessCommunicator::distribute_data(), ug::DistributeGrid(), pcl::ProcessCommunicator::gatherv(), and ug::ExpectedErrorMarkingStrategy< TDomain >::mark().

◆ GetDynamicLibraryPrefix()

UG_API const char * ug::GetDynamicLibraryPrefix ( )

returns the standard prefix of static and dynamic libraries on this os

Referenced by ug::LoadPlugins().

◆ GetDynamicLibrarySuffix()

UG_API const char * ug::GetDynamicLibrarySuffix ( )

returns the standard suffix of dynamic libraries on this os

Referenced by ug::LoadPlugins().

◆ GetLibraryProcedure()

void * ug::GetLibraryProcedure ( DynLibHandle  h,
const char *  procName 
)

Returns the address of the specified procedure in the given library.

If no procedure with the given name was found, NULL is returned.

See also
OpenLibrary, CloseLibrary

Referenced by ug::bridge::LUACompiler::createC(), ug::LoadPlugins(), and ug::UnloadPlugins().

◆ GetLoadedPlugins()

vector< string > ug::GetLoadedPlugins ( )

◆ GetParamIndex()

UG_API int ug::GetParamIndex ( const char *  param,
int  argc,
const char *const *  argv 
)

searches argv for the given parameter and returns its position in argv. If the parameter is not contained in argv, -1 is returned.

Referenced by ug::FindParam(), ug::ParamToDouble(), ug::ParamToInt(), ug::ParamToString(), ugshell_get_call_command(), and ugshell_main().

◆ GetPathSeparator()

◆ GetSortedIndices() [1/4]

template<typename TCompareValues >
std::vector<size_t> GetSortedIndices ( const TCompareValues &  values)

References GetSortedIndices().

◆ GetSortedIndices() [2/4]

template<typename TCompareValues , typename TCompare >
std::vector<size_t> GetSortedIndices ( const TCompareValues &  values,
TCompare  comp 
)

References GetSortedIndices().

◆ GetSortedIndices() [3/4]

template<typename TCompareValues >
void GetSortedIndices ( std::vector< size_t > &  indices,
const TCompareValues &  values,
bool  bReverse = false 
)

example: std::vector<size_t> v; // = { 45, 3, 6, 4, 9}; ind = GetSortedIndices(ind, v); then v[ ind[0] ] <= v[ ind[1] ] <= ... <= v [ ind[v.size() -1] ]; , and here ind = 1, 3, 2, 4, 0, because e.g. v[ind[0]] = v[1] = 3.

Parameters
valuesarray where indices should be sorted after
Returns
the indices list sorted with respect to the ordering in values

Referenced by GetSortedIndices().

◆ GetSortedIndices() [4/4]

template<typename TCompareValues , typename TCompare >
void GetSortedIndices ( std::vector< size_t > &  indices,
const TCompareValues &  values,
TCompare  comp 
)

example: std::vector<const char*> v; // some strings GetSortedIndices(ind, v, boolstrcmp); then v[ ind[0] ] <= v[ ind[1] ] <= ... <= v [ ind[v.size() -1] ]; ,

Parameters
indicesarray with indices
valuesarray where indices should be sorted after
compcompare function

◆ GetUniqueTypeID()

template<class TType >
size_t ug::GetUniqueTypeID ( )

This method associated a unique unsigned integer value with each type.

References ug::UniqueTypeIDProvider::inst(), and ug::UniqueTypeIDProvider::new_id().

Referenced by ug::bridge::ExportedClassBaseImpl::get_json_constructor().

◆ hash_key()

template<typename TKey >
size_t ug::hash_key ( const TKey &  key)

The hashing method can be specialized for different types.

A default implementation exists, which casts each key to a unsigned long.

Referenced by ug::Grid::find_face_in_associated_faces(), ug::Grid::find_volume_in_associated_volumes(), ug::Hash< TKey, TValue >::hash_index(), and ug::VolumeContains().

◆ IsBigEndian()

bool ug::IsBigEndian ( )
inline

Returns false if the system endianess is little endian, i.e. the least significant byte is stored first. If returned true the system endianess is big endian, i.e. most significant byte first. Please note, that this is a runtime check.

Returns
false if little endian, true if big endian

References ug::IsLittleEndian().

◆ IsLittleEndian()

bool ug::IsLittleEndian ( )
inline

Returns true if the system endianess is little endian, i.e. the least significant byte is stored first. If returned false the system endianess is big endian, i.e. most significant byte first. Please note, that this is a runtime check.

Returns
true if little endian, false if big endian

Referenced by ug::IsBigEndian(), ug::VTKOutput< TDim >::print(), ug::VTKOutput< TDim >::print_subset(), and ug::VTKOutput< TDim >::print_subsets().

◆ LoadPlugins()

UG_API bool ug::LoadPlugins ( const char *  pluginPath,
std::string  parentGroup,
bridge::Registry reg,
bool  bPrefixGroup = false 
)

Loads all plugins in the given path.

◆ OpenLibrary()

DynLibHandle ug::OpenLibrary ( const char *  fileName)

Loads a library and returns a handle.

The function throws an std::string as error if the library could not be found or if the library could not be opened (e.g. dependent shared libraries not found)

See also
CloseLibrary, GetLibraryProcedure

Referenced by ug::bridge::LUACompiler::createC(), and ug::LoadPlugins().

◆ ParamToDouble() [1/2]

UG_API double ug::ParamToDouble ( const char *  param,
int  argc,
const char *const *  argv,
double  dDefault 
)

References ug::ParamToDouble().

◆ ParamToDouble() [2/2]

UG_API bool ug::ParamToDouble ( double &  dOut,
const char *  param,
int  argc,
const char *const *  argv 
)

searches argv for the given parameter, and converts the associated value to a double value. Returns true if the parameter was found, false if not.

References ug::GetParamIndex().

Referenced by ug::ParamToDouble().

◆ ParamToInt() [1/2]

UG_API int ug::ParamToInt ( const char *  param,
int  argc,
const char *const *  argv,
int  iDefault 
)

References ug::ParamToInt().

◆ ParamToInt() [2/2]

UG_API bool ug::ParamToInt ( int &  iOut,
const char *  param,
int  argc,
const char *const *  argv 
)

searches argv for the given parameter, and converts the associated value to an integer. Returns true if the parameter was found, false if not.

References ug::GetParamIndex().

Referenced by ug::ParamToInt(), and ugshell_main().

◆ ParamToString()

UG_API bool ug::ParamToString ( const char **  strOut,
const char *  param,
int  argc,
const char *const *  argv 
)

searches argv for the given parameter, and returns the associated string (the argv directly following param). associated Returns true if the parameter was found, false if not.

Please note that spaces may not be contained in the associated string.

References ug::GetParamIndex().

Referenced by ugshell_main().

◆ PluginLoaded()

UG_API bool ug::PluginLoaded ( const std::string &  name)

◆ split_parameters()

void ug::split_parameters ( std::vector< std::string > &  paramsOut,
char *  strParams,
const char *  delims = " " 
)

fills paramsOut with the parameters that are seperated by the characters given in delim.

if you pass " ,.-" to delims, then paramsOut will contain all parameters that are separated by ' ', ',', '.' or '-'.

Please note that strParams is not const!

◆ UnloadPlugins()

bool ug::UnloadPlugins ( )

Variable Documentation

◆ SPNULL