class PDI::Ref_any

Description

A dynamically typed reference to data with automatic memory management and read/write locking semantic.

Ref_any is a smart pointer that features:

  • a dynamic type system,
  • garbage collection mechanism similar to std::shared_ptr,
  • a read/write locking mechanism similar to std::shared_mutex,
  • a release system that nullifies all existing references to the raw data,
  • a notification system to be notified when a reference is going to be nullified.

{{% alert %}} As of now, and unlike std::shared_ptr, the lock system can not be relied upon in a multithreaded environment. {{% /alert %}}

Content

Member Functions

Ref_any ( )
Constructs a null reference.
Ref_any ( const Ref_any & other )
Copies an existing reference.
Ref_any ( const Ref_any< OR, OW > & other )
Copies an existing reference with different privileges.
Ref_any ( Ref_any && other )
Moves an existing reference.
Ref_any ( void * data, std::function< void(void *)> freefunc, bool readable, Datatype_uptr type, bool writable )
Creates a reference to currently unreferenced data.
Ref_any ( const Datatype::Accessor_base & accessor, Ref other )
Creates a subreference from reference.
Ref_any ( const std::vector< std::unique_ptr< Datatype::Accessor_base >> & accessors, Ref other )
Creates a subreference from reference.
Ref copy ( )
Makes a copy of the raw content behind this reference and returns a new reference.
Ref_access< R, W >::type get ( )
Offers access to the referenced raw data, throws on null references.
Ref_access< R, W >::type get ( std::nothrow_t )
Offers access to the referenced raw data, returns null for null references.
void on_nullify ( std::function< void(Ref)> notifier )
Registers a nullification callback.
operator bool ( )
Checks whether this is a null reference.
operator typename Ref_access< R, W >::type ( )
Offers access to the referenced raw data.
bool operator!= ( const Reference_base & o )
bool operator< ( const Reference_base & o )
bool operator<= ( const Reference_base & o )
Ref_any & operator= ( Ref_any && other )
Ref_any & operator= ( const Ref_any & other )
bool operator== ( const Reference_base & o )
bool operator> ( const Reference_base & o )
bool operator>= ( const Reference_base & o )
Ref operator[] ( const std::string & member_name )
Create a sub-reference to a member in case the content behind the ref is a record.
Ref operator[] ( const char * member_name )
Create a sub-reference to a member in case the content behind the ref is a record.
Ref operator[] ( std::size_t index )
Create a sub-reference to the content at a given index in case the content behind the ref is an array.
Ref operator[] ( std::pair< std::size_t, std::size_t > slice )
Create a sub-reference to the content at a given slice in case the content behind the ref is an array.
void * release ( )
Releases ownership of the referenced raw data by nullifying all existing references.
void reset ( )
Nullify the reference.
T scalar_value ( )
Returns a scalar value of type T taken from the data buffer.
~Ref_any ( )
Destructor.

Documentation

Member Functions

Ref_any ( )

Description

Constructs a null reference.

Ref_any ( const Ref_any & other )

Description

Copies an existing reference. if the requested rights can not be granted, the reference is made null

Parameters

other
the ref to copy

Ref_any ( const Ref_any< OR, OW > & other )

Description

Copies an existing reference with different privileges. if the requested rights can not be granted, the reference is made null

Parameters

other
the ref to copy

Ref_any ( Ref_any && other )

Description

Moves an existing reference.

Parameters

other
the ref to copy

Ref_any ( void * data, std::function< void(void *)> freefunc, bool readable, Datatype_uptr type, bool writable )

Description

Creates a reference to currently unreferenced data.

Parameters

data
the raw data to reference
freefunc
the function to use to free the data buffer
readable
the maximum allowed access to the underlying content
type
the type of the referenced data, ownership will be taken
writable
the maximum allowed access to the underlying content

Ref_any ( const Datatype::Accessor_base & accessor, Ref other )

Description

Creates a subreference from reference.

Parameters

accessor
accessor to use to create subreference
other
source reference

Ref_any ( const std::vector< std::unique_ptr< Datatype::Accessor_base >> & accessors, Ref other )

Description

Creates a subreference from reference.

Parameters

accessors
vector of accessor to use to create subreference
other
source reference

Ref copy ( )

Description

Makes a copy of the raw content behind this reference and returns a new reference.

Result

a new reference to a copy of the raw data this references

Ref_access< R, W >::type get ( )

Description

Offers access to the referenced raw data, throws on null references.

Result

a pointer to the referenced raw data

Ref_access< R, W >::type get ( std::nothrow_t )

Description

Offers access to the referenced raw data, returns null for null references.

Parameters

Result

a pointer to the referenced raw data

void on_nullify ( std::function< void(Ref)> notifier )

Description

Registers a nullification callback.

Parameters

notifier
the function to call when this reference becomes null

operator bool ( )

Description

Checks whether this is a null reference.

operator typename Ref_access< R, W >::type ( )

Description

Offers access to the referenced raw data.

bool operator!= ( const Reference_base & o )

Parameters

o

bool operator< ( const Reference_base & o )

Parameters

o

bool operator<= ( const Reference_base & o )

Parameters

o

Ref_any & operator= ( Ref_any && other )

Parameters

other

Ref_any & operator= ( const Ref_any & other )

Parameters

other

bool operator== ( const Reference_base & o )

Parameters

o

bool operator> ( const Reference_base & o )

Parameters

o

bool operator>= ( const Reference_base & o )

Parameters

o

Ref operator[] ( const std::string & member_name )

Description

Create a sub-reference to a member in case the content behind the ref is a record.

Parameters

member_name
member to make a subref for

Result

created subreference

Ref operator[] ( const char * member_name )

Description

Create a sub-reference to a member in case the content behind the ref is a record.

Parameters

member_name
member to make a subref for

Result

created subreference

Ref operator[] ( std::size_t index )

Description

Create a sub-reference to the content at a given index in case the content behind the ref is an array.

Parameters

index
index to make a subref for

Result

created subreference

Ref operator[] ( std::pair< std::size_t, std::size_t > slice )

Description

Create a sub-reference to the content at a given slice in case the content behind the ref is an array.

Parameters

slice
pair with start and end index

Result

created subreference

void * release ( )

Description

Releases ownership of the referenced raw data by nullifying all existing references.

Result

the previously referenced raw data or nullptr if this was a null reference, i.e. the value which would be returned by get() before the call.

void reset ( )

Description

Nullify the reference.

T scalar_value ( )

Description

Returns a scalar value of type T taken from the data buffer.

Result

value taken from the data buffer

~Ref_any ( )

Description

Destructor.

Last modified January 1, 0001