From 274491c8464974b17980f293ce0267f57468ff07 Mon Sep 17 00:00:00 2001
From: Andreas Lauser <and@poware.org>
Date: Fri, 23 Sep 2011 15:34:31 +0000
Subject: [PATCH] property system: add SET_STRING_PROP macro

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@6655 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 dumux/common/propertysystem.hh | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/dumux/common/propertysystem.hh b/dumux/common/propertysystem.hh
index 154f4b17f8..5997842b60 100644
--- a/dumux/common/propertysystem.hh
+++ b/dumux/common/propertysystem.hh
@@ -327,18 +327,37 @@ int TypeTagInfo<FA_TTAG_(__VA_ARGS__)>::foo =                           \
  * use this macro, the property tag "Scalar" needs to be defined for
  * the real type tag.
  */
-#define SET_SCALAR_PROP(EffTypeTagName, PropTagName, Value)             \
+#define SET_SCALAR_PROP(EffTypeTagName, PropTagName, ...)               \
     SET_PROP_(EffTypeTagName,                                           \
               /*kind=*/"scalar",                                        \
               PropTagName,                                              \
-              /*value=*/#Value)                                         \
+              /*value=*/__VA_ARGS__)                                    \
     {                                                                   \
         typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;   \
     public:                                                             \
         typedef Scalar type;                                            \
-        static constexpr Scalar value = Value;                          \
+        static constexpr Scalar value = __VA_ARGS__;                    \
     }
 
+/*!
+ * \brief Set a property to a simple constant string value.
+ *
+ * The constant can be accessed by the 'value' attribute and is of
+ * type std::string.
+ */
+#define SET_STRING_PROP(EffTypeTagName, PropTagName, ...)               \
+    SET_PROP_(EffTypeTagName,                                           \
+              /*kind=*/"string",                                        \
+              PropTagName,                                              \
+              /*value=*/__VA_ARGS__)                                    \
+    {                                                                   \
+    public:                                                             \
+        typedef std::string type;                                       \
+        static const std::string value;                                 \
+    };                                                                  \
+    template <class TypeTag>                                            \
+    const std::string Property<TypeTag, TTAG(EffTypeTagName), PTAG(PropTagName)>::value(__VA_ARGS__);
+
 /*!
  * \brief Get the property for a type tag.
  *
@@ -968,9 +987,9 @@ inline void print_(const std::string &typeTagName,
            << key.propertyKind() << " " << key.propertyName();
         if (key.propertyKind() != "opaque")
             os << " = '" << key.propertyValue() << "'";
-        os << " (" << key.fileDefined()
+        os << " defined at " << key.fileDefined()
            << ":" << key.lineDefined()
-           << ")\n";
+           << "\n";
         printedProperties.insert(key.propertyName());
     };
     if (!somethingPrinted)
-- 
GitLab