XRootD
XrdCl::Fwd< T > Struct Template Reference

#include <XrdClFwd.hh>

+ Inheritance diagram for XrdCl::Fwd< T >:
+ Collaboration diagram for XrdCl::Fwd< T >:

Public Member Functions

 Fwd ()
 
 Fwd (const Fwd &fwd)
 Copy constructor. More...
 
 Fwd (const T &value)
 Constructor from value. More...
 
 Fwd (Fwd &&fwd)
 Move constructor. More...
 
 Fwd (std::shared_ptr< FwdStorage< T >> &&ptr)
 Initialize from shared_ptr. More...
 
 Fwd (T &&value)
 Move construct from value. More...
 
T & operator* () const
 
T * operator-> () const
 
Fwdoperator= (const T &value)
 
Fwdoperator= (T &&value)
 
bool Valid () const
 Check if it contains a valid value. More...
 

Detailed Description

template<typename T>
struct XrdCl::Fwd< T >

A helper class for forwarding arguments between operations. In practice it's a wrapper around std::shared_ptr using FwdStorage as underlying memory.

  • T : type of forwarded value

Definition at line 133 of file XrdClFwd.hh.

Constructor & Destructor Documentation

◆ Fwd() [1/6]

template<typename T >
XrdCl::Fwd< T >::Fwd ( )
inline

Default constructor.

Allocates memory for the underlying value object without callying its constructor.

Definition at line 141 of file XrdClFwd.hh.

141  : std::shared_ptr<FwdStorage<T>>( std::make_shared<FwdStorage<T>>() )
142  {
143  }

◆ Fwd() [2/6]

template<typename T >
XrdCl::Fwd< T >::Fwd ( const Fwd< T > &  fwd)
inline

Copy constructor.

Definition at line 148 of file XrdClFwd.hh.

148  : std::shared_ptr<FwdStorage<T>>( fwd )
149  {
150  }

◆ Fwd() [3/6]

template<typename T >
XrdCl::Fwd< T >::Fwd ( Fwd< T > &&  fwd)
inline

Move constructor.

Definition at line 155 of file XrdClFwd.hh.

155  : std::shared_ptr<FwdStorage<T>>( std::move( fwd ) )
156  {
157  }

◆ Fwd() [4/6]

template<typename T >
XrdCl::Fwd< T >::Fwd ( std::shared_ptr< FwdStorage< T >> &&  ptr)
inline

Initialize from shared_ptr.

Definition at line 162 of file XrdClFwd.hh.

162  : std::shared_ptr<FwdStorage<T>>( std::move( ptr ) )
163  {
164  }

◆ Fwd() [5/6]

template<typename T >
XrdCl::Fwd< T >::Fwd ( const T &  value)
inlineexplicit

Constructor from value.

Definition at line 169 of file XrdClFwd.hh.

170  {
171  *this->get() = value;
172  }

◆ Fwd() [6/6]

template<typename T >
XrdCl::Fwd< T >::Fwd ( T &&  value)
inlineexplicit

Move construct from value.

Definition at line 177 of file XrdClFwd.hh.

178  {
179  *this->get() = std::move( value );
180  }

Member Function Documentation

◆ operator*()

template<typename T >
T& XrdCl::Fwd< T >::operator* ( ) const
inline

Dereferencing operator. Note if Fwd has not been assigned with a value this will trigger an exception

Returns
: reference to the underlying value
Exceptions
std::logic_error

Definition at line 213 of file XrdClFwd.hh.

214  {
215  if( !bool( this->get()->ptr ) ) throw std::logic_error( "XrdCl::Fwd contains no value!" );
216  return *this->get()->ptr;
217  }

◆ operator->()

template<typename T >
T* XrdCl::Fwd< T >::operator-> ( ) const
inline

Dereferencing member operator. Note if Fwd has not been assigned with a value this will trigger an exception

Returns
: pointer to the underlying value
Exceptions
std::logic_error

Definition at line 226 of file XrdClFwd.hh.

227  {
228  if( !bool( this->get()->ptr ) ) throw std::logic_error( "XrdCl::Fwd contains no value!" );
229  return this->get()->ptr;
230  }

◆ operator=() [1/2]

template<typename T >
Fwd& XrdCl::Fwd< T >::operator= ( const T &  value)
inline

Assignment operator.

Parameters
value: forwarded value
Exceptions
std::logic_error

Definition at line 188 of file XrdClFwd.hh.

189  {
190  *this->get() = value;
191  return *this;
192  }

◆ operator=() [2/2]

template<typename T >
Fwd& XrdCl::Fwd< T >::operator= ( T &&  value)
inline

Move assignment operator.

Parameters
value: forwarded value
Exceptions
std::logic_error

Definition at line 200 of file XrdClFwd.hh.

201  {
202  *this->get() = std::move( value );
203  return *this;
204  }

◆ Valid()

template<typename T >
bool XrdCl::Fwd< T >::Valid ( ) const
inline

Check if it contains a valid value.

Definition at line 235 of file XrdClFwd.hh.

236  {
237  return bool( this->get()->ptr );
238  }

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