Commit 940b70ad authored by Martin Schneider's avatar Martin Schneider
Browse files

[metadata] Add function to write TypeTag tree

parent ec015117
Pipeline #5932 waiting for manual action with stages
......@@ -33,7 +33,12 @@
#include <nlohmann/json.hpp>
#include <dumux/common/typetraits/isvalid.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/indices.hh>
#include "dumux/common/properties/propertysystem.hh"
#include <dumux/common/typetraits/utility.hh>
#include "dumux/common/typetraits/isvalid.hh"
#include "dumux/assembly/fvassembler.hh"
#include "dumux/assembly/diffmethod.hh"
......@@ -70,6 +75,29 @@ struct isGridVariables
{}
};
std::string removeNamespace(std::string&& s)
{
std::size_t last = s.find_last_of("::");
if(last != std::string::npos)
s.erase(0, last+1);
return std::move(s);
}
template<class TTagTuple, class Collector>
void collectTypeTagsFromTuple(Collector& collector, int depth=0, int parentBranch=-1)
{
using namespace Dune::Hybrid;
forEach(std::make_index_sequence<std::tuple_size_v<TTagTuple>>{}, [&](auto i)
{
using type = typename std::tuple_element<i, TTagTuple>::type;
collector.push_back(std::tuple<int, int, std::string>{depth, parentBranch, removeNamespace(Dune::className<type>())});
if constexpr (Dumux::Properties::Detail::hasParentTypeTag<type>(int{}))
collectTypeTagsFromTuple<typename type::InheritsFrom>(collector, int{depth+1}, i);
});
}
} // end namespace Detail
/*!
......@@ -120,6 +148,7 @@ public:
return std::move(s);
}
private:
JsonTree tree_;
};
......@@ -167,6 +196,14 @@ auto collectMetaData(Collector& collector, const GridVariables& gv, bool hideTem
obj["Type"] = Metadata::className(gv, hideTemplates);
}
template<class TypeTag, class Collector>
auto collectTypeTags(Collector& collector)
{
auto& obj = collector["TTags"];
obj = nlohmann::json::array();
Detail::collectTypeTagsFromTuple<std::tuple<TypeTag>>(obj);
}
} // end namespace Dumux
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment