From 58229b0164d2dcb2020d5164cbc04eca55fd24e4 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Tue, 25 Sep 2018 19:14:47 +0200
Subject: [PATCH] Add messenger instance access

Also add commRank and commSize access functions
---
 src/utils/Messenger.hpp | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/utils/Messenger.hpp b/src/utils/Messenger.hpp
index 275840eef..94e551c9a 100644
--- a/src/utils/Messenger.hpp
+++ b/src/utils/Messenger.hpp
@@ -2,6 +2,7 @@
 #define MESSENGER_HPP
 
 #include <PastisMacros.hpp>
+#include <PastisAssert.hpp>
 
 class Messenger
 {
@@ -15,6 +16,13 @@ class Messenger
   static void create(int& argc, char* argv[]);
   static void destroy();
 
+  PASTIS_INLINE
+  static Messenger& getInstance()
+  {
+    Assert(m_instance != nullptr);
+    return *m_instance;
+  }
+
   PASTIS_INLINE
   const int& rank() const
   {
@@ -31,4 +39,25 @@ class Messenger
   ~Messenger();
 };
 
+PASTIS_INLINE
+const Messenger& messenger()
+{
+  return Messenger::getInstance();
+}
+
+[[deprecated("use better name")]]
+PASTIS_INLINE
+const int& commRank()
+{
+  return messenger().rank();
+}
+
+[[deprecated("use better name")]]
+PASTIS_INLINE
+const int& commSize()
+{
+  return messenger().size();
+}
+
+
 #endif // MESSENGER_HPP
-- 
GitLab