From f0f4aa977c66799db42cb5622b796ce705396829 Mon Sep 17 00:00:00 2001
From: Martin Killenberg <martin.killenberg@desy.de>
Date: Mon, 7 Aug 2017 15:11:19 +0200
Subject: [PATCH] starting to implement the VariableMapper. Compiles, but not
 implemented and used yet.

---
 include/VariableMapper.h     | 47 ++++++++++++++++++++++++++++++++++++
 src/VariableMapper.cc        | 12 +++++++++
 tests/testVariableMapper.cpp |  8 ++++++
 3 files changed, 67 insertions(+)
 create mode 100644 include/VariableMapper.h
 create mode 100644 src/VariableMapper.cc
 create mode 100644 tests/testVariableMapper.cpp

diff --git a/include/VariableMapper.h b/include/VariableMapper.h
new file mode 100644
index 0000000..fd57a27
--- /dev/null
+++ b/include/VariableMapper.h
@@ -0,0 +1,47 @@
+#ifndef CHIMERATK_DOOCS_ADAPTER_VARIABLE_MAPPER_H
+#define CHIMERATK_DOOCS_ADAPTER_VARIABLE_MAPPER_H
+
+#include <string>
+#include <map>
+#include <set>
+
+namespace ChimeraTK{
+
+  class VariableMapper{
+  public:
+    static VariableMapper & getInstance();
+    void prepareOutput(std::string xmlFile, std::set< std::string > inputVariables);
+
+    // PropertyAttributes are used in the property description itself, and
+    // as default values (global and in the locations)
+    struct PropertyAttributes{
+      bool hasHistory;
+      bool isWriteable;
+    };
+
+    // extends the PropertyAttributes by a name
+    // FIXME: should sort by name to put it into a set?
+    struct PropertyDescription:
+      public PropertyAttributes{
+      std::string location;
+      std::string name;
+    };
+
+    std::map< std::string, PropertyDescription > getPropertiesInLocation(std::string location);
+
+    VariableMapper(VariableMapper &)=delete;
+    void operator=(VariableMapper const &)=delete;
+    
+  private:
+    VariableMapper()=default;
+
+    std::map<std::string, PropertyAttributes> locationDefaults;
+    PropertyAttributes globalDefaults;
+
+    // PropertyDescriptions, sorted by input, i.e. the ChimeraTK PV name
+    std::map<std::string, PropertyDescription> inputSortedDescriptions;
+  };
+
+} // namespace ChimeraTK
+
+#endif // CHIMERATK_DOOCS_ADAPTER_VARIABLE_MAPPER_H
diff --git a/src/VariableMapper.cc b/src/VariableMapper.cc
new file mode 100644
index 0000000..6bd8004
--- /dev/null
+++ b/src/VariableMapper.cc
@@ -0,0 +1,12 @@
+#include "VariableMapper.h"
+
+namespace ChimeraTK{
+  VariableMapper & VariableMapper::getInstance(){
+    static VariableMapper instance;
+    return instance;
+  }
+
+  
+
+} // namespace ChimeraTK
+
diff --git a/tests/testVariableMapper.cpp b/tests/testVariableMapper.cpp
new file mode 100644
index 0000000..591986f
--- /dev/null
+++ b/tests/testVariableMapper.cpp
@@ -0,0 +1,8 @@
+#define BOOST_TEST_MODULE DoocsProcessArrayTest
+// Only after defining the name include the unit test header.
+#include <boost/test/included/unit_test.hpp>
+//#include <boost/test/test_case_template.hpp>
+
+BOOST_AUTO_TEST_CASE( testCreation ){
+  VariableMapper & vm = VariableMapper::getInstance();
+}
-- 
GitLab