-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilterEvents.hpp
73 lines (64 loc) · 2.44 KB
/
FilterEvents.hpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/** @file
* @brief Filter Events
*
* This file contains the filter event class to filter events from the Common Storage Component
* @author José Manuel Ramos Ruiz
* @date 23 Dic 2018 - Revisión 1.0
*
* @see @ref FilterEvents_legal_note_sec
*
* @section FilterEvents_legal_note_sec Legal Note
* Only for Qustodio hiring purposes
*
* @section FilterEvents_intro_sec Introduction
*
* This is the controller of a Browsing Element to handle concurrenly in C++11
*
* @section FilterEvents_revision_sec Versions
* Versión | Fecha | Autor | Comentarios adicionales
* ------: | :--------: | :-------------------------- | -----------------------
* 1.0 | 2018-12-23 | José Manuel Ramos Ruiz | Initial Release
*
* @section FilterEvents_install_sec Use
*
* @subsection FilterEvents_step1 Requirements
* Requires C++11 to use it correctly
*/
#ifndef FILTEREVENTS_HPP
#define FILTEREVENTS_HPP
#include "CommonStorageComponent.hpp"
#include "BrowsingEvent.hpp"
namespace Qustodio
{
class FilterEvents
{
public:
FilterEvents ( Qustodio::CommonStorageComponent &commonStorageComponent, const std::string &filter = 0 );
/**
* @brief Filters all captured events using the #regexString filter
* @param regexString [in] the filter
*/
void filterBadWords ( const std::string ®exString );
/**
* @brief Show the number of filtered results
*/
void showFilteredResultsCount ( void );
private:
/**
* @brief Given a #regexString, filters all #BrowsingEvent to match the filter
* @param element [in] a #BrowsingElement
* @param regexString [in] the filter
*/
void filterUrl ( Qustodio::BrowsingEvent &element, const std::string ®exString);
ComposerPool pool; //< The thread pool to filter the Events
std::mutex browsingEventMutex; //< The synchronize mechanism to make insertions sequentially
Qustodio::CommonStorageComponent &mCommonStorageComponent; //< Access to the CommonStorageComponent
std::string mFilter; //< The filter used
uint32_t countFilteredElements;//< The amount of filtered elements
// Can't be auto!
std::shared_ptr <std::vector< Qustodio::BrowsingEvent>> browsingEvent =
std::make_shared < std::vector < Qustodio::BrowsingEvent >> (
std::vector< Qustodio::BrowsingEvent >() ); //< The vector of #BrowsingEvent
};
} // namespace Qustodio
#endif //FILTEREVENTS_HPP