Gabriele Contini
2019-09-10 82f9d834ad772b2f16b6524f679d14d8a7afe881
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * EventRegistry.h
 *
 *  Created on: Mar 30, 2014
 *      
 */
 
#ifndef EVENTREGISTRY_H_
#define EVENTREGISTRY_H_
 
#include "../api/datatypes.h"
#include <vector>
#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);*/
 
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;
public:
    EventRegistry();
    //operator <<
    void append(const EventRegistry& eventRegistry);
    void turnLastEventIntoError();
    bool turnEventIntoError(EVENT_TYPE event);
    bool turnErrosIntoWarnings();
    /**
     * @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);
 
};
}
#endif /* EVENTREGISTRY_H_ */