From 5a8a12d7a2c69610cd7a9a00ed1b3579b750a914 Mon Sep 17 00:00:00 2001 From: gcontini <1121667+gcontini@users.noreply.github.com> Date: 周六, 16 11月 2019 21:39:10 +0800 Subject: [PATCH] issue #42 #38 \n review build system, \n issue #38 added clang format --- src/library/base/EventRegistry.h | 48 ++++++++++++++++++++++++++++-------------------- 1 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/library/base/EventRegistry.h b/src/library/base/EventRegistry.h index c8bc3b9..af5389b 100644 --- a/src/library/base/EventRegistry.h +++ b/src/library/base/EventRegistry.h @@ -2,7 +2,7 @@ * EventRegistry.h * * Created on: Mar 30, 2014 - * + * */ #ifndef EVENTREGISTRY_H_ @@ -10,43 +10,51 @@ #include "../api/datatypes.h" #include <vector> +#include <map> +#include <set> #include <string> namespace license { -/* - AuditEvent error_event_builder(EVENT_TYPE event); - AuditEvent audit_event_builder(EVENT_TYPE event, SEVERITY severity); - AuditEvent audit_event_builder(EVENT_TYPE event, SEVERITY severity, - const string& eventParameter);*/ - +/** + * Tracks the events relative to a license and provide explanation regarding + * failures to verify licenses. + */ class EventRegistry { private: friend EventRegistry& operator<<(EventRegistry&, AuditEvent&); friend EventRegistry& operator<<(EventRegistry&, EventRegistry&); - //TODO change into map + friend std::ostream & operator << (std::ostream &out, const EventRegistry &er); + std::vector<AuditEvent> logs; - //Forbid copy - //EventRegistry(const EventRegistry& that) = delete; + /** + * For every license keep track of the events who progressed most + * in the validation process + */ + std::map<std::string,size_t> mostAdvancedLogIdx_by_LicenseId; + int current_validation_step; + public: EventRegistry(); //operator << void append(const EventRegistry &eventRegistry); - void turnLastEventIntoError(); - bool turnEventIntoError(EVENT_TYPE event); - bool turnErrosIntoWarnings(); /** + * Turn the event warning for the license with the most advanced status + * into an error. + */ + bool turnWarningsIntoErrors(); + bool turnErrorsIntoWarnings(); + bool isGood() const; + /** + * Return the last failure (event with warn or error status) + * for the license with the most advanced status. * @return NULL if no failures are found. */ AuditEvent const* getLastFailure() const; - bool isGood() const; - - void addError(EVENT_TYPE event); - void addEvent(EVENT_TYPE event, SEVERITY severity); - void addEvent(EVENT_TYPE event, SEVERITY severity, - const std::string &eventParameter); + void addEvent(EVENT_TYPE event, const std::string &licenseLocationId); + void addEvent(EVENT_TYPE event, const char *licenseLocationId = nullptr, + const char *info = nullptr); void exportLastEvents(AuditEvent *auditEvents, int nlogs); - }; } #endif /* EVENTREGISTRY_H_ */ -- Gitblit v1.9.1