X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/183a6118a95c570b0c66695505dab7dbebc0c7b3..435eac9875f286908c7ead8f6b50fd9bb23690b8:/include/xbt/exception.hpp diff --git a/include/xbt/exception.hpp b/include/xbt/exception.hpp index 6e801981d2..544f6ae247 100644 --- a/include/xbt/exception.hpp +++ b/include/xbt/exception.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2016. The SimGrid Team.All rights reserved. */ +/* Copyright (c) 2005-2018. The SimGrid Team.All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -65,23 +65,17 @@ class ThrowPoint { * However, you can try `dynamic_cast` an exception to this type in order to * get contextual information about the exception. */ -XBT_PUBLIC_CLASS WithContextException { +class XBT_PUBLIC WithContextException { public: WithContextException() : backtrace_(simgrid::xbt::backtrace()), procname_(xbt_procname()), pid_(xbt_getpid()) {} - WithContextException(Backtrace bt) : - backtrace_(std::move(bt)), - procname_(xbt_procname()), - pid_(xbt_getpid()) + explicit WithContextException(Backtrace bt) : backtrace_(std::move(bt)), procname_(xbt_procname()), pid_(xbt_getpid()) {} - WithContextException(ThrowPoint throwpoint, Backtrace bt) : - backtrace_(std::move(bt)), - procname_(xbt_procname()), - pid_(xbt_getpid()), - throwpoint_(throwpoint) + explicit WithContextException(ThrowPoint throwpoint, Backtrace bt) + : backtrace_(std::move(bt)), procname_(xbt_procname()), pid_(xbt_getpid()), throwpoint_(throwpoint) {} virtual ~WithContextException(); Backtrace const& backtrace() const @@ -89,8 +83,19 @@ public: return backtrace_; } int pid() const { return pid_; } - std::string const& processName() const { return procname_; } - ThrowPoint& throwPoint() { return throwpoint_; } + std::string const& process_name() const { return procname_; } + ThrowPoint& throw_point() { return throwpoint_; } + + // deprecated + XBT_ATTRIB_DEPRECATED_v323("Please use WithContextException::process_name()") std::string const& processName() const + { + return process_name(); + } + XBT_ATTRIB_DEPRECATED_v323("Please use WithContextException::throw_point()") ThrowPoint& throwPoint() + { + return throw_point(); + } + private: Backtrace backtrace_; std::string procname_; /**< Name of the process who thrown this */ @@ -105,8 +110,7 @@ class WithContext : public E, public WithContextException public: static_assert(not std::is_base_of::value, "Trying to appli WithContext twice"); - WithContext(E exception) : - E(std::move(exception)) {} + explicit WithContext(E exception) : E(std::move(exception)) {} WithContext(E exception, ThrowPoint throwpoint, Backtrace backtrace) : E(std::move(exception)), WithContextException(throwpoint, std::move(backtrace)) {} @@ -116,7 +120,7 @@ public: WithContext(E exception, WithContextException context) : E(std::move(exception)), WithContextException(std::move(context)) {} - ~WithContext() override {} + ~WithContext() override = default; }; /** Throw a C++ exception with some context