MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / BinaryGenerator

Class BinaryGenerator

tests/unit/sys/test_expressionparser.cxx:36–61  ·  view source on GitHub ↗

For testing, a generator function of two inputs

Source from the content-addressed store, hash-verified

34
35/// For testing, a generator function of two inputs
36class BinaryGenerator : public FieldGenerator {
37public:
38 BinaryGenerator(std::shared_ptr<FieldGenerator> a = nullptr,
39 std::shared_ptr<FieldGenerator> b = nullptr)
40 : a(std::move(a)), b(std::move(b)) {}
41
42 std::shared_ptr<FieldGenerator>
43 clone(const std::list<std::shared_ptr<FieldGenerator>> args) override {
44 if (args.size() != 2) {
45 throw ParseException(
46 "Incorrect number of arguments to increment function. Expecting 2, got {:d}",
47 args.size());
48 }
49
50 return std::make_shared<BinaryGenerator>(args.front(), args.back());
51 }
52 BoutReal generate(const Context& ctx) override {
53 return a->generate(ctx) + b->generate(ctx);
54 }
55 std::string str() const override {
56 return std::string{"add(" + a->str() + ", " + b->str() + ")"};
57 }
58
59private:
60 std::shared_ptr<FieldGenerator> a, b;
61};
62
63class IncrementGenerator : public FieldGenerator {
64public:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected