1 /** 2 Copyright: Copyright (c) 2018, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 */ 10 module dextool.plugin.mutate.backend.report.type; 11 12 import dextool.type : AbsolutePath, Path; 13 14 import dextool.plugin.mutate.backend.database : Database, IterateMutantRow, 15 FileRow, FileMutantRow; 16 import dextool.plugin.mutate.type : MutationKind; 17 18 alias SimpleWriter = void delegate(const(char)[]) @safe; 19 20 /** Generic interface that a reporter can implement. 21 * 22 * Event order: 23 * * mutationKindEvent 24 * * locationStatEvent 25 * * locationEvent. Looping over every mutant. 26 * * locationEndEvent 27 * * locationStatEvent 28 * * statEvent 29 */ 30 @safe interface ReportEvent { 31 /// The printer is informed of what kind of mutants there are. 32 void mutationKindEvent(const MutationKind[]); 33 void locationStartEvent(ref Database db); 34 void locationEvent(ref Database db, const ref IterateMutantRow); 35 void locationEndEvent(); 36 void locationStatEvent(); 37 void statEvent(ref Database db); 38 } 39 40 /** Iterate over all mutants in a file. 41 */ 42 @safe interface FileReport { 43 /// A mutant in that file. 44 void fileMutantEvent(const ref FileMutantRow); 45 46 /// The file has finished being processed. 47 void endFileEvent(ref Database db); 48 } 49 50 /** Iterate over all files. 51 */ 52 @safe interface FilesReporter { 53 /// The users input of what mutants to report. 54 void mutationKindEvent(const MutationKind[]); 55 56 /// Get the reporter that should be used to report all mutants in a file. 57 FileReport getFileReportEvent(ref Database db, const ref FileRow); 58 59 /// All files have been reported. 60 void postProcessEvent(ref Database db); 61 62 /// The last event to be called. 63 /// Sync any IO if needed before destruction. 64 void endEvent(ref Database db); 65 }