Loading...
Searching...
No Matches
tbaseObjOrigin.hpp
Go to the documentation of this file.
1
2#pragma once
3
5
6namespace by {
7
28 template <typename T> class tbaseObjOrigin: public T {
30 static_assert(tifSub<T, baseObj>::is, "you need to input 'T' as derived class of baseObj.");
31
32 public:
33 tbaseObjOrigin(): me(dumScope::singleton()) {}
34
35 tbaseObjOrigin(const scope& subs): me(subs, *new modifier()) {}
36
37 tbaseObjOrigin(const scope& subs, const modifier& mod): super(), _subs(subs), _mod(mod) {
38 coreInternal::setOrigin(*this, *this);
39 }
40
41 public:
42 const node& getSubPod() const override {
43 static mockNode inner;
44 return inner;
45 }
46
47 const ntype& getType() const override { return ttype<super>::get(); }
48
49 using super::subs;
50
51 scope& subs() override { return *_subs; }
52
53 const modifier& getModifier() const override { return *_mod; }
54
55 clonable* clone() const override {
56 baseObj* ret = new super(*this);
57 coreInternal::setOrigin(*ret, *this);
58 return ret;
59 }
60
61 clonable* cloneDeep() const override {
62 me* ret = new me(*this);
63 ret->onCloneDeep(*this);
64 return ret;
65 }
66
67 void onCloneDeep(const clonable& from) override {
68 const me& rhs = (const me&) from;
69 if(rhs._subs) _subs.bind((scope&) *rhs._subs->cloneDeep());
70 if(rhs._mod) _mod.bind((modifier&) *rhs._mod->cloneDeep());
71 }
72
73 protected:
74 void _setModifier(const modifier& mod) override { _mod.bind(mod); }
75
76 private:
77 tstr<scope> _subs;
78 tstr<modifier> _mod;
79 };
80} // namespace by
Base class for representing byeol objects.
Definition baseObj.hpp:73
Interface for objects that can be cloned.
Definition clonable.hpp:13
Access modifier for type members.
Definition modifier.hpp:13
Base class for all AST nodes in the byeol language.
Definition node.hpp:195
represents native c++ type system for byeol language
Definition ntype.hpp:33
Template for easily defining baseObj origin objects.
Definition tbaseObjOrigin.hpp:28
Template type wrapper providing entry point for meta information.
Definition ttype.hpp:37
Weak reference smart pointer with type-safe access.
Definition tweak.hpp:16
const T *get() const BY_CONST_FUNC(get()) using super nbool bind(const T &new1)
Binds a weak reference to the specified instance.
Type trait to check if T is subclass of super.
Definition rtti.hpp:53
to Top