Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge the content of xbt/exception.hpp into simgrid/Exception.hpp
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 25 Aug 2018 09:07:11 +0000 (11:07 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 25 Aug 2018 09:07:11 +0000 (11:07 +0200)
include/simgrid/Exception.hpp
include/xbt/exception.hpp [deleted file]
include/xbt/log.hpp
src/s4u/s4u_Barrier.cpp
src/s4u/s4u_ConditionVariable.cpp

index 66c12de..37acd8f 100644 (file)
 
 #include <exception>
 #include <stdexcept>
 
 #include <exception>
 #include <stdexcept>
-#include <xbt/exception.hpp>
+#include <string>
+#include <type_traits>
+#include <vector>
 
 
+#include <xbt/backtrace.h>
+#include <xbt/backtrace.hpp>
+#include <xbt/base.h>
 #include <xbt/ex.h>
 #include <xbt/ex.h>
+#include <xbt/log.h>
+#include <xbt/misc.h>  // xbt_procname
+#include <xbt/virtu.h> // xbt_getpid
 
 namespace simgrid {
 
 namespace simgrid {
+namespace xbt {
+
+/** The location of where an exception has been thrown
+ *
+ *  This is a tuple (__FILE__, __LINE__, __func__), created with @ref XBT_THROW_POINT.
+ *
+ *  @ingroup XBT_ex
+ */
+class ThrowPoint {
+public:
+  ThrowPoint() = default;
+  explicit ThrowPoint(const char* file, int line, const char* function) : file_(file), line_(line), function_(function)
+  {
+  }
+  const char* file_     = nullptr;
+  int line_             = 0;
+  const char* function_ = nullptr;
+};
+
+/** Create a ThrowPoint with (__FILE__, __LINE__, __func__) */
+#define XBT_THROW_POINT ::simgrid::xbt::ThrowPoint(__FILE__, __LINE__, __func__)
+
+/** A base class for exceptions with context
+ *
+ *  This is a base class for exceptions which store additional contextual
+ *  information: backtrace, throw point, simulated process name, PID, etc.
+ */
+class XBT_PUBLIC ContextedException {
+public:
+  ContextedException() : backtrace_(simgrid::xbt::backtrace()), procname_(xbt_procname()), pid_(xbt_getpid()) {}
+  explicit ContextedException(Backtrace bt) : backtrace_(std::move(bt)), procname_(xbt_procname()), pid_(xbt_getpid())
+  {
+  }
+  explicit ContextedException(ThrowPoint throwpoint, Backtrace bt)
+      : backtrace_(std::move(bt)), procname_(xbt_procname()), pid_(xbt_getpid()), throwpoint_(throwpoint)
+  {
+  }
+  virtual ~ContextedException();
+  Backtrace const& backtrace() const { return backtrace_; }
+  int pid() const { return pid_; }
+  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 */
+  int pid_;              /**< PID of the process who thrown this */
+  ThrowPoint throwpoint_;
+};
+} // namespace xbt
 
 /** Ancestor class of all SimGrid exception */
 class Exception : public std::runtime_error {
 
 /** Ancestor class of all SimGrid exception */
 class Exception : public std::runtime_error {
diff --git a/include/xbt/exception.hpp b/include/xbt/exception.hpp
deleted file mode 100644 (file)
index 4036734..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/* 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. */
-
-#ifndef SIMGRID_XBT_EXCEPTION_HPP
-#define SIMGRID_XBT_EXCEPTION_HPP
-
-#include <string>
-#include <type_traits>
-#include <vector>
-
-#include <xbt/base.h>
-#include <xbt/backtrace.h>
-#include <xbt/backtrace.hpp>
-#include <xbt/log.h>
-#include <xbt/misc.h>  // xbt_procname
-#include <xbt/virtu.h> // xbt_getpid
-
-/** @addtogroup XBT_ex
- *  @brief Exceptions support
- */
-
-namespace simgrid {
-namespace xbt {
-
-/** The location of where an exception has been thrown
- *
- *  This is a tuple (__FILE__, __LINE__, __func__) and can be created with
- *  @ref XBT_THROW_POINT.
- *
- *  @ingroup XBT_ex
- */
-class ThrowPoint {
- public:
-  ThrowPoint() = default;
-  explicit ThrowPoint(const char* file, int line, const char* function) : file_(file), line_(line), function_(function)
-  {
-  }
-  const char* file_     = nullptr;
-  int line_             = 0;
-  const char* function_ = nullptr;
-};
-
-/** Create a ThrowPoint with (__FILE__, __LINE__, __func__) */
-#define XBT_THROW_POINT ::simgrid::xbt::ThrowPoint(__FILE__, __LINE__, __func__)
-
-/** A base class for exceptions with context
- *
- *  This is a base class for exceptions which store additional contextual
- *  information: backtrace, throw point, simulated process name, PID, etc.
- */
-class XBT_PUBLIC ContextedException {
-public:
-  ContextedException() :
-    backtrace_(simgrid::xbt::backtrace()),
-    procname_(xbt_procname()),
-    pid_(xbt_getpid())
-  {}
-  explicit ContextedException(Backtrace bt) : backtrace_(std::move(bt)), procname_(xbt_procname()), pid_(xbt_getpid())
-  {}
-  explicit ContextedException(ThrowPoint throwpoint, Backtrace bt)
-      : backtrace_(std::move(bt)), procname_(xbt_procname()), pid_(xbt_getpid()), throwpoint_(throwpoint)
-  {}
-  virtual ~ContextedException();
-  Backtrace const& backtrace() const
-  {
-    return backtrace_;
-  }
-  int pid() const { return pid_; }
-  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 */
-  int pid_;              /**< PID of the process who thrown this */
-  ThrowPoint throwpoint_;
-};
-}
-}
-
-#endif
index 083ce2d..4aaff8a 100644 (file)
@@ -3,8 +3,8 @@
 /* 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. */
 
 /* 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. */
 
+#include <simgrid/Exception.hpp>
 #include <xbt/log.h>
 #include <xbt/log.h>
-#include <xbt/exception.hpp>
 
 namespace simgrid {
 namespace xbt {
 
 namespace simgrid {
 namespace xbt {
index b0c2121..d19fb26 100644 (file)
@@ -6,12 +6,11 @@
 #include <exception>
 #include <mutex>
 
 #include <exception>
 #include <mutex>
 
-#include <xbt/exception.hpp>
-#include <xbt/log.hpp>
-
+#include "simgrid/Exception.hpp"
 #include "simgrid/barrier.h"
 #include "simgrid/s4u/Barrier.hpp"
 #include "simgrid/simix.h"
 #include "simgrid/barrier.h"
 #include "simgrid/s4u/Barrier.hpp"
 #include "simgrid/simix.h"
+#include "xbt/log.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_barrier, "S4U barrier");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_barrier, "S4U barrier");
 
index 7707e66..4d053ae 100644 (file)
@@ -3,15 +3,13 @@
 /* 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. */
 
 /* 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. */
 
-#include <exception>
-#include <mutex>
-
-#include <xbt/exception.hpp>
-#include <xbt/log.hpp>
-
 #include "simgrid/s4u/ConditionVariable.hpp"
 #include "simgrid/simix.h"
 #include "src/kernel/activity/ConditionVariableImpl.hpp"
 #include "simgrid/s4u/ConditionVariable.hpp"
 #include "simgrid/simix.h"
 #include "src/kernel/activity/ConditionVariableImpl.hpp"
+#include "xbt/log.hpp"
+
+#include <exception>
+#include <mutex>
 
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {