Store transaction id in thread local storage

Implement the transaction id variable in a .C file and
create an sdbusplus library with it.
Create interfaces to set/get the transaction id.

Change-Id: Id1df415d9cc05e4b96817c7a05c1be7052d05c65
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 377c62d..cf70efe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,5 +22,14 @@
 	sdbusplus/utility/type_traits.hpp \
 	sdbusplus/vtable.hpp
 
+LIBSDBUSPLUS_FILES = \
+	sdbusplus/server/transaction.cpp
+
+libsdbusplusdir = ${libdir}
+libsdbusplus_LTLIBRARIES = libsdbusplus.la
+libsdbusplus_la_SOURCES = $(LIBSDBUSPLUS_FILES)
+libsdbusplus_la_LDFLAGS = $(SYSTEMD_LIBS) -version-info 1:0:0 -shared
+libsdbusplus_la_CXXFLAGS = $(SYSTEMD_CFLAGS)
+
 endif
 SUBDIRS = test tools
diff --git a/sdbusplus/server/transaction.cpp b/sdbusplus/server/transaction.cpp
new file mode 100644
index 0000000..be91b8f
--- /dev/null
+++ b/sdbusplus/server/transaction.cpp
@@ -0,0 +1,18 @@
+#include "transaction.hpp"
+
+namespace sdbusplus
+{
+namespace server
+{
+namespace transaction
+{
+namespace details
+{
+
+// Transaction Id
+thread_local uint64_t id = 0;
+
+} // namespace details
+} // namespace transaction
+} // namespace server
+} // namespace sdbusplus
diff --git a/sdbusplus/server/transaction.hpp b/sdbusplus/server/transaction.hpp
index c23bc04..0dbab5f 100644
--- a/sdbusplus/server/transaction.hpp
+++ b/sdbusplus/server/transaction.hpp
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <thread>
 #include <sdbusplus/bus.hpp>
 
 namespace sdbusplus
@@ -8,6 +9,13 @@
 {
 namespace transaction
 {
+namespace details
+{
+
+// Transaction Id
+extern thread_local uint64_t id;
+
+} // namespace details
 
 struct Transaction
 {
@@ -66,3 +74,32 @@
 };
 
 } // namespace std
+
+namespace sdbusplus
+{
+namespace server
+{
+namespace transaction
+{
+
+/** @brief Get transaction id
+  *
+  * @return The value of the transaction id
+  */
+inline uint64_t get_id()
+{
+    return details::id;
+}
+
+/** @brief Set transaction id
+  *
+  * @param[in] value - Desired value for the transaction id
+  */
+inline void set_id(uint64_t value)
+{
+    details::id = value;
+}
+
+} // namespace transaction
+} // namespace server
+} // namespace sdbusplus