Deprecate Val(double, TypeTag) ctor, add TimeVal/DoubleVal subclasses

This also updates all usages of the deprecated Val ctor to use
either IntervalVal, TimeVal, or DoubleVal ctors.  The reason for
doing away with the old constructor is that using it with TYPE_INTERVAL
isn't strictly correct since there exists a more specific subclass,
IntervalVal, with overriden ValDescribe() method that ought to be used
to print such values in a more descriptive way.
This commit is contained in:
Jon Siwek 2020-06-02 18:19:40 -07:00
parent a431f6b45d
commit 5b4313b593
76 changed files with 847 additions and 782 deletions

View file

@ -120,6 +120,7 @@ class Val : public BroObj {
public:
static inline const IntrusivePtr<Val> nil;
[[deprecated("Remove in v4.1. Use IntervalVal(), TimeVal(), or DoubleVal() constructors.")]]
Val(double d, TypeTag t)
: val(d), type(base_type(t))
{}
@ -489,14 +490,27 @@ extern ValManager* val_mgr;
class IntervalVal final : public Val {
public:
IntervalVal(double quantity, double units);
IntervalVal(double quantity, double units = Seconds)
: Val(quantity * units, base_type(TYPE_INTERVAL))
{}
protected:
IntervalVal() {}
void ValDescribe(ODesc* d) const override;
};
class TimeVal final : public Val {
public:
TimeVal(double t)
: Val(t, base_type(TYPE_TIME))
{}
};
class DoubleVal final : public Val {
public:
DoubleVal(double v)
: Val(v, base_type(TYPE_DOUBLE))
{}
};
class PortVal final : public Val {
public: