System

“System” is C++ (mostly) template library build from many small classes that are useful, doesn't fit anywhere else and are too small to form a library alone. implements some small, common algorithms, threading helpers, math operations, plugins and more.

library content

available classes/functions are:

  • AtExit – object-oriented wrapper for atexit() standard library call.
  • arraySum*FP – generic algorithm for summing floating points, with minimal loss on precision.
  • AutoCptr – std::auto_ptr<> like wrapper for C-style pointers (allocated with malloc()). it is usefull when working with legacy C code.
  • AutoDescriptor – class behaving just like std::auto_ptr<> but holding descriptors (int): sockets, files, etc…
  • AutoFILE – again std::auto_ptr<> like class, this time for holding C-streams (FILE*).
  • AutoVariable – class for managing user-specified type in std::auto_ptr<> like way. it has been used to write AutoFILE, AutoDescriptor and AutoCptr but is not limited to those 3. it can be used of nearly resource spotted in practice.
  • Average – computes average and standard deviation on given sample of numbers.
  • compareFP – compares floating point numbers withing given precision range.
  • DiskFile – represents file on disk. opens file on disk and returns its descriptor. allows to delete file.
  • DivingStack – template container implementation of diving stack algorithm.
  • Enum – “normal” enum type is very poor in both C and C++. this is a template wrapping user-specified enum type, so that it could be used in more human-readable manner. for example:
class MyEnumType: public Enum<...> {...}
MyEnumType e=MyEnumType::ENUM_VALUE_1;
if(e!=MyEnumType::ENUM_VALUE_2) {...}
...
  • FunctionName.hpp – helper macro that uses standard 'function' or 'pretty function' names, depending on the compiler.
  • GlobalInit – helper to safely initialize libraries, that require some calls to be made before usage (mostly C libraries, but not only). ensures single-initialization, is thread-safe and can be used multiple times safely.
  • ignore – template that does nothing with the argument, except for preventing compiler complaining about unused variable (i.e. when used only in debug for assert()).
  • IterableEnum – extension of Enum class that allows iterating through enum values.
  • MultiLock – locks multiple mutexes in a predefined order (i.e. always the same) to prevent deadlocks.
  • Plugins:: – implementation of generic plugins mechanism with shared-object files.
  • SafeValue – wrapper for non-thread safe values that allows using them in thread-aware environment
  • Singleton – template class implementing Mayer's singleton pattern on user provided type.
  • StateMachine – easy to use representation of state machine. user implements its states and inheritates from this calls. than stepping to another state is done be base-calss call, etc…
  • Sync – class allowing easy master-slave thread synchronization.
  • TempFile – if you need a file and your not interested in details and file should be removed ASAP when not needed TempFile is what you're looking for.
  • Thread – thread wrapper, automatically joining thread when destroyed and catching all runtime errors.
  • keepRange – template function, similar to std::min and std::max, but working on range of values to keep. allows also converting to 'smaller' types (ex.: int to char), doing translation to best-match in new range.
  • nonint_ioctl – ioctl() function wrapper that will not break when EINTR arrives.
  • OneInstanceAtOnce – debug wrapper that checks if given object does is in at most one instance at every time.
  • SharedPtrNotNULL – boost::shared_ptr-like template that ensures pointer held inside is non-NULL. template also provides converting from non-const to const types, and derived to base class pointers.
  • ScopedPtrCustom – boost::scoped_ptr-like template that allows adding self-provided user function to free given pointer.
  • likely.hpp – implements heuristics for branches.
  • SYSTEM_FUNCTION_NAME – wrapper that returns pretty-function name if available, or regular function name if not.
  • SignalRegistrator – C++ helper for registering signal handlers.
  • Timer – boost::timer equivalent for measuring real-time elapsed (instead of CPU-time).
  • Safe-Init-Locking – mechanism that ensures compile-time initialization of (global) mutexes and locking them to ensure thread-safe initialization.

requirements

System requires build_process in recent version. to make life easier it has been included in download package.

you will need to have boost library installed too.

download

you can download current version of System library here. latest version is 1.0.0.

release notes

release notes for particular version of library (newest on top).

v1.0.0

  • Threads::SafeValue - wrapper making basic types thread-safe, has been implemented.
  • Threads::MultiLock class for locking multiple mutexes in a predefined order implemented.
  • Threads::Thread thread wrapper added.
  • Threads::Sync added for easy synchronizing master-slave threads.
  • SharedPtrNotNULL const-fixes.
  • support for intel compiler updated.
  • build process v1.7.1 introduced.

