Commit graph

24 commits

Author SHA1 Message Date
Martin Braun
b6119e581e uhd: Replace Boost mutexes and locks with standard options
This is a very mechanical task that could almost have been done with
sed. Boost versions of mutexes and locks were removed, and replaced with
std:: versions. The replacement tables are as follows:

== Mutexes ==
- boost::mutex -> std::mutex
- boost::recursive_mutex -> std::recursive_mutex

Mutexes behave identically between Boost and std:: and have the same
API.

== Locks ==
C++11 has only two types of lock that we use/need in UHD:
- std::lock_guard: Identical to boost::lock_guard
- std::unique_lock: Identical to boost::unique_lock

Boost also has boost::mutex::scoped_lock, which is a typedef for
boost::unique_lock<>. However, we often have used scoped_lock where we
meant to use lock_guard<>. The name is a bit misleading, "scoped lock"
sounding a bit like an RAII mechanism. Therefore, some previous
boost::mutex::scoped_lock are now std::lock_guard<>.

std::unique_lock is required when doing more than RAII locking (i.e.,
unlocking, relocking, usage with condition variables, etc.).

== Condition Variables ==
Condition variables were out of the scope of this lock/mutex change, but
in UHD, we inconsistently use boost::condition vs.
boost::condition_variable. The former is a templated version of the
latter, and thus works fine with std::mutex'es. Therefore, some
boost::condition_variable where changed to boost::condition.

All locks and mutexes use `#include <mutex>`. The corresponding Boost
includes were removed. In some cases, this exposed issues with implicit
Boost includes elsewhere. The missing explicit includes were added.
2021-10-19 12:21:33 -07:00
Martin Braun
107a49c0c2 host: Update code base using clang-tidy
The checks from the new clang-tidy file are applied to the source tree
using:

$ find . -name "*.cpp" | sort -u | xargs \
    --max-procs 8 --max-args 1 clang-tidy --format-style=file \
    --fix -p /path/to/compile_commands.json
2021-03-04 08:07:26 -06:00
Steven Koo
f22e3c2d47 uhd: revert "Check property type at access..."
This change reverts cb9329a681.
The type checking is causing some conversion issues on clang/macos.
The type_index checking doesn't work correctly across shared
libraries and should not be relied on to verify type, since it can
vary from compiler to compiler.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2021-01-08 11:23:17 -06:00
Martin Braun
876d4150aa uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
2020-03-03 08:51:32 -06:00
Martin Braun
1fe98e8701 uhd: Replace usage of boost smart pointers with C++11 counterparts
This removes the following Boost constructs:
- boost::shared_ptr, boost::weak_ptr
- boost::enable_shared_from_this
- boost::static_pointer_cast, boost::dynamic_pointer_cast

The appropriate includes were also removed. All C++11 versions of these
require #include <memory>.
Note that the stdlib and Boost versions have the exact same syntax, they
only differ in the namespace (boost vs. std). The modifications were all
done using sed, with the exception of boost::scoped_ptr, which was
replaced by std::unique_ptr.

References to boost::smart_ptr were also removed.

boost::intrusive_ptr is not removed in this commit, since it does not
have a 1:1 mapping to a C++11 construct.
2019-11-26 12:21:32 -08:00
Aaron Rossetto
cb9329a681 uhd: Check property type at access; error if mismatch 2019-11-26 12:21:31 -08:00
Martin Braun
d8b75ca532 Revert "uhd: Check property type at access; error if mismatch"
This reverts commit 94592641f0.

The commit itself was OK, but it changed the requirements such that UHD
could only be compiled with C++11.
2019-09-30 16:35:51 +02:00
Aaron Rossetto
94592641f0 uhd: Check property type at access; error if mismatch 2019-09-04 19:06:08 -07:00
Brent Stapleton
01fd6d52ce prop_tree: add pop() function
Adding pop function to property tree, which will remove and return a
property from the property tree. This also includes unit tests.
2019-05-02 08:39:54 -07:00
Brent Stapleton
d44277d7ac prop_tree: formatting property tree files
- Ran clang-format
- Fixed typos
- Updated copyright headers

clang-format -i --style=file \
    host/include/uhd/property_tree.hpp \
    host/include/uhd/property_tree.ipp
clang-format -i --style=file \
    host/lib/property_tree.cpp host/tests/property_test.cpp
2019-05-02 08:39:54 -07:00
Martin Braun
ae5211d71d uhd: Update license headers
All copyright is now attributed to "Ettus Research, a National
Instruments company".

SPDX headers were also updated to latest version 3.0.
2018-02-19 16:54:52 -08:00
Martin Braun
4f948e2c8b Move all license headers to SPDX format. 2017-12-22 10:45:51 -08:00
Martin Braun
47cdd6319c uhd: Replaced many lexical_cast with appropriate C++11 equivalents 2017-06-29 13:40:07 -07:00
Andrej Rode
26cc20847c uhd: replace BOOST_FOREACH with C++11 range-based for loop
Note: This is the first commit that uses for-range, and range-based
for-loops are now usable for UHD development.
2017-02-10 16:44:33 -08:00
Ashish Chaudhari
834acb8b6c prop_tree: Added advanced coercion capability to property
- Added auto and manual coerce modes
- Added set_coerced API for manual coercion
- Added detailed doxy comments describing behavior of property class
2016-02-11 14:36:20 -08:00
Martin Braun
5aefa0fdfc Merge branch 'maint' 2014-09-23 16:03:27 -07:00
Martin Braun
c431a66df3 uhd: Added an operator/ for (fs_path, size_t)
This is useful when constructing property tree paths.
With this path, the following code would be valid:

size_t mb_index = 0;
fs_path mb_root = "/mboards";
mb_root = mb_root / mb_index;

This is a shortcut for the (in UHD very common)

mb_root = mb_root / boost::lexical_cast<std::string(mb_index);
2014-09-23 16:02:14 -07:00
Nicholas Corgan
654c5b06c0 Added missing pure virtual destructors to base classes 2014-09-01 17:58:24 +02:00
Josh Blum
da40a1aebc uhd: replaced boost filesystem path with fs_path in property tree 2011-07-22 13:59:47 -07:00
Josh Blum
22319dfc30 uhd: tweaks for windows boost 1.47 compile 2011-07-18 12:57:00 -07:00
Josh Blum
aa6b340f43 uhd: added subtree capability to property tree 2011-07-08 10:08:43 -07:00
Josh Blum
d2f79c0728 uhd: added properties unit tests, use shared ptr<void> in tree 2011-06-28 21:26:28 -07:00
Josh Blum
3a61875156 usrp2: restored discovery and most of io_impl 2011-06-27 23:05:53 -07:00
Josh Blum
ba2a6b4b39 uhd: forgot to commit properties file 2011-06-25 20:23:19 -07:00