Class

CGAL::Modifier_base<R>

Definition

Modifier_base<R> is an abstract base class providing the interface for any modifier. A modifier is a function object derived from Modifier_base<R> that implements the pure virtual member function operator(), which accepts a single reference parameter R& on which the modifier is allowed to work. R is the type of the internal representation that is to be modified.

#include <CGAL/Modifier_base.h>

Types

typedef R Representation; the internal representation type.

Operations

virtual void modifier.operator() ( R& rep)
Postcondition: rep is a valid representation.

Example

The following fragment defines a class A with an internal representation i of type int. It provides a member function delegate(), which gives a modifier access to the internal variable and checks validity thereafter. The example modifier sets the internal variable to 42. The example function applies the modifier to an instance of class A.

class A {
    int i;  // protected internal representation
public:
    void delegate( CGAL::Modifier_base<int>& modifier) {
        modifier(i);
        CGAL_postcondition( i > 0);  // check validity
    }
};

struct Modifier : public CGAL::Modifier_base<int> {
    void operator()( int& rep) { rep = 42;}
};

void use_it() {
    A a;
    Modifier m;
    a.delegate(m);  // a.i == 42 and A has checked that A::i > 0.
}