Source release v3.5.0
This commit is contained in:
46
metrics/include/metric_serialization.h
Normal file
46
metrics/include/metric_serialization.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This file contains the declarations for the Metric class and related
|
||||
// types.
|
||||
#ifndef WVCDM_METRICS_METRIC_SERIALIZATION_H_
|
||||
#define WVCDM_METRICS_METRIC_SERIALIZATION_H_
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
// The MetricSerializer is implemented by the code that instantiates
|
||||
// MetricSerializable instances. The caller provides this MetricSerializer
|
||||
// instance to MetricSerializable::Serialize. In turn, Serialize will make a
|
||||
// call to Set* for each value to be Serialized. The MetricSerialiable
|
||||
// implementation may set zero or more values on the MetricSerializer.
|
||||
class MetricSerializer {
|
||||
public:
|
||||
virtual ~MetricSerializer() {};
|
||||
|
||||
// The metric_id is the metric name, plus the metric part name, and the
|
||||
// metric field name/value string. E.g.
|
||||
// name: "drm/cdm/decrypt/duration"
|
||||
// part: "mean"
|
||||
// field name/value string: "{error_code:0&buffer_size:1024}"
|
||||
// becomes: "drm/cdm/decrypt/duration/mean/{error_code:0&buffer_size:1024}".
|
||||
virtual void SetString(const std::string& metric_id,
|
||||
const std::string& value) = 0;
|
||||
virtual void SetInt32(const std::string& metric_id, int32_t value) = 0;
|
||||
virtual void SetInt64(const std::string& metric_id, int64_t value) = 0;
|
||||
virtual void SetDouble(const std::string& metric_id, double value) = 0;
|
||||
};
|
||||
|
||||
// This abstract class merely provides the definition for serializing the value
|
||||
// of the metric.
|
||||
class MetricSerializable {
|
||||
public:
|
||||
virtual ~MetricSerializable() { }
|
||||
// Serialize metric values to the MetricSerializer. |serializer| must
|
||||
// not be null and is owned by the caller.
|
||||
virtual void Serialize(MetricSerializer* serializer) = 0;
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // WVCDM_METRICS_METRIC_SERIALIZATION_H_
|
||||
Reference in New Issue
Block a user