#51 Better node system

Lezárt
megnyitva ekkor: 7 éve caryoscelus által · 2 hozzászólás
caryoscelus hozzászólt 7 éve
  • 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 hozzászólt 7 éve
Tulajdonos

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 hivatkozott erre a hibajegyre egy commit-ban ekkor: 6 éve
caryoscelus hozzászólt 6 éve
Tulajdonos

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.
caryoscelus lezárta ekkor: 6 éve
Jelentkezzen be hogy csatlakozhasson a beszélgetéshez.
Töltés...
Mégse
Mentés
Még nincs tartalom.