mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions | Private Attributes | Friends
m::Pooled< T, Pool, CanBeNone > Struct Template Reference

A data type representing a pooled (or internalized) object. More...

#include <Pool.hpp>

Collaboration diagram for m::Pooled< T, Pool, CanBeNone >:
[legend]

Public Types

using value_type = typename Pool::table_type::value_type
 

Public Member Functions

 Pooled ()=default
 
 Pooled (const Pooled &other)
 
 Pooled (Pooled &&other)
 
 Pooled (const Pooled< T, Pool, false > &other)
 

‍Constructs an optional Pooled with a present value from a non-optional one.


 
 Pooled (Pooled< T, Pool, false > &&other)
 

‍Move-constructs an optional Pooled with a present value from a non-optional one.


 
 Pooled (const Pooled< T, Pool, true > &other)
 

‍Constructs a non-optional Pooled from an optional one. Can only be used if value is present.


 
 Pooled (Pooled< T, Pool, true > &&other)
 

‍Move-constructs a non-optional Pooled from an optional one. Can only be used if value is present.


 
bool has_value () const
 
Pooled< T, Pool, false > assert_not_none () const
 
uint32_t count () const
 Returns the number of references to the pooled object or 0 if this Pooled CanBeNone and does not hold a reference to an object.
 
 ~Pooled ()
 
Pooledoperator= (Pooled other)
 
 operator const T & () const
 
 operator const T * () const
 
const Toperator* () const
 
const Toperator-> () const
 
template<typename U >
requires std::is_polymorphic_v<typename Pool::pooled_type>
 and (std::derived_from< U, T > or std::derived_from< T, U >) Pooled< U
 Explicitly casts this Pooled<T> to Pooled<U>.
 
false as () const
 
template<typename U >
requires std::is_polymorphic_v<typename Pool::pooled_type>
and std::derived_from< T, Uoperator Pooled< U, Pool, false > ()
 Implicitly casts this Pooled<T> to Pooled<U>.
 
template<typename U , bool _CanBeNone>
requires std::is_polymorphic_v<typename Pool::pooled_type>
and std::derived_from< U, T > Pooledoperator= (Pooled< U, Pool, _CanBeNone > other)
 Assigns a Pooled<U> to this Pooled<T>.
 
template<typename U , bool _CanBeNone>
bool operator== (Pooled< U, Pool, _CanBeNone > other) const
 
template<typename U , bool _CanBeNone>
bool operator!= (Pooled< U, Pool, _CanBeNone > other) const
 
template<typename U >
bool operator== (const U *other) const
 
template<typename U >
bool operator!= (const U *other) const
 
void dump (std::ostream &out) const
 
void dump () const
 

Data Fields

friend Pool
 


 
 Pool
 

Static Public Attributes

static constexpr bool can_be_none = CanBeNone
 

‍Can this Pooled not reference an object?


 

Private Member Functions

 Pooled (Pool *pool, value_type *value)
 Constucts a fresh Pooled from a pooled.
 

Private Attributes

Poolpool_ = nullptr
 

‍The pool holding this value. Can only be nullptr if CanBeNone or if the Pooled instance is moved.


 
value_typeref_ = nullptr
 

‍The pointer to the pooled object. Can only be nullptr if CanBeNone or if the Pooled instance is moved.


 

Friends

template<typename , typename , bool >
struct Pooled
 

‍Access privilege for conversion between optional and non-optional Pooled instances.


 
void swap (Pooled &first, Pooled &second)
 
std::ostream & operator<< (std::ostream &out, const Pooled &pooled)
 

Detailed Description

template<typename T, typename Pool, bool CanBeNone>
struct m::Pooled< T, Pool, CanBeNone >

A data type representing a pooled (or internalized) object.

If

Template Parameters
CanBeNone,aninstance of Pooled can not point to any object, and Pooled provides additional methods to query whether it is pointing to an actual object and to safely get the object, if any.

Definition at line 167 of file Pool.hpp.

Member Typedef Documentation

◆ value_type

template<typename T , typename Pool , bool CanBeNone>
using m::Pooled< T, Pool, CanBeNone >::value_type = typename Pool::table_type::value_type

Definition at line 172 of file Pool.hpp.

Constructor & Destructor Documentation

