#include <Checker.h>
Public Types | |
typedef bool(Host::* | Validator )(void) const |
Signature for the validation function. | |
Public Member Functions | |
ContractChecker (const Host *host, Validator validator, Validator pre=0, Validator post=0) | |
~ContractChecker (void) | |
bool | Check (void) const |
Loki::ContractChecker< Host, ExceptionPolicy >::ContractChecker | ( | const Host * | host, | |
Validator | validator, | |||
Validator | pre = 0 , |
|||
Validator | post = 0 | |||
) | [inline] |
The constructor makes sure the host is valid at the time the checker was created, thus insuring the host object was not corrupt from the start.
References Loki::ContractChecker< Host, ExceptionPolicy >::Check().
Loki::ContractChecker< Host, ExceptionPolicy >::~ContractChecker | ( | void | ) | [inline] |
The destructor checks if any Host invariants failed, and then calls the ExceptionPolicy's Check function to determine what to do in case of an exception.
References Loki::ContractChecker< Host, ExceptionPolicy >::Check().
bool Loki::ContractChecker< Host, ExceptionPolicy >::Check | ( | void | ) | const [inline] |
This first checks the invariants for ContractChecker, and then calls the validator function for the host to make sure no class invariants were broken by the host within the Host's member function body. The host member function can call Check directly to verify the object remains valid at any time. This does not care if the pre- and post-condition validator pointers are null since a host class may pass in NULL pointers for either to indicate the pre-conditions or post-conditions are the same as the overall class invariants.
Referenced by Loki::ContractChecker< Host, ExceptionPolicy >::ContractChecker(), and Loki::ContractChecker< Host, ExceptionPolicy >::~ContractChecker().