v0.8.0

  • average and standard deviation computation algorithm has been introduced.
  • implemented algorithm for comparison of floating points with a given precision.
  • added two algorithms for addition of floating points with minimal loss of precision.
  • new System::Math namespace is present.
  • added DivingStack<> template container.
  • moved some library internals to System::detail namespace.
  • updated AtExit's code so that unregistering dynamic objects (dlclose() call) that registered to AtExit is will be possible.
  • added Plugins namespace for handling plugins in external *.so files.
  • few typos fixed.
  • minor code/style fixes.

v0.7.1

  • fixed issue with convertion from const in SharedPtrNotNULL<>
  • fixed issue with comparison operators in SharedPtrNotNULL<> - now only operators available in boost::shared_ptr<> are available.

v0.7.0

  • OneInstanceAtOnce - guard class that ensures that only one instance of a given object is present at a given time in system.
  • ignore<>() - helper that prevents warnings about unused variable (ex.: that is needed only in debug).
  • fixed SharedPtrNotNULL API to have explicit back-to-shared_ptr<> conversion method.
  • GlobalInit<> - secure, thread safe initializer of the libraries that need such before usage.
  • SharedPtrNotNULL<> can now implicitly convert between pointers to derived → base classes and non-const → const pointers.

v0.6.0

  • fixed remarks on intel's toolchain.
  • added real-time timer showing time elapsed since its start.
  • implemented helper for registration handlers for signals.
  • file opening uses now O_CLOEXEC flag by default.
  • implemented SharedPtrNotNULL template - boost::shred_ptr<> equivalent, that ensures that pointer is NOT NULL.
  • implemented ScopedPtrCustom template - boost::scoped_ptr<> equivalent, that allows user-provided function to free pointer.
  • likely.hpp implements compiler heuristics for branches.
  • added FunctionName.hpp with macro wrapping and setting SYSTEM_FUNCTION_NAME macro to return pretty-function name, when possible and funciton name as a fallback.
  • added location information for all exception classes (new c-tor has been added).
  • exceptions can now return their name (via RTTI) with getTypeName().
  • fixed Backtrace's tests (tail-recursion on newer gcc versions).
  • fixed race condition when initializing Singleton from multiple threads.
  • Singleton is now Phoenix/Mayer's Singleton with thread-safe initialization and release.
  • AtExit now allows registering new handlers from another handler (while executing).
  • build_process v1.3.0 introduced.

v0.5.0

  • *Enum::toInt() is now standard.
  • exceptions thrown by library are slightly more verbose now.
  • updated Auto* classes to allow “regular” copying as atuo_ptr<> does, in all situations.
  • fixed resource leaks in assignment for AutoVariable.
  • provided Backtrace for saving stack backtraces (useful for exceptions).
  • added Exceptions::* for creating own exceptions easily.

v0.4.3

  • fixed convention in Exception.
  • begin(), end(), size() are now static.
  • fixed warning in assert in IterableEnum<> on some compilers.
  • build_process v0.6.0 introduced.
  • removed extra link reference to boost::threads.

v0.4.1

  • build_process v0.6.0 introduced.
  • removed extra link reference to boost::threads.

v0.4.0

  • replaced all explicit deletes with boost::checked_delete.
  • AtExit is thread safe now (also during creating/destroing).
  • updated build_process to v0.5.6.
  • added AtExit class - an OO replacement of limited atexit() system call.
  • added 2nd license: revised BSD.
  • added missing headers.
  • removed extra dependency on pthreads.
  • StateMachine internal states can now handle their states as well (this simplifies life in case of operations like counting, etc…)
  • added AutoCptr for mananging C-style pointers (malloc()/free()).
  • removed unfinished code of AutoVector.
  • added doxygen comments.
  • System::Network has been removed – use boost::asio instead.
  • System::Threads he been removed – use boost::thread instead.
  • uses new build_process v0.5.3.
  • keepRange<>() has second implementation allowing to convert between types, with range limitation if needed.
  • keepRange<>() now can convert on-the-fly to new range, ex: keepRange<char>(399)==255.
  • added mtest for DiskFile to test if it is poiisble to write file > 2GB.
prjs/system/system.txt · Last modified: 2011/02/17 21:49 by basz
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0