Loki
0.1.7
|
#include <Checker.h>
Inherits ExceptionPolicy< Host >.
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 |
This class determines if a function violated any class invariant, but it also determines if a function fulfills its contract with client code. In the "Design by Contract" paradigm, each function has certain pre-conditions and post-conditions which may differ from the class invariants. This asserts if a check for an invariant fails as well as if any pre- or post-condition fails. It also demonstrate which exception safety level a function provides.
|
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().
|
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().
|
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().