-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathStatsWindowCount.cpp
47 lines (38 loc) · 1.5 KB
/
StatsWindowCount.cpp
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
#include "StatsWindowCount.h"
#include "StatsPerHost.h"
#include "StatsPerService.h"
#include "StatsPerServiceWithSrcPort.h"
#include "FeatureUpdaterCount.h"
namespace FeatureExtractor {
template<class TStatsPerHost, class TStatsPerService>
StatsWindowCount<TStatsPerHost, TStatsPerService>::StatsWindowCount()
: StatsWindow<TStatsPerHost, TStatsPerService>(new FeatureUpdaterCount())
, window_size(100) // Default size = 100 conversations
{
}
template<class TStatsPerHost, class TStatsPerService>
StatsWindowCount<TStatsPerHost, TStatsPerService>::StatsWindowCount(unsigned int window_size)
: StatsWindow<TStatsPerHost, TStatsPerService>(new FeatureUpdaterCount())
, window_size(window_size)
{
}
template<class TStatsPerHost, class TStatsPerService>
StatsWindowCount<TStatsPerHost, TStatsPerService>::~StatsWindowCount()
{
}
template<class TStatsPerHost, class TStatsPerService>
void StatsWindowCount<TStatsPerHost, TStatsPerService>::perform_window_maintenance(const Conversation *new_conv)
{
while (this->finished_convs.size() > window_size) {
Conversation *conv = this->finished_convs.front();
this->finished_convs.pop();
// Exclude removed conversation from stats
this->report_conversation_removal(conv);
// Object commits suicide if no more references to it
conv->deregister_reference();
}
}
// Explicit template specialisation
template class StatsWindowCount<StatsPerHost, StatsPerService>;
template class StatsWindowCount<StatsPerHost, StatsPerServiceWithSrcPort>;
}