Loading...
Searching...
No Matches
ThreadsafeException.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/config.h> // for GTSAM_USE_TBB
#include <boost/optional/optional.hpp>
#include <gtsam/dllexport.h>
#include <string>
#include <typeinfo>
#include <exception>
#ifdef GTSAM_USE_TBB
#include <tbb/tbb_allocator.h>
#include <tbb/scalable_allocator.h>
#include <iostream>
#endif
namespace gtsam {
template<class DERIVED>
class ThreadsafeException:
public std::exception
{
private:
typedef std::exception Base;
#ifdef GTSAM_USE_TBB
protected:
typedef std::basic_string<char, std::char_traits<char>,
tbb::tbb_allocator<char> > String;
#else
protected:
typedef std::string String;
#endif
protected:
bool dynamic_;
mutable boost::optional<String> description_;
ThreadsafeException() :
dynamic_(false) {
}
ThreadsafeException(const ThreadsafeException& other) :
Base(other), dynamic_(false) {
}
ThreadsafeException(const std::string& description) :
dynamic_(false), description_(
String(description.begin(), description.end())) {
}
~ThreadsafeException() noexcept override {
}
public:
const char* what() const noexcept override {
return description_ ? description_->c_str() : "";
}
};
class GTSAM_EXPORT RuntimeErrorThreadsafe: public ThreadsafeException<RuntimeErrorThreadsafe> {
public:
RuntimeErrorThreadsafe(const std::string& description) :
ThreadsafeException<RuntimeErrorThreadsafe>(description) {
}
};
class OutOfRangeThreadsafe: public ThreadsafeException<OutOfRangeThreadsafe> {
public:
OutOfRangeThreadsafe(const std::string& description) :
ThreadsafeException<OutOfRangeThreadsafe>(description) {
}
};
class InvalidArgumentThreadsafe: public ThreadsafeException<
InvalidArgumentThreadsafe> {
public:
InvalidArgumentThreadsafe(const std::string& description) :
ThreadsafeException<InvalidArgumentThreadsafe>(description) {
}
};
class CholeskyFailed : public gtsam::ThreadsafeException<CholeskyFailed>
{
public:
CholeskyFailed() noexcept {}
~CholeskyFailed() noexcept override {}
};
} // namespace gtsam
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::ThreadsafeException
Base exception type that uses tbb_allocator if GTSAM is compiled with TBB.
Definition ThreadsafeException.h:42
gtsam::ThreadsafeException::~ThreadsafeException
~ThreadsafeException() noexcept override
Default destructor doesn't have the noexcept.
Definition ThreadsafeException.h:75
gtsam::ThreadsafeException::dynamic_
bool dynamic_
Whether this object was moved.
Definition ThreadsafeException.h:55
gtsam::ThreadsafeException::ThreadsafeException
ThreadsafeException()
Default constructor is protected - may only be created from derived classes.
Definition ThreadsafeException.h:59
gtsam::ThreadsafeException::ThreadsafeException
ThreadsafeException(const ThreadsafeException &other)
Copy constructor is protected - may only be created from derived classes.
Definition ThreadsafeException.h:64
gtsam::ThreadsafeException::ThreadsafeException
ThreadsafeException(const std::string &description)
Construct with description string.
Definition ThreadsafeException.h:69
gtsam::ThreadsafeException::description_
boost::optional< String > description_
Optional description.
Definition ThreadsafeException.h:56
gtsam::RuntimeErrorThreadsafe::RuntimeErrorThreadsafe
RuntimeErrorThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition ThreadsafeException.h:88
gtsam::OutOfRangeThreadsafe::OutOfRangeThreadsafe
OutOfRangeThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition ThreadsafeException.h:97
gtsam::InvalidArgumentThreadsafe::InvalidArgumentThreadsafe
InvalidArgumentThreadsafe(const std::string &description)
Construct with a string describing the exception.
Definition ThreadsafeException.h:107