UHD  003.001.002
Public Member Functions | List of all members
wax::obj Class Reference

#include <wax.hpp>

Inheritance diagram for wax::obj:
uhd::device

Public Member Functions

 obj (void)
 
 obj (const obj &o)
 
template<class T >
 obj (const T &o)
 
virtual ~obj (void)
 
obj operator[] (const obj &key)
 
objoperator= (const obj &val)
 
obj get_link (void) const
 
const std::type_info & type (void) const
 
template<class T >
as (void) const
 

Detailed Description

WAX object base class:

A wax obj has two major purposes: 1) to act as a polymorphic container, just like boost any 2) to provide a nested set/get properties interface

Internally, the polymorphic container is handled by a boost any. For properties, a subclass should override the set and get methods. For property nesting, wax obj subclasses return special links to other wax obj subclasses, and the api handles the magic.

Constructor & Destructor Documentation

◆ obj() [1/3]

wax::obj::obj ( void  )

Default constructor: The contents will be empty.

◆ obj() [2/3]

wax::obj::obj ( const obj o)

Copy constructor: The contents will be cloned.

Parameters
oanother wax::obj

◆ obj() [3/3]

template<class T >
wax::obj::obj ( const T &  o)
inline

Templated any type constructor: The contents can be anything. Uses the boost::any to handle the magic.

Parameters
oan object of any type

◆ ~obj()

virtual wax::obj::~obj ( void  )
virtual

Destructor.

Member Function Documentation

◆ as()

template<class T >
T wax::obj::as ( void  ) const
inline

Cast this obj into the desired type. Usage: myobj.as<type>()

Returns
an object of the desired type
Exceptions
wax::bad_castwhen the cast fails

◆ get_link()

obj wax::obj::get_link ( void  ) const

Get a link in the chain: When a wax obj returns another wax obj as part of a get call, the return value should be set to the result of this method. Doing so will ensure chain-ability of the returned object.

Returns
an obj containing a valid link to a wax obj

◆ operator=()

obj& wax::obj::operator= ( const obj val)

The assignment operator: This operator allows for assignment of new contents. In the special case where this obj contains a proxy, the value will be set to the proxy's property reference.

Parameters
valthe new value to assign to the wax obj
Returns
a reference to this obj (*this)

◆ operator[]()

obj wax::obj::operator[] ( const obj key)

The chaining operator: This operator allows access objs with properties. A call to the [] operator will return a new proxy obj. The proxy object is an obj with special proxy contents. Assignment and casting can be used on this special object to access the property referenced by the obj key.

Parameters
keya key to identify a property within this obj
Returns
a special wax obj that proxies the obj and key

◆ type()

const std::type_info& wax::obj::type ( void  ) const

Get the type of the contents of this obj.

Returns
a reference to the type_info

The documentation for this class was generated from the following file: