SEValidationTarget.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5
6#include "cdm/CommonDefs.h"
7#include "cdm/engine/SEDataRequest.h"
8#include "cdm/engine/SEEventManager.h"
9
10class CDM_DECL SEValidationTarget : public Loggable
11{
12 friend class PBValidation;//friend the serialization class
13protected:
14 SEValidationTarget() { Clear(); }
15public:
16 virtual ~SEValidationTarget() = default;
17
18 virtual void Clear();
19 virtual bool IsValid();
20
21 std::string GetHeader() const { return m_Header; }
22 void SetHeader(const std::string& h) { m_Header = h; }
23
24 std::string GetReference() const { return m_Reference; }
25 void SetReference(const std::string& c) { m_Reference = c; }
26
27 std::string GetNotes() const { return m_Notes; }
28 void SetNotes(const std::string& n) { m_Notes = n; }
29
30 double GetTargetMaximum() const { return m_TargetMaximum; }
31 double GetTargetMinimum() const { return m_TargetMinimum; }
32 double GetTarget() const { return m_Target; }
33
34protected:
35 std::string m_Header;
36 std::string m_Reference;
37 std::string m_Notes;
38
39 double m_Target;
42};
43
45{
46 friend class PBValidation;//friend the serialization class
47public:
48 enum class eComparisonType { None=0, EqualToValue, EqualToSegment, GreaterThanValue, GreaterThanSegment,
49 LessThanValue, LessThanSegment, TrendsToValue, TrendsToSegment, Range };
51 virtual ~SESegmentValidationTarget() = default;
52
53 static bool SerializeToString(const std::vector<const SESegmentValidationTarget*>& src, std::string& output, eSerializationFormat m, Logger* logger);
54 static bool SerializeToFile(const std::vector<const SESegmentValidationTarget*>& src, const std::string& filename, Logger* logger);
55 static bool SerializeFromString(const std::string& src, std::vector<SESegmentValidationTarget*>& dst, eSerializationFormat m, Logger* logger);
56 static bool SerializeFromFile(const std::string& filename, std::vector<SESegmentValidationTarget*>& dst, Logger* logger);
57
58 void Clear() override;
59 eComparisonType GetComparisonType() const { return m_ComparisonType; }
60
61 int GetTargetSegment() const { return m_TargetSegment; }
62
63 void SetEqualToSegment(int segment);
64 void SetEqualToValue(double d);
65 void SetGreaterThanSegment(int segment);
66 void SetGreaterThanValue(double d);
67 void SetLessThanSegment(int segment);
68 void SetLessThanValue(double d);
69 void SetTrendsToSegment(int segment);
70 void SetTrendsToValue(double d);
71 void SetRange(double min, double max);
72
73protected:
76};
77
79{
80 friend class PBValidation;//friend the serialization class
81public:
82 enum class eComparisonType { None=0, EqualToValue, Range };
83 enum class eTargetType { Mean=0, Minimum, Maximum,
84 MeanPerIdealWeight_kg, MaxPerIdealWeight_kg, MinPerIdealWeight_kg };
86 virtual ~SETimeSeriesValidationTarget() = default;
87
88 void Clear() override;
89
90 static bool SerializeToString(const std::vector<const SETimeSeriesValidationTarget*>&src, std::string& output, eSerializationFormat m, Logger* logger);
91 static bool SerializeToFile(const std::vector<const SETimeSeriesValidationTarget*>& src, const std::string& filename, Logger* logger);
92 static bool SerializeFromString(const std::string& src, std::vector<SETimeSeriesValidationTarget*>& dst, eSerializationFormat m, Logger* logger);
93 static bool SerializeFromFile(const std::string& filename, std::vector<SETimeSeriesValidationTarget*>& dst, Logger* logger);
94
95 eTargetType GetTargetType() const { return m_TargetType; }
96 eComparisonType GetComparisonType() const { return m_ComparisonType; }
97
98 void SetEqualTo(double d, eTargetType t);
99 void SetRange(double min, double max, eTargetType t);
100
101 // Maybe we want a different class to do the comparision
102 // For now, I just put it in line here for the CircuitOptimizer
103 bool ComputeError();
104 double GetError() const { return m_Error; }
105 double GetDataValue() const { return m_ComparisonValue; }
106 std::vector<double>& GetData() { return m_Data; }
107
108protected:
111
112 // Not serializing
113 double m_Error;
114 std::vector<double> m_Data;
116};
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PBValidation.h:12
static bool SerializeFromString(const std::string &src, std::vector< SESegmentValidationTarget * > &dst, eSerializationFormat m, Logger *logger)
Definition: PBValidation.cpp:124
static bool SerializeFromFile(const std::string &filename, std::vector< SESegmentValidationTarget * > &dst, Logger *logger)
Definition: PBValidation.cpp:132
static bool SerializeToFile(const std::vector< const SESegmentValidationTarget * > &src, const std::string &filename, Logger *logger)
Definition: PBValidation.cpp:161
static bool SerializeToString(const std::vector< const SESegmentValidationTarget * > &src, std::string &output, eSerializationFormat m, Logger *logger)
Definition: PBValidation.cpp:153
Definition: SEValidationTarget.h:45
eComparisonType m_ComparisonType
Definition: SEValidationTarget.h:74
int GetTargetSegment() const
Definition: SEValidationTarget.h:61
eComparisonType
Definition: SEValidationTarget.h:48
virtual ~SESegmentValidationTarget()=default
int m_TargetSegment
Definition: SEValidationTarget.h:75
eComparisonType GetComparisonType() const
Definition: SEValidationTarget.h:59
Definition: SEValidationTarget.h:79
eComparisonType m_ComparisonType
Definition: SEValidationTarget.h:110
eTargetType GetTargetType() const
Definition: SEValidationTarget.h:95
eComparisonType GetComparisonType() const
Definition: SEValidationTarget.h:96
virtual ~SETimeSeriesValidationTarget()=default
double m_Error
Definition: SEValidationTarget.h:113
std::vector< double > m_Data
Definition: SEValidationTarget.h:114
eTargetType
Definition: SEValidationTarget.h:83
double m_ComparisonValue
Definition: SEValidationTarget.h:115
double GetError() const
Definition: SEValidationTarget.h:104
eComparisonType
Definition: SEValidationTarget.h:82
double GetDataValue() const
Definition: SEValidationTarget.h:105
eTargetType m_TargetType
Definition: SEValidationTarget.h:109
std::vector< double > & GetData()
Definition: SEValidationTarget.h:106
Definition: SEValidationTarget.h:11
std::string GetReference() const
Definition: SEValidationTarget.h:24
double GetTarget() const
Definition: SEValidationTarget.h:32
std::string m_Reference
Definition: SEValidationTarget.h:36
double m_TargetMinimum
Definition: SEValidationTarget.h:41
std::string GetHeader() const
Definition: SEValidationTarget.h:21
SEValidationTarget()
Definition: SEValidationTarget.h:14
virtual ~SEValidationTarget()=default
double GetTargetMaximum() const
Definition: SEValidationTarget.h:30
double m_TargetMaximum
Definition: SEValidationTarget.h:40
double GetTargetMinimum() const
Definition: SEValidationTarget.h:31
void SetReference(const std::string &c)
Definition: SEValidationTarget.h:25
std::string GetNotes() const
Definition: SEValidationTarget.h:27
std::string m_Header
Definition: SEValidationTarget.h:35
void SetNotes(const std::string &n)
Definition: SEValidationTarget.h:28
std::string m_Notes
Definition: SEValidationTarget.h:37
double m_Target
Definition: SEValidationTarget.h:39
void SetHeader(const std::string &h)
Definition: SEValidationTarget.h:22

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.