1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #ifndef SYZYGY_REFINERY_VALIDATORS_VALIDATOR_H_
16 : #define SYZYGY_REFINERY_VALIDATORS_VALIDATOR_H_
17 :
18 : #include "syzygy/refinery/process_state/process_state.h"
19 :
20 : namespace refinery {
21 :
22 : // Fwd
23 : class ValidationReport;
24 :
25 : // The interface implemented by validators. Each validator processes the process
26 : // state in search of expectation violations or inconsistencies, which are then
27 : // added to the validation report.
28 : class Validator {
29 : public:
30 E : virtual ~Validator() = 0 {};
31 :
32 : enum ValidationResult {
33 : VALIDATION_COMPLETE,
34 : VALIDATION_ERROR,
35 : };
36 :
37 : // Validate @p process_state and update the validation @p report if necessary.
38 : // @param process_state the representation of a process.
39 : // @param report the validation report to suppplement with detected
40 : // expectation violations or inconsistencies.
41 : // @returns a validation result. A validator should not be invoked again after
42 : // it's returned VALIDATION_COMPLETE. If a validator returns
43 : // VALIDATION_ERROR @p report may be inconsistent.
44 : virtual ValidationResult Validate(ProcessState* process_state,
45 : ValidationReport* report) = 0;
46 : };
47 :
48 : } // namespace refinery
49 :
50 : #endif // SYZYGY_REFINERY_VALIDATORS_VALIDATOR_H_
|