From 89152d1ffe452438db46932ebc62d5ccc5b79208 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 5 Feb 2010 11:36:17 -0800 Subject: Made get_link the only way to create nested props. Removed the obj::ptr and sptr typedefs. The dboard manager now must store not the subdevs, but their proxies. --- lib/wax.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'lib/wax.cpp') diff --git a/lib/wax.cpp b/lib/wax.cpp index 0ae0d4315..a75acdc7f 100644 --- a/lib/wax.cpp +++ b/lib/wax.cpp @@ -34,6 +34,18 @@ struct proxy_args_t{ boost::function set; }; +/*! + * The link args for internal use within this cpp file: + * + * It contains a link (in this case a pointer) to a wax object. + * Only the methods in this file may create or parse link args. + * The get_link method is the creator of a link args object. + * The [] operator will resolve the link and make the [] call. + */ +struct link_args_t{ + wax::obj *obj_ptr; +}; + /*********************************************************************** * Structors **********************************************************************/ @@ -55,16 +67,12 @@ wax::obj::~obj(void){ wax::obj wax::obj::operator[](const obj &key){ if (_contents.type() == typeid(proxy_args_t)){ obj val = resolve(); - //check if its a regular pointer and call - if (val.type() == typeid(obj::ptr)){ - return (*cast(val))[key]; - } - //check if its a smart pointer and call - if (val.type() == typeid(obj::sptr)){ - return (*cast(val))[key]; + //check if its a special link and call + if (val.type() == typeid(link_args_t)){ + return (*cast(val).obj_ptr)[key]; } //unknown obj - throw std::runtime_error("cannot use [] on non wax::obj pointer"); + throw std::runtime_error("cannot use [] on non wax::obj link"); } else{ proxy_args_t proxy_args; @@ -88,7 +96,9 @@ wax::obj & wax::obj::operator=(const obj &val){ * Public Methods **********************************************************************/ wax::obj wax::obj::get_link(void) const{ - return ptr(this); + link_args_t link_args; + link_args.obj_ptr = const_cast(this); + return link_args; } const std::type_info & wax::obj::type(void) const{ -- cgit v1.2.3