1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // vi: set et ts=4 sw=2 sts=2: 3 4 #ifndef DUNE_TYPETREE_LEAFNODE_HH 5 #define DUNE_TYPETREE_LEAFNODE_HH 6 7 #include <dune/typetree/nodetags.hh> 8 #include <cstddef> 9 #include <type_traits> 10 11 namespace Dune { 12 namespace TypeTree { 13 14 /** \addtogroup Nodes 15 * \ingroup TypeTree 16 * \{ 17 */ 18 19 /** \brief Base class for leaf nodes in a \ref TypeTree. 20 * 21 * Every leaf type in a \ref TypeTree must be derived from this 22 * class. 23 */ 24 25 class LeafNode 26 { 27 28 public: 29 30 //! Mark this class as a leaf in a \ref TypeTree. 31 static const bool isLeaf = true; 32 33 //! Mark this class as a non power in the \ref TypeTree. 34 static const bool isPower = false; 35 36 //! Mark this class as a non composite in the \ref TypeTree. 37 static const bool isComposite = false; 38 39 //! Leafs have no children. 40 static const std::size_t CHILDREN = 0; 41 42 //! The type tag that describes a LeafNode. 43 typedef LeafNodeTag NodeTag; 44 45 static constexpr auto degree() 46 { 47 return std::integral_constant<std::size_t,0>{}; 48 } 49 50 protected: 51 52 //! Default constructor. 53 /** 54 * The default constructor is protected, as LeafNode is a utility 55 * class that needs to be filled with meaning by subclassing it 56 * and adding useful functionality to the subclass. 57 */ 58 LeafNode() {} 59 }; 60 61 //! \} group Nodes 62 63 } // namespace TypeTree 64 } //namespace Dune 65 66 #endif // DUNE_TYPETREE_POWERNODE_HH