#pragma once #include "common.hpp" #include "funcs.hpp" #include "../level-0/ref.hpp" #include namespace intellect { namespace level1 { template struct baseref : public level0::baseref { baseref(concept * p) : level0::baseref(p) { } baseref(level0::ref const & other) : baseref(other.ptr()) { } baseref(std::string const & name) : baseref(getnamed(name)) { } baseref(const char *name) : baseref(std::string(name)) { } baseref(bool b) : baseref(b ? "true" : "false") { } baseref() : baseref("nothing") { } bool isa(ref group) const { return level1::isa(self, group); } bool isan(ref group) const { return isa(group); } std::string const & name() const { return getname(self); } operator std::string const &() const { return getname(self); } explicit operator char const *() const { return getname(self)->data.c_str(); } ref operator-(ref other) const { return hyphenate(self, other); } ref operator[](ref subref) const { return self.get(subref); } template void vset(ref const & type, T const & v) { self.set(type, level1::alloc(v)); } template std::function & fun() { return self.template val>(); } template void fun(std::function const & f) { self.val(f); } template void fun(std::function const & f) { self.val(voidtoret(f)); } template void fget(ref const & type) { return self.template vget>(type); } template void fset(ref const & type, std::function f) { self.vset(type, f); } template void fset(ref const & type, std::function f) { fset(type, voidtoret(f)); } template ref operator()(Ref... args) { return self.template fun()(args...); } std::string dump(ref skipmarkertype, ref skipmarkertarget) { return level1::dump(self, skipmarkertype, skipmarkertarget); }; private: template std::function voidtoret(std::function f) { return [f](Refs... args) -> ref { std::initializer_list({&args...}); f(args...); return concepts::nothing; }; } }; } }