summaryrefslogtreecommitdiff
path: root/src/core/common/Location.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-27 15:37:47 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-27 15:37:47 +0100
commit3334e1ba2417fb726f52963270f1367fac45265c (patch)
tree5f85f35610e140d984f4cd5df780a5e7b4469c31 /src/core/common/Location.hpp
parent13393c5e1e3261176d9b750cc10b9c62b740f08c (diff)
Adapted LoggableException to use the same code for obtaining the location of an object reference or pointer as the Logger class
Diffstat (limited to 'src/core/common/Location.hpp')
-rw-r--r--src/core/common/Location.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/common/Location.hpp b/src/core/common/Location.hpp
index 4b70619..93e5d8e 100644
--- a/src/core/common/Location.hpp
+++ b/src/core/common/Location.hpp
@@ -345,6 +345,32 @@ public:
{
return SourceRange::isValid() && sourceId != InvalidSourceId;
}
+
+ /**
+ * Calls the getLocation function on the given reference.
+ *
+ * @param obj is the object on which the getLocation function should be
+ * called.
+ * @return the SourceLocation returned by the getLocation function.
+ */
+ template <typename T>
+ static SourceLocation location(const T &obj)
+ {
+ return obj.getLocation();
+ }
+
+ /**
+ * Calls the getLocation function on the given pointer.
+ *
+ * @param obj is the object on which the getLocation function should be
+ * called.
+ * @return the SourceLocation returned by the getLocation function.
+ */
+ template <typename T>
+ static SourceLocation location(const T *obj)
+ {
+ return obj->getLocation();
+ }
};
/**