[Dune] bug #10 Interface Implementation Check.

Robert Kloefkorn robertk at mathematik.uni-freiburg.de
Thu Oct 19 15:59:28 CEST 2006


Hi Dune,

when using static polymorphism, one gets seg faults, if an interface
method is not implemented in the Implementation class.
I just invented a simple check to throw an exception, when an interface
method is not implemented, but should be implemented.

To call that check just include

#include <dune/common/bartonnackmanifcheck.hh>


and invoke (the grids maxLevel method for example)

  int maxLevel() const
  {
    CHECK_INTERFACE_IMPLEMENTATION(asImp().maxLevel());
    return asImp().maxLevel();
  }
When using template methods you have to add another pair of brakets ()
arround the mehtod to call, for example:

   //! Iterator to first entity of given codim on level
  template<int cd, PartitionIteratorType pitype>
  typename Codim<cd>::template Partition<pitype>::LevelIterator lbegin
(int level) const
  {
    CHECK_INTERFACE_IMPLEMENTATION((asImp().template
lbegin<cd,pitype>(level)));
    return asImp().template lbegin<cd,pitype>(level);
  }

We have to add this to the other classes using Barton-Nackman. The
Grid-Class is done.

Regards

R

-- 

  Robert Klöfkorn           <robertk at mathematik.uni-freiburg.de>

  Mathematisches Institut              Tel: +49 (0) 761 203 5631
  Abt. für Angewandte Mathematik       Fax: +49 (0) 761 203 5632
  Universität Freiburg
  Hermann-Herder-Str. 10
  79104 Freiburg

  http://www.mathematik.uni-freiburg.de/IAM/homepages/robertk




More information about the Dune mailing list