Smart pointer with loose type checking and lifetime management. More...
#include <binder.hpp>
Public Member Functions | |
| binder (const type &type, bindTacticable &tactic) | |
| binder (const me &rhs) | |
| instance * | operator-> () |
| Dereference operator to access bound instance. More... | |
| const instance * | operator-> () const BY_CONST_FUNC(operator->()) instance &operator*() |
| const instance & | operator* () const BY_CONST_FUNC(operator*()) me &operator |
| id | getItsId () const |
| nbool | isBind () const override |
| void | rel () override |
| nbool | canBind (const type &it) const override |
| nbool | bind (const instance &it) override |
| instance * | get () |
| const instance * | get () const BY_CONST_FUNC(get()) template< typename E > E *get() |
| template<typename E > | |
| const E * | get () const BY_CONST_FUNC(get< E >()) const type &getType() const override |
| void * | cast (const type &to) override |
| nbool | canBind (const T &it) const |
| nbool | canBind (const T *it) const BY_SIDE_FUNC(canBind) |
| virtual nbool | canBind (const type &it) const=0 |
| nbool | canBind (const type *it) const BY_SIDE_FUNC(canBind) |
| virtual nbool | bind (const T &it) |
| nbool | bind (const T *it) |
| Bind to instance pointer. More... | |
| template<typename T > | |
| T * | cast () |
| template<typename T > | |
| const T * | cast () const BY_CONST_FUNC(cast< T >()) virtual void *cast(const type &to) |
| const void * | cast (const type &to) const BY_CONST_FUNC(cast(to)) void *cast(const type *it) BY_SIDE_FUNC(cast) |
Public Member Functions inherited from by::typeProvidable | |
| nbool | operator== (const me &rhs) const |
| nbool | operator!= (const me &rhs) const |
| virtual const type & | getType () const =0 |
| nbool | isSub (const type &it) const |
| nbool | isSub (const type *it) const BY_SIDE_FUNC(isSub) |
| nbool | isSub (const me &it) const |
| nbool | isSub (const me *it) const BY_SIDE_FUNC(isSub) |
| nbool | isSuper (const type &it) const |
| nbool | isSuper (const type *it) const BY_SIDE_FUNC(isSuper) |
| nbool | isSuper (const me &it) const |
| nbool | isSuper (const me *it) const BY_SIDE_FUNC(isSuper) |
| template<typename T > | |
| nint | isSub () const |
| template<typename T > | |
| nint | isSuper () const |
| template<typename T > | |
| T * | cast () |
| template<typename T > | |
| const T * | cast () const BY_CONST_FUNC(cast< T >()) virtual void *cast(const type &to) |
| const void * | cast (const type &to) const BY_CONST_FUNC(cast(to)) void *cast(const type *it) BY_SIDE_FUNC(cast) |
Public Member Functions inherited from by::tbindable< instance > | |
| operator nbool () const | |
| nbool | bind (const instance *it) |
| Bind to instance pointer. More... | |
| nbool | canBind (const instance &it) const |
| nbool | canBind (const instance *it) const BY_SIDE_FUNC(canBind) |
| nbool | canBind (const type *it) const BY_SIDE_FUNC(canBind) |
Protected Member Functions | |
| nbool | _assign (const binder &rhs) |
| nbool | _onSame (const typeProvidable &rhs) const override |
| bindTag * | _getBindTag () const |
Protected Attributes | |
| id | _itsId |
| const type * | _type |
| bindTacticable * | _tactic |
Friends | |
| class | strTactic |
| class | bindTag |
| struct | ::binderTest |
Smart pointer with loose type checking and lifetime management.
Provides guaranteed instance cleanup and tracking with three key features: 1) Distinguished abstract type checking with flexible acceptance/rejection 2) Complete instance cleanup using RAII 3) Notification when bound instances are replaced or freed Prevents process halting and provides developer notifications.
type checking: this was most valuable requirement when I design component of bind. in fact, bind was suggested to replace sort of exisiting smart-ptr concept things, such as weakptr. because weakptr was planned to replace and enhance existing pointer of c/c++, they were very strict to check type and whether template param T was const or not. this characteristic was pretty worked good in most environment but not on usage of byeol framework.
why was it not proper to use as before?: byeol is based on class node and make user not need to know what really was. all actions (including calling some func on byeol env) can be replacable to sending msg using "use()". to say the least, what byeol doing is loose-check. so, strict type-checking of existing smart pointers doesn't matched to what byeol framework willing to do.
design: binder components are mostly constructed to 3 classes and they form 2 layers vertically. class binder: represents binder on loose-checking layer. user can try any type to bind or get from the binded. compiler won't complain about. but because of loose-checking, if it's not proper request, binder will warn you at runtime as result. constness of binding instance was persisted. (for example, if user try to get non-const instance from consted binder, s/he will get nulled reference.) user needs to checks that returned value was nullref on using loose-checking API.
class tweak, class tstr: these represent binder on strict-checking layer. because it was declared to class template, user need to bind or get binded using type T. of course these are based on class 'bind', user can use loose-check API case by case.
|
overridevirtual |
Reimplemented from by::tbindable< instance >.
| nbool by::tbindable< T >::bind | ( | const T * | it | ) |
Bind to instance pointer.
binder will loose previous binding instance whether given parameter it isn't nullptr or not.
|
overridevirtual |
Implements by::tbindable< instance >.
|
virtual |
Implements by::tbindable< instance >.
|
overridevirtual |
Implements by::tbindable< instance >.
| instance * by::binder::operator-> | ( | ) |
Dereference operator to access bound instance.
This follows the same policy as tmay and stl. that is, if the binder does not bind any instances and tries to dereference them with get() or operator*(), it will behave as UB. this is likely to crash.
|
overridevirtual |
Implements by::tbindable< instance >.