Program Listing for File PDFSegment.hpp
↰ Return to documentation for file (src/pdfs/PDFSegment.hpp)
#ifndef PDFSEGMENT_HPP
#define PDFSEGMENT_HPP
#include <fstream>
#include <map>
#include <string>
#include <toml.hpp>
#include <vector>
namespace pdfs {
class PDFSegment {
public:
// Constructors and destructor
PDFSegment(double sMin, double sMax) :
sMin_(sMin), sMax_(sMax) {}
PDFSegment(const PDFSegment&) = default;
auto operator=(const PDFSegment&) -> PDFSegment& = default;
PDFSegment(PDFSegment&&) = default;
auto operator=(PDFSegment&&) -> PDFSegment& = default;
virtual ~PDFSegment() = default;
// Getters for the lower and upper limits of the segment
[[nodiscard]] auto getMin() const -> double { return sMin_; }
[[nodiscard]] auto getMax() const -> double { return sMax_; }
// Evaluation functions
[[nodiscard]] virtual auto operator()(double x) const -> double = 0;
[[nodiscard]] virtual auto expectationValue(double a, double b) const -> double = 0;
[[nodiscard]] virtual auto expectationValue() const -> double = 0;
[[nodiscard]] virtual auto integral(double a, double b) const -> double = 0;
// Drawing functions
[[nodiscard]] virtual auto draw(double a, double b) const -> double = 0;
[[nodiscard]] virtual auto draw() const -> double = 0;
// Serialization
virtual void toToml(toml::table& tbl) const = 0;
protected:
static auto segmentParser(std::ifstream& file,
std::vector<std::string>& tok)
-> std::map<std::string, double>;
static auto segmentParserToml(toml::node_view<const toml::node> node,
std::vector<std::string>& tok)
-> std::map<std::string, double>;
double sMin_;
double sMax_;
};
} // namespace pdfs
#endif // PDFSEGMENT_HPP