OLD | NEW |
| (Empty) |
1 // Copyright 2006-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Helper class to aggregate the collected in-memory stats to persistent | |
17 // storage. | |
18 #ifndef OMAHA_STATSREPORT_AGGREGATOR_H__ | |
19 #define OMAHA_STATSREPORT_AGGREGATOR_H__ | |
20 | |
21 #include "metrics.h" | |
22 | |
23 namespace stats_report { | |
24 // TODO(omaha): Refactor to avoid cross platform code duplication. | |
25 | |
26 /// Wrapper class and interface for metrics aggregation. This is a platform | |
27 /// independent class and needs to be subclassed for various platforms and/or | |
28 /// metrics persistence methods | |
29 class MetricsAggregator { | |
30 public: | |
31 /// Aggregate all metrics in the associated collection | |
32 /// @returns true iff aggregation started successfully, false otherwise. | |
33 bool AggregateMetrics(); | |
34 | |
35 protected: | |
36 MetricsAggregator(); | |
37 MetricsAggregator(const MetricCollection &coll); | |
38 virtual ~MetricsAggregator(); | |
39 | |
40 /// Start aggregation. Override this to grab locks, open files, whatever | |
41 /// needs to happen or can expedite the individual aggregate steps. | |
42 /// @return true on success, false on failure. | |
43 /// @note aggregation will not progress if this function returns false | |
44 virtual bool StartAggregation(); | |
45 virtual void EndAggregation(); | |
46 | |
47 virtual void Aggregate(CountMetric &metric) = 0; | |
48 virtual void Aggregate(TimingMetric &metric) = 0; | |
49 virtual void Aggregate(IntegerMetric &metric) = 0; | |
50 virtual void Aggregate(BoolMetric &metric) = 0; | |
51 | |
52 private: | |
53 DISALLOW_EVIL_CONSTRUCTORS(MetricsAggregator); | |
54 | |
55 const MetricCollection &coll_; | |
56 }; | |
57 | |
58 } // namespace stats_report | |
59 | |
60 #endif // OMAHA_STATSREPORT_AGGREGATOR_H__ | |
OLD | NEW |