#51 Better node system

Uzavrená
otvorené 7 rokov pred užívateľom caryoscelus · 2 komentárov
  • more compile-time checks
  • better syntax
  • better runtime performance

Something like this:

class Add : public TypedNode<double, Only<double>, Only<double>> {
    NODE_PROPERTIES(a, b)
    NODE_PROPERTY(a, 0)
    NODE_PROPERTY(b, 0)
public:
    double get(shared_ptr<Context> ctx) const {
        return a(ctx)+b(ctx);
    }
};
- more compile-time checks - better syntax - better runtime performance Something like this: ```c++ class Add : public TypedNode<double, Only<double>, Only<double>> { NODE_PROPERTIES(a, b) NODE_PROPERTY(a, 0) NODE_PROPERTY(b, 0) public: double get(shared_ptr<Context> ctx) const { return a(ctx)+b(ctx); } }; ```
caryoscelus okomentoval 7 rokov pred
Vlastník

Better yet:

template <class Self, typename... Args>
class LinkStorage {
private:
    // guaranteed to be unique per Self
    static map<string,size_t>& name_map() {
        map<string,size_t> _instance;
        return _instance;
    }
public:
    static void register_name(string const& name) {
        ...
    }
};

template <class Self, typename Result, typename... Args>
class Node;

class Add : NODE(Add, double, Only<double>, Only<double>) {
    NODE_PROPERTIES(a, b) // using variadic macro expansion

public:
    double get(shared_ptr<Context> ctx) const override {
        return get_a(ctx) + get_b(ctx);
    }
};
Better yet: ```c++ template <class Self, typename... Args> class LinkStorage { private: // guaranteed to be unique per Self static map<string,size_t>& name_map() { map<string,size_t> _instance; return _instance; } public: static void register_name(string const& name) { ... } }; template <class Self, typename Result, typename... Args> class Node; class Add : NODE(Add, double, Only<double>, Only<double>) { NODE_PROPERTIES(a, b) // using variadic macro expansion public: double get(shared_ptr<Context> ctx) const override { return get_a(ctx) + get_b(ctx); } }; ```
caryoscelus sa odvolal na túto issue z commitu 6 rokov pred
caryoscelus okomentoval 6 rokov pred
Vlastník

Basic system is in place, though some enhancements to API are still expected.

Basic system is in place, though some enhancements to API are still expected.
Prihláste sa pre zapojenie do konverzácie.
Načítavanie...
Zrušiť
Uložiť
Zatiaľ neexistuje žiadny obsah.