◆ Pooled() [1/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( Pool pool,
value_type value 
)
inlineprivate

Constucts a fresh Pooled from a pooled.

Parameters
valueand its owning
pool.

Definition at line 194 of file Pool.hpp.

References M_insist, M_notnull, m::Pooled< T, Pool, CanBeNone >::pool_, and m::Pooled< T, Pool, CanBeNone >::ref_.

◆ Pooled() [2/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( )
default

◆ Pooled() [3/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( const Pooled< T, Pool, CanBeNone > &  other)
inline

Definition at line 205 of file Pool.hpp.

◆ Pooled() [4/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( Pooled< T, Pool, CanBeNone > &&  other)
inline

Definition at line 206 of file Pool.hpp.

References m::Pooled< T, Pool, CanBeNone >::swap.

◆ Pooled() [5/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( const Pooled< T, Pool, false > &  other)
inline

‍Constructs an optional Pooled with a present value from a non-optional one.

Definition at line 209 of file Pool.hpp.

◆ Pooled() [6/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( Pooled< T, Pool, false > &&  other)
inline

‍Move-constructs an optional Pooled with a present value from a non-optional one.

Definition at line 214 of file Pool.hpp.

◆ Pooled() [7/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( const Pooled< T, Pool, true > &  other)
inlineexplicit

‍Constructs a non-optional Pooled from an optional one. Can only be used if value is present.

Definition at line 220 of file Pool.hpp.

◆ Pooled() [8/8]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pooled ( Pooled< T, Pool, true > &&  other)
inlineexplicit

‍Move-constructs a non-optional Pooled from an optional one. Can only be used if value is present.

Definition at line 228 of file Pool.hpp.

◆ ~Pooled()

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::~Pooled ( )
inline

Member Function Documentation

◆ and()

template<typename T , typename Pool , bool CanBeNone>
template<typename U >
requires std::is_polymorphic_v<typename Pool::pooled_type>
m::Pooled< T, Pool, CanBeNone >::and ( std::derived_from< U, T > or std::derived_from< T, U )

Explicitly casts this Pooled<T> to Pooled<U>.

Supports both up-casting and down-casting. Requires that the underlying type is polymorphic and T can be dynamically casted to

Template Parameters
U.

◆ as()

template<typename T , typename Pool , bool CanBeNone>
false m::Pooled< T, Pool, CanBeNone >::as ( ) const
inline

◆ assert_not_none()

template<typename T , typename Pool , bool CanBeNone>
Pooled< T, Pool, false > m::Pooled< T, Pool, CanBeNone >::assert_not_none ( ) const
inline

◆ count()

template<typename T , typename Pool , bool CanBeNone>
uint32_t m::Pooled< T, Pool, CanBeNone >::count ( ) const
inline

Returns the number of references to the pooled object or 0 if this Pooled CanBeNone and does not hold a reference to an object.

Definition at line 249 of file Pool.hpp.

References m::Pooled< T, Pool, CanBeNone >::ref_.

Referenced by m::Pooled< T, Pool, CanBeNone >::dump().

◆ dump() [1/2]

template<typename T , typename Pool , bool CanBeNone>
void m::Pooled< T, Pool, CanBeNone >::dump ( ) const
inline

Definition at line 328 of file Pool.hpp.

References m::Pooled< T, Pool, CanBeNone >::dump().

Referenced by m::Pooled< T, Pool, CanBeNone >::dump().

◆ dump() [2/2]

template<typename T , typename Pool , bool CanBeNone>
void m::Pooled< T, Pool, CanBeNone >::dump ( std::ostream &  out) const
inline

◆ has_value()

template<typename T , typename Pool , bool CanBeNone>
bool m::Pooled< T, Pool, CanBeNone >::has_value ( ) const
inline

◆ operator const T &()

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::operator const T & ( ) const
inlineexplicit

Definition at line 264 of file Pool.hpp.

References m::Pool< T, Hash, KeyEqual, ThreadSafe >::Get(), and m::T().

◆ operator const T *()

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::operator const T * ( ) const
inline

Definition at line 265 of file Pool.hpp.

References m::Pool< T, Hash, KeyEqual, ThreadSafe >::Get(), and m::T().

◆ operator Pooled< U, Pool, false >()

template<typename T , typename Pool , bool CanBeNone>
template<typename U >
requires std::is_polymorphic_v<typename Pool::pooled_type>
and std::derived_from< T, U > m::Pooled< T, Pool, CanBeNone >::operator Pooled< U, Pool, false > ( )
inline

Implicitly casts this Pooled<T> to Pooled<U>.

Only supports up-casting. Requires that the underlying type is polymorphic and T is derived from type

Template Parameters
U.

Definition at line 288 of file Pool.hpp.

◆ operator!=() [1/2]

template<typename T , typename Pool , bool CanBeNone>
template<typename U >
bool m::Pooled< T, Pool, CanBeNone >::operator!= ( const U other) const
inline

Definition at line 314 of file Pool.hpp.

References m::Pooled< T, Pool, CanBeNone >::operator==().

◆ operator!=() [2/2]

template<typename T , typename Pool , bool CanBeNone>
template<typename U , bool _CanBeNone>
bool m::Pooled< T, Pool, CanBeNone >::operator!= ( Pooled< U, Pool, _CanBeNone >  other) const
inline

Definition at line 310 of file Pool.hpp.

References m::Pooled< T, Pool, CanBeNone >::operator==().

◆ operator*()

template<typename T , typename Pool , bool CanBeNone>
const T & m::Pooled< T, Pool, CanBeNone >::operator* ( ) const
inline

Definition at line 267 of file Pool.hpp.

References m::Pool< T, Hash, KeyEqual, ThreadSafe >::Get(), and m::T().

◆ operator->()

template<typename T , typename Pool , bool CanBeNone>
const T * m::Pooled< T, Pool, CanBeNone >::operator-> ( ) const
inline

Definition at line 268 of file Pool.hpp.

References m::Pool< T, Hash, KeyEqual, ThreadSafe >::Get(), and m::T().

◆ operator=() [1/2]

template<typename T , typename Pool , bool CanBeNone>
Pooled & m::Pooled< T, Pool, CanBeNone >::operator= ( Pooled< T, Pool, CanBeNone >  other)
inline

Definition at line 262 of file Pool.hpp.

References m::Pooled< T, Pool, CanBeNone >::swap.

◆ operator=() [2/2]

template<typename T , typename Pool , bool CanBeNone>
template<typename U , bool _CanBeNone>
requires std::is_polymorphic_v<typename Pool::pooled_type>
and std::derived_from< U, T > Pooled & m::Pooled< T, Pool, CanBeNone >::operator= ( Pooled< U, Pool, _CanBeNone >  other)
inline

Assigns a Pooled<U> to this Pooled<T>.

Only supports up-casting. Requires that the underlying type is polymorphic and rhs type(

Template Parameters
U) is derived from lhs type (T). The rhs can be optional or non-optional Pooled, in either case it can not be empty.

Definition at line 299 of file Pool.hpp.

References M_insist, m::Pooled< T, Pool, CanBeNone >::pool_, m::Pooled< T, Pool, CanBeNone >::ref_, and m::Pooled< T, Pool, CanBeNone >::swap.

◆ operator==() [1/2]

template<typename T , typename Pool , bool CanBeNone>
template<typename U >
bool m::Pooled< T, Pool, CanBeNone >::operator== ( const U other) const
inline

Definition at line 312 of file Pool.hpp.

References m::Pool< T, Hash, KeyEqual, ThreadSafe >::Get().

◆ operator==() [2/2]

template<typename T , typename Pool , bool CanBeNone>
template<typename U , bool _CanBeNone>
bool m::Pooled< T, Pool, CanBeNone >::operator== ( Pooled< U, Pool, _CanBeNone >  other) const
inline

Friends And Related Function Documentation

◆ operator<<

template<typename T , typename Pool , bool CanBeNone>
std::ostream & operator<< ( std::ostream &  out,
const Pooled< T, Pool, CanBeNone > &  pooled 
)
friend

Definition at line 316 of file Pool.hpp.

◆ Pooled

template<typename T , typename Pool , bool CanBeNone>
template<typename , typename , bool >
friend struct Pooled
friend

‍Access privilege for conversion between optional and non-optional Pooled instances.

Definition at line 179 of file Pool.hpp.

◆ swap

template<typename T , typename Pool , bool CanBeNone>
void swap ( Pooled< T, Pool, CanBeNone > &  first,
Pooled< T, Pool, CanBeNone > &  second 
)
friend

Field Documentation

◆ can_be_none

template<typename T , typename Pool , bool CanBeNone>
constexpr bool m::Pooled< T, Pool, CanBeNone >::can_be_none = CanBeNone
staticconstexpr

‍Can this Pooled not reference an object?

Definition at line 170 of file Pool.hpp.

◆ Pool [1/2]

template<typename T , typename Pool , bool CanBeNone>
friend m::Pooled< T, Pool, CanBeNone >::Pool

Template Parameters
Poolneeds access to private c'tor

Definition at line 175 of file Pool.hpp.

◆ Pool [2/2]

template<typename T , typename Pool , bool CanBeNone>
m::Pooled< T, Pool, CanBeNone >::Pool

Definition at line 276 of file Pool.hpp.

◆ pool_

template<typename T , typename Pool , bool CanBeNone>
Pool* m::Pooled< T, Pool, CanBeNone >::pool_ = nullptr
private

‍The pool holding this value. Can only be nullptr if CanBeNone or if the Pooled instance is moved.

Definition at line 189 of file Pool.hpp.

Referenced by m::Pooled< T, Pool, CanBeNone >::as(), m::Pooled< T, Pool, CanBeNone >::assert_not_none(), m::Pooled< T, Pool, CanBeNone >::operator=(), m::Pooled< T, Pool, CanBeNone >::Pooled(), and m::Pooled< T, Pool, CanBeNone >::~Pooled().

◆ ref_

template<typename T , typename Pool , bool CanBeNone>
value_type* m::Pooled< T, Pool, CanBeNone >::ref_ = nullptr
private

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