All Projects → nixiz → tracked

nixiz / tracked

Licence: MIT license
Header-only C++17 library enables to track object instances with varied policies and gives you to control exceptions on policy rule break.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to tracked

AndroidApkAnalyzer
Android application for analyzing installed apps
Stars: ✭ 159 (+1225%)
Mutual labels:  analyzer
tableize
Turn lists into tables with ease
Stars: ✭ 12 (+0%)
Mutual labels:  utility
gut
🍱 yet another collection of go utilities & tools
Stars: ✭ 24 (+100%)
Mutual labels:  utility
pe-util
List shared object dependencies of a portable executable (PE)
Stars: ✭ 45 (+275%)
Mutual labels:  utility
mpu
Martins Python Utilities - Stuff that comes in Handy
Stars: ✭ 47 (+291.67%)
Mutual labels:  utility
OP1GO
Ultraportable backups for Teenage Engineering's OP-1
Stars: ✭ 34 (+183.33%)
Mutual labels:  utility
HEAPUtil
Code for the RA-L (IROS) 2021 paper "A Hierarchical Dual Model of Environment- and Place-Specific Utility for Visual Place Recognition"
Stars: ✭ 46 (+283.33%)
Mutual labels:  utility
i2c-exp-driver
Driver to program I2C based Onion Expansions
Stars: ✭ 33 (+175%)
Mutual labels:  utility
cra-tailwindcss-in-js
Integrate Tailwind CSS in a Create React App setup using css-in-js solutions
Stars: ✭ 35 (+191.67%)
Mutual labels:  utility
leak
Show info about package releases on PyPI.
Stars: ✭ 15 (+25%)
Mutual labels:  utility
Quickeys
A mac menu bar app that provides note taking functionality though a quick dropdown menu.
Stars: ✭ 54 (+350%)
Mutual labels:  utility
TestCards
A simple test pattern generator.
Stars: ✭ 46 (+283.33%)
Mutual labels:  utility
grizzly
Extra utilities for Bear 🐻
Stars: ✭ 20 (+66.67%)
Mutual labels:  utility
Funky
Funky is a functional utility library written in Objective-C.
Stars: ✭ 41 (+241.67%)
Mutual labels:  utility
pronto-reek
Pronto runner for Reek, code smell detector for Ruby
Stars: ✭ 27 (+125%)
Mutual labels:  analyzer
ios
CoThings's iOS application. CoThings is a realtime counter for shared things.
Stars: ✭ 13 (+8.33%)
Mutual labels:  utility
goroutines
provides utilities to perform common tasks on goroutines
Stars: ✭ 19 (+58.33%)
Mutual labels:  utility
pronto-flay
Pronto runner for Flay, structural similarities analyzer
Stars: ✭ 18 (+50%)
Mutual labels:  analyzer
mik
The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
Stars: ✭ 32 (+166.67%)
Mutual labels:  utility
kyanite
A small purely functional library of curried functions, with great piping possibilities!
Stars: ✭ 26 (+116.67%)
Mutual labels:  utility

Actions Status Actions Status Actions Status codecov GitHub release (latest by date)

Tracked - Runtime Object Analyze and Tracker

This is a header-only C++17 library enables to track object instances with varied policies and gives you to control exceptions on policy rule break.

Tracked pointer is based on std::unique_ptr and with policy based design, it can be extend for your own needs

Simple Usage

#include "tracked/tracked.hpp"
#include "tracked/policy/all_policies.hpp"

class MyClass { /*...*/ };

// creating tracked_ptr<MyClass> with throw exception policy  
// and multiple dereferencing policies
auto ptr = make_tracked_ptr<MyClass,  
                            exceptions::throw_on_exception<std::exception>,  
                            must_accessed_by_single_thread,  
                            should_use_min_times<2>::type>();
// tracked pointer will throw exception either if 'ptr' accessed by any other
// thread than the thread pointer created or called more than "N" times
// declared in given policy.
ptr->foo();
auto bar = ptr->getBar();

// this call will make tracked pointer to throw exception
try
{
  ptr->foo();
} catch (const std::exception&) {
  ...
}

Policy Change

#include "tracked/tracked.hpp"
#include "tracked/policy/all_policies.hpp"

class MyClass { /*...*/ };

auto ptr = make_tracked_ptr<MyClass,
                            exceptions::throw_on_exception<std::exception>,
                            must_accessed_by_single_thread,
                            should_use_min_times<2>::type>();

/* ... */
// change policies by moving pointer to new one by explicitly declaring new type
tracked_ptr<MyClass, tracked_traits<MyClass>> untracked_ptr = std::move(ptr);
// or use auto with make_tracked_ptr<>() helper function
auto untracked_ptr = make_tracked_ptr<MyClass>(std::move(ptr));

Policies

  • Error Handling

    • default_do_nothing
    • assert_on_exception
    • throw_on_exception<exception_type = std::exception>
  • Usage - Dereferencing

    • must_be_used
    • should_use_min_times<N_Times>::type
    • should_use_max_times<N_Times>::type
  • Accessing

    • must_accessed_by_single_thread
    • must_accessed_by_main_thread

Extending Policies

Any desired policy can be added by following these simple rules:

  1. Policy class must be take exception policy by template argument

  2. If any other template type want to be used in new policy should have underlying policy class that satisfies rule 1.
    Look at should_use_min_times for implementation.

  3. Destructors of policies must have noexcept() decleration explicitly.
    Note:if destructor does not have noexcept(false) and using with throw_expection policy can cause to terminate the application

  4. Policy classes must have void x_policy::apply() const function. This is main check function that tracked_ptr delegates through policies

Building and Runnning Tests

To build the project, all you need to do call cmake with following parameters:

mkdir build/ && cd build/
cmake .. -DCMAKE_INSTALL_PREFIX=/absolute/path/to/custom/install/directory
cmake --build . --target install
ctest -C Release  # or `ctest -C Debug` or any other configuration you wish to test

# you can also run tests with the `-VV` flag for a more verbose output (i.e.
#GoogleTest output as well)

Note: The custom CMAKE_INSTALL_PREFIX can be omitted if you wish to install in the default install location.

By default, tracked library uses Google Test for unit testing. Unit testing can be disabled in the options, by setting the ENABLE_UNIT_TESTING (from cmake/StandardSettings.cmake) to be false. To run the tests, simply use CTest, from the build directory, passing the desire configuration for which to run tests for.

Tests and Usage Examples

Contributing

Please read CONTRIBUTING.md for details on our how you can become a contributor and the process for submitting pull requests to us.

Authors

This library is licensed under the MIT License - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].