From 8d405b265285c368df2e9cf1c14acee7532e0ee7 Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: ćšć, 29 5æ 2025 18:14:38 +0800 Subject: [PATCH] Merge branch 'develop' of http://139.9.88.116:3000/r/module/open-license-manager into develop --- src/library/base/EventRegistry.h | 67 +++++++++++++++++++-------------- 1 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/library/base/EventRegistry.h b/src/library/base/EventRegistry.h index d86ea77..a6260b2 100644 --- a/src/library/base/EventRegistry.h +++ b/src/library/base/EventRegistry.h @@ -2,51 +2,60 @@ * EventRegistry.h * * Created on: Mar 30, 2014 - * + * */ #ifndef EVENTREGISTRY_H_ #define EVENTREGISTRY_H_ -#include "../api/datatypes.h" +#include <licensecc/datatypes.h> + #include <vector> +#include <map> +#include <set> #include <string> namespace license { -using namespace std; -/* -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 - vector<AuditEvent> logs; - //Forbid copy - //EventRegistry(const EventRegistry& that) = delete; + friend EventRegistry &operator<<(EventRegistry &, AuditEvent &); + friend EventRegistry &operator<<(EventRegistry &, EventRegistry &); + friend std::ostream &operator<<(std::ostream &out, const EventRegistry &er); + + std::vector<AuditEvent> logs; + /** + * 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(); + // operator << + void append(const EventRegistry &eventRegistry); /** + * 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 string& eventParameter); - void exportLastEvents(AuditEvent* auditEvents,int nlogs); - + const AuditEvent *getLastFailure() const; + void addEvent(LCC_EVENT_TYPE event, const std::string &licenseLocationId); + void addEvent(LCC_EVENT_TYPE event, const char *licenseLocationId = nullptr, const char *info = nullptr); + void exportLastEvents(AuditEvent *auditEvents, int nlogs); + std::string to_string() const; }; -} +} // namespace license #endif /* EVENTREGISTRY_H_ */ -- Gitblit v1.9.1