|
VisualIB
1.0
IBExpress library for making use of Borland IBExpress outside of C++Builder
|
Property implements Borland Delphi-style properties using standard C++11 mechanisms. More...
#include <VIBProperties.h>
Public Member Functions | |
| Property () | |
| Default constructor, you must initialize get and set later. | |
| Property (const Getter &pGet, const Setter &pSet) | |
| Full constructor. | |
| void | initCallbacks (const Getter &pGet, const Setter &pSet) |
| Late-initialize the callbacks, or change their values at runtime. | |
| operator T () | |
| Cast operator, invokes get() and returns its value. | |
| Property< T > & | operator= (const T &nv) |
| Assignment operator, invokes set with the provided value, returns this object. | |
| T | operator-> () |
| Invokes get, assuming it returns a pointer that can be used with the deref-access arrow operator. | |
Protected Types | |
| typedef std::function< T(void)> | Getter |
| The type of a Property Getter method. | |
|
typedef std::function< void(const T &)> | Setter |
| The type of a Property Setter method. | |
Protected Attributes | |
| Getter | get |
| The getter method; typically, a this-capturing lambda function. | |
| Setter | set |
| The setter method; typically, a this-capturing lambda function. | |
Property implements Borland Delphi-style properties using standard C++11 mechanisms.
Implementation of proper message forwarding to the parent object of the property is accomplished through use of lambda functions as get/set callbacks, which capture the "this" pointer by reference during their construction. Both callbacks are optional; leaving one unimplemented will cause a std::exception to be thrown if a call is attempted. This can be used to create read-only or even write-only properties.
| T | Basic type or structure/class type to wrap. |
|
inline |
Default constructor, you must initialize get and set later.
Typical use case.
|
inline |
Full constructor.
Provide get and set callbacks at instantiation.
| [in] | pGet | Pointer to a T (void) getter function; typically, a this-capturing lambda. |
| [in] | pSet | Pointer to a void (const T &) setter function; typically, a this-capturing lambda. |
|
inline |
Late-initialize the callbacks, or change their values at runtime.
| [in] | pGet | Pointer to a T (void) getter function; typically, a this-capturing lambda. |
| [in] | pSet | Pointer to a void (const T &) setter function; typically, a this-capturing lambda. |
|
inline |
|
inline |
Invokes get, assuming it returns a pointer that can be used with the deref-access arrow operator.
If not, you will cause a compile-time error by trying to use it.
|
inline |
Assignment operator, invokes set with the provided value, returns this object.
| [in] | nv | New value of the underlying type to assign to the property via the setter callback function. |