File properties.hpp

Typedefs

template<typename T>
using SharedProperty = Property<T, std::shared_ptr<T>>

A Property that is backed by a shared pointer.

template<typename T>
struct ReadableProperty
#include <properties.hpp>

Provides access to a property via a getter function.

Template Parameters:

T – The type of the property

Subclassed by Property< T, std::shared_ptr< T > >, Property< T, Ptr >

Public Types

using GetterFunction = std::function<T&()>

A getter function.

Public Functions

inline explicit ReadableProperty(GetterFunction getterFunction)
Parameters:

getterFunction – The getter function

Public Members

const GetterFunction get

The getter function.

template<typename T, typename Ptr = std::unique_ptr<T>>
struct WritableProperty
#include <properties.hpp>

Provides access to a property via a setter function.

Template Parameters:
  • T – The type of the property

  • Ptr – The type of the pointer that is backing the property

Subclassed by Property< T, std::shared_ptr< T > >, Property< T, Ptr >

Public Types

using SetterFunction = std::function<void(Ptr&&)>

A setter function.

Public Functions

inline explicit WritableProperty(SetterFunction setterFunction)
Parameters:

setterFunction – The setter function

Public Members

const SetterFunction set

The setter function.

template<typename T, typename Ptr = std::unique_ptr<T>>
struct Property : public ReadableProperty<T>, public WritableProperty<T, std::unique_ptr<T>>
#include <properties.hpp>

Provides access to a property via a getter and setter function.

Template Parameters:
  • T – The type of the property

  • Ptr – The type of the pointer that is backing the property

Public Functions

inline Property(typename ReadableProperty<T>::GetterFunction getterFunction, typename WritableProperty<T, Ptr>::SetterFunction setterFunction)
Parameters:
  • getterFunction – The getter function

  • setterFunction – The setter function

namespace util

Functions

template<typename T>
static inline ReadableProperty<T>::GetterFunction getterFunction(const std::unique_ptr<T> &uniquePtr)

Creates and returns a GetterFunction that is backed by an unique pointer.

Template Parameters:

T – The return type of the GetterFunction

Parameters:

uniquePtr – A reference to the unique pointer

Returns:

The GetterFunction that has been created

template<typename T>
static inline ReadableProperty<T>::GetterFunction getterFunction(const std::shared_ptr<T> &sharedPtr)

Creates and returns a GetterFunction that is backed by a shared pointer.

Template Parameters:

T – The return type of the GetterFunction

Parameters:

sharedPtr – A reference to the shared pointer

Returns:

The GetterFunction that has been created

template<typename T, typename S1, typename S2>
static inline ReadableProperty<T>::GetterFunction getterFunction(const std::shared_ptr<S1> &sharedPtr1, const std::shared_ptr<S2> &sharedPtr2)

Creates and returns a GetterFunction that is backed by two shared pointers.

Template Parameters:
  • T – The return type of the GetterFunction

  • S1 – The type of the first shared pointer. Must be a supertype of T

  • S2 – The type of the second shared pointer. Must be a supertype of T

Parameters:
  • sharedPtr1 – A reference to the first shared pointer

  • sharedPtr2 – A reference to the second shared pointer

Returns:

The GetterFunction that has been created

template<typename T>
static inline WritableProperty<T>::SetterFunction setterFunction(std::unique_ptr<T> &uniquePtr)

Creates and returns a SetterFunction that is backed by an unique pointer.

Template Parameters:

T – The argument type of the SetterFunction

Parameters:

uniquePtr – A reference to the unique pointer

Returns:

The SetterFunction that has been created

template<typename T>
static inline WritableProperty<T, std::shared_ptr<T>>::SetterFunction sharedSetterFunction(std::shared_ptr<T> &sharedPtr)

Creates and returns a SetterFunction that is backed by a shared pointer.

Template Parameters:

T – The argument type of the SetterFunction

Parameters:

sharedPtr – A reference to the shared pointer

Returns:

The SetterFunction that has been created

template<typename T>
static inline ReadableProperty<T> readableProperty(const std::unique_ptr<T> &uniquePtr)

Creates and returns a ReadableProperty that is backed by an unique pointer.

Template Parameters:

T – The type of the ReadableProperty

Parameters:

uniquePtr – A reference to the unique pointer

Returns:

The ReadableProperty that has been created

template<typename T, typename S = T>
static inline ReadableProperty<T> readableProperty(const std::shared_ptr<S> &sharedPtr)

Creates and returns a ReadableProperty that is backed by a shared pointer.

Template Parameters:
  • T – The type of the ReadableProperty

  • S – The type of the shared pointer. Must be a supertype of T

Parameters:

sharedPtr – A reference to the shared pointer

Returns:

The ReadableProperty that has been created

template<typename T, typename S1 = T, typename S2 = T>
static inline ReadableProperty<T> readableProperty(const std::shared_ptr<S1> &sharedPtr1, const std::shared_ptr<S2> &sharedPtr2)

Creates and returns a ReadableProperty that is backed by two shared pointers.

Template Parameters:
  • T – The type of the ReadableProperty

  • S1 – The type of the first shared pointer. Must be a supertype of T

  • S2 – The type of the second shared pointer. Must be a supertype of T

Parameters:
  • sharedPtr1 – A reference to the first shared pointer

  • sharedPtr2 – A reference to the second shared pointer

Returns:

The ReadableProperty that has been created

template<typename T>
static inline Property<T> property(std::unique_ptr<T> &uniquePtr)

Creates and returns a Property that is backed by an unique pointer.

Template Parameters:

T – The type of the Property

Parameters:

uniquePtr – A reference to the unique pointer

Returns:

The Property that has been created

template<typename T>
static inline SharedProperty<T> sharedProperty(std::shared_ptr<T> &sharedPtr)

Creates and returns a Property that is backed by a shared pointer.

Template Parameters:

T – The type of the Property

Parameters:

sharedPtr – A reference to the shared pointer

Returns:

The Property that has been created