erster versuch der min max ausgibt
[201903hackathon.git] / inc / sample_utils / EventReporter.hpp
1 /****************************************************************************\
2  * Copyright (C) 2018 Infineon Technologies & pmdtechnologies ag
3  *
4  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
5  * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
6  * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
7  * PARTICULAR PURPOSE.
8  *
9  \****************************************************************************/
10
11 #pragma once
12
13 #include <royale/IEvent.hpp>
14
15 namespace sample_utils
16 {
17     /**
18      * This class reports on events from Royale. Depending on the event's severity, this class
19      * writes the description of the event to standard output or standard error. Information and
20      * warnings are written to standard output. Non-fatal errors and fatal errors are written to
21      * standard error.
22      */
23     class EventReporter : public royale::IEventListener
24     {
25     public:
26         virtual ~EventReporter() = default;
27
28         /**
29          * @inheritdoc
30          */
31         virtual void onEvent (std::unique_ptr<royale::IEvent> &&event) override
32         {
33             royale::EventSeverity severity = event->severity();
34
35             switch (severity)
36             {
37                 case royale::EventSeverity::ROYALE_INFO:
38                 case royale::EventSeverity::ROYALE_WARNING:
39                     std::cout << event->describe() << std::endl;
40                     break;
41                 case royale::EventSeverity::ROYALE_ERROR:
42                 case royale::EventSeverity::ROYALE_FATAL:
43                     std::cerr << event->describe() << std::endl;
44                     break;
45             }
46         }
47     };
48 }