#51 Better node system

Zavřený
otevřeno před 7 roky uživatelem caryoscelus · 2 komentářů
  • 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 před 7 roky
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 okomentoval před 6 roky
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.
Přihlaste se pro zapojení do konverzace.
Načítání...
Zrušit
Uložit
Není zde žádný obsah.