From 24f0302e353973a39a2f4c29da42c6802f9978ca Mon Sep 17 00:00:00 2001
From: Nils Erik Krumnack <nils.erik.krumnack@cern.ch>
Date: Tue, 10 May 2016 23:04:38 +0200
Subject: [PATCH] fixed AnaToolHandle::swap to work in Athena (the problem was
 that the release function had the AnaToolHandle it worked on hard-coded)
 (AsgTools-00-00-85)

	* fixed AnaToolHandle::swap to work in Athena (the problem was that
	  the release function had the AnaToolHandle it worked on hard-
	  coded)
	* tagging as AsgTools-00-00-85

2016-05-05 Nils Krumnack <Nils.Erik.Krumnack@cern.ch>
	* added documentation to the MessageCheck.h header file
	* tagging as AsgTools-00-00-84


Former-commit-id: 0c28bbefea05ccbb86b71d7ac975934577d5dad2
---
 .../AsgTools/AsgTools/AnaToolHandle.h         |  2 +-
 .../AsgTools/AsgTools/AnaToolHandle.icc       |  4 +-
 .../AsgTools/AsgTools/MessageCheck.h          | 65 ++++++++++++++++++-
 .../AthToolSupport/AsgTools/Root/AsgTool.cxx  |  2 +-
 4 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.h b/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.h
index 0ced5989456..ed8e8bbbe33 100644
--- a/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.h
+++ b/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.h
@@ -554,7 +554,7 @@ namespace asg
     // \brief this contains a release function we use, so that we can
     // break down on include dependencies
   private:
-    std::function<void ()> m_releaseFunction;
+    std::function<void (ToolHandle<T> *)> m_releaseFunction;
 
   private:
     std::string fullName () const;
diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc b/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc
index 7948d1a739e..3abcf0e7492 100644
--- a/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc
+++ b/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc
@@ -88,7 +88,7 @@ namespace asg
       m_parent (val_parent),
       m_originalTypeAndName (m_handle->typeAndName ())
 #ifndef ROOTCORE
-    , m_releaseFunction ([this] () {
+    , m_releaseFunction ([] (ToolHandle<T> *m_handle) {
 	using namespace msgToolHandle;
 	//tool has 2 ref counts out of the box?? (ToolSvc and, and ToolSvc again because of the queryInterface call (line 348 of ToolSvc.cpp .. and see line 34 of AlgTool.cpp))
 	if(m_handle->isSet()) {
@@ -191,7 +191,7 @@ namespace asg
       detail::removePropertyFromCatalogue( fullName() , prop ).ignore();
 
     if (m_releaseFunction)
-      m_releaseFunction ();
+      m_releaseFunction (m_handle.get());
 
 #endif
   }
diff --git a/Control/AthToolSupport/AsgTools/AsgTools/MessageCheck.h b/Control/AthToolSupport/AsgTools/AsgTools/MessageCheck.h
index 21eccebaf7c..0c460c37ac0 100644
--- a/Control/AthToolSupport/AsgTools/AsgTools/MessageCheck.h
+++ b/Control/AthToolSupport/AsgTools/AsgTools/MessageCheck.h
@@ -11,9 +11,68 @@
 // reports, feature suggestions, praise and complaints.
 
 
-// This module still needs to be documented.  The interface provided
-// in this module is intended for experts only.  The module is
-// considered to be in the pre-alpha stage.
+/// \file MessageCheck.h
+/// \brief macros for messaging and checking status codes
+///
+/// The core of this file is the macro ANA_CHECK.  With it, a simple
+/// main might look like this:
+/// \code{.cpp}
+/// int main ()
+/// {
+///   using namespace asg::msgUserCode;
+///   ANA_CHECK_SET_TYPE (int);
+///
+///   ANA_CHECK (xAOD::Init());
+///   return 0;
+/// }
+/// \endcode
+///
+/// For the most part \ref ANA_CHECK works just like \ref ATH_CHECK,
+/// except it works for any kind of status code (and other things like
+/// bool).  By default it will return a regular StatusCode object, but
+/// you can make it return a different type by specifying \ref
+/// ANA_CHECK_SET_TYPE at the beginning of the function. In the
+/// example I use it to return an int instead.
+///
+/// Unfortunately the example will compile without that line, but it
+/// will not work as expected, i.e. when you return
+/// StatusCode::FAILURE it will convert to a value of 0, which the
+/// shell interprets as success.  There is very little I can do about
+/// that from my side, as that is the intrinsic behavior of StatusCode
+/// itself.  So it is very important that you remember to put that
+/// line in.
+///
+/// If you have a function that needs to indicate failure, but can't
+/// do so via a status code (e.g. a constructor) you can use the macro
+/// \ref ANA_CHECK_THROW, which will throw an exception instead.
+/// However, where possible a status code is preferred.
+///
+/// If this is actually a unit test and you already had the chance to
+/// update it to GoogleTest, then there are also macros
+/// ASSERT_SUCCESS, ASSERT_FAILURE, EXPECT_SUCCESS and EXPECT_FAILURE
+/// defined that integrate with the GoogleTest reporting system.
+///
+///
+/// The other thing needed in the above example is the using namespace
+/// line. This makes the standard messaging macros available in
+/// functions that are not member functions of a tool.  Or almost: It
+/// works fine in RootCore, but for dual-use code you need to use
+/// ANA_MSG_* instead of ATH_MSG_* for sending messages yourself.
+///
+/// The msgUserCode category I used here is meant for things like main
+/// functions, etc.  If you want to use this for other standalone
+/// functions you may consider making your own category (or indeed
+/// several).  For that you put in one of your headers the line:
+/// \code{.cpp}
+/// ANA_MSG_HEADER (msgMyCategory)
+/// \endcode
+/// and then in one of the source files:
+/// \code{.cpp}
+/// ANA_MSG_SOURCE (msgMyCategory, "MyCategory")
+/// \endcode
+/// That way users get the chosen label as part of the messages.  Plus
+/// they can actually set the message level separately for each
+/// category.
 
 
 
diff --git a/Control/AthToolSupport/AsgTools/Root/AsgTool.cxx b/Control/AthToolSupport/AsgTools/Root/AsgTool.cxx
index 586f7ab4451..cd96c0c8b15 100644
--- a/Control/AthToolSupport/AsgTools/Root/AsgTool.cxx
+++ b/Control/AthToolSupport/AsgTools/Root/AsgTool.cxx
@@ -1,4 +1,4 @@
-// $Id: AsgTool.cxx 745116 2016-05-05 15:59:32Z ssnyder $
+// $Id: AsgTool.cxx 745115 2016-05-05 15:59:29Z ssnyder $
 
 // System include(s):
 #include <iostream>
-- 
GitLab