#pragma once #include #include #include #include struct concept; template struct value; struct ref { ref(concept *p) : ptr(p) { } concept* operator->() { return ptr; } bool operator<(ref const & other) const { return ptr < other.ptr; } // helper names ref(std::string const &); ref(char const * str) : ref(std::string(str)) { } value & name() const; operator const char *() const; concept * ptr; }; struct concept { // a concept is made of concept-typed links to other concepts std::multimap links; using array = std::vector; ref id(); ref get(ref type); // returns first array getAll(ref type); void link(ref type, ref target); void unlink(ref type, ref target); }; template struct value : public concept, public T { value(T const & val) : T(val) {} value(value const & val) = default; static value& of(ref c) { return *static_cast*>(c.ptr); } };