#51 Better node system

Geschlossen
vor 7 Jahren geöffnet von caryoscelus · 2 Kommentare
caryoscelus kommentierte vor 7 Jahren
  • 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 kommentierte vor 7 Jahren
Besitzer

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 hat dieses Issue vor 6 Jahren aus einem Commit referenziert
caryoscelus kommentierte vor 6 Jahren
Besitzer

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 hat vor 6 Jahren geschlossen
Anmelden, um an der Diskussion teilzunehmen.
Laden…
Abbrechen
Speichern
Hier gibt es bis jetzt noch keinen Inhalt.