ThreadsafeException.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #pragma once
21 
22 #include <gtsam/config.h> // for GTSAM_USE_TBB
23 
24 #include <gtsam/dllexport.h>
25 #include <string>
26 #include <typeinfo>
27 #include <exception>
28 #include <optional>
29 
30 #ifdef GTSAM_USE_TBB
31 #include <tbb/tbb_allocator.h>
32 #include <tbb/scalable_allocator.h>
33 #include <iostream>
34 #endif
35 
36 namespace gtsam {
37 
39 template<class DERIVED>
41 public std::exception
42 {
43 private:
44  typedef std::exception Base;
45 #ifdef GTSAM_USE_TBB
46 protected:
47  typedef std::basic_string<char, std::char_traits<char>,
48  tbb::tbb_allocator<char> > String;
49  typedef tbb::tbb_allocator<char> Allocator;
50 #else
51 protected:
52  typedef std::string String;
53  typedef std::allocator<char> Allocator;
54 #endif
55 
56 protected:
57  bool dynamic_;
58  mutable std::optional<String> description_;
59 
62  dynamic_(false) {
63  }
64 
67  Base(other), dynamic_(false) {
68  }
69 
71  ThreadsafeException(const std::string& description) :
72  dynamic_(false), description_(
73  String(description.begin(), description.end())) {
74  }
75 
77  ~ThreadsafeException() noexcept override {
78  }
79 
80 public:
81  const char* what() const noexcept override {
82  return description_ ? description_->c_str() : "";
83  }
84 };
85 
87 class GTSAM_EXPORT RuntimeErrorThreadsafe: public ThreadsafeException<RuntimeErrorThreadsafe> {
88 public:
90  RuntimeErrorThreadsafe(const std::string& description) :
92  }
93 };
94 
96 class OutOfRangeThreadsafe: public ThreadsafeException<OutOfRangeThreadsafe> {
97 public:
99  OutOfRangeThreadsafe(const std::string& description) :
101  }
102 };
103 
106  InvalidArgumentThreadsafe> {
107 public:
111  }
112 };
113 
115 class CholeskyFailed : public gtsam::ThreadsafeException<CholeskyFailed>
116 {
117 public:
118  CholeskyFailed() noexcept {}
119  ~CholeskyFailed() noexcept override {}
120 };
121 
122 } // namespace gtsam
gtsam::ThreadsafeException::dynamic_
bool dynamic_
Whether this object was moved.
Definition: ThreadsafeException.h:57
gtsam::OutOfRangeThreadsafe
Thread-safe out of range exception.
Definition: ThreadsafeException.h:96
gtsam::ThreadsafeException::Base
std::exception Base
Definition: ThreadsafeException.h:44
gtsam::RuntimeErrorThreadsafe::RuntimeErrorThreadsafe
RuntimeErrorThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:90
gtsam::ThreadsafeException::String
std::string String
Definition: ThreadsafeException.h:52
gtsam::ThreadsafeException
Base exception type that uses tbb_allocator if GTSAM is compiled with TBB.
Definition: ThreadsafeException.h:40
setup.description
description
Definition: gtsam/3rdparty/GeographicLib/python/setup.py:45
gtsam::ThreadsafeException::~ThreadsafeException
~ThreadsafeException() noexcept override
Default destructor doesn't have the noexcept.
Definition: ThreadsafeException.h:77
gtsam::ThreadsafeException::what
const char * what() const noexcept override
Definition: ThreadsafeException.h:81
gtsam::ThreadsafeException::ThreadsafeException
ThreadsafeException(const ThreadsafeException &other)
Copy constructor is protected - may only be created from derived classes.
Definition: ThreadsafeException.h:66
gtsam::CholeskyFailed
Indicate Cholesky factorization failure.
Definition: ThreadsafeException.h:115
gtsam::OutOfRangeThreadsafe::OutOfRangeThreadsafe
OutOfRangeThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:99
gtsam::CholeskyFailed::CholeskyFailed
CholeskyFailed() noexcept
Definition: ThreadsafeException.h:118
gtsam::ThreadsafeException::description_
std::optional< String > description_
Optional description.
Definition: ThreadsafeException.h:58
gtsam
traits
Definition: chartTesting.h:28
gtsam::InvalidArgumentThreadsafe
Thread-safe invalid argument exception.
Definition: ThreadsafeException.h:105
gtsam::CholeskyFailed::~CholeskyFailed
~CholeskyFailed() noexcept override
Definition: ThreadsafeException.h:119
gtsam::ThreadsafeException::ThreadsafeException
ThreadsafeException(const std::string &description)
Construct with description string.
Definition: ThreadsafeException.h:71
gtsam::ThreadsafeException::ThreadsafeException
ThreadsafeException()
Default constructor is protected - may only be created from derived classes.
Definition: ThreadsafeException.h:61
Eigen::placeholders::end
static const EIGEN_DEPRECATED end_t end
Definition: IndexedViewHelper.h:181
Base
Definition: test_virtual_functions.cpp:156
gtsam::RuntimeErrorThreadsafe
Thread-safe runtime error exception.
Definition: ThreadsafeException.h:87
gtsam::ThreadsafeException::Allocator
std::allocator< char > Allocator
Definition: ThreadsafeException.h:53
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::InvalidArgumentThreadsafe::InvalidArgumentThreadsafe
InvalidArgumentThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition: ThreadsafeException.h:109


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:07:12