XRootD
XrdCl::Ctx< T > Struct Template Reference

Utility class for storing a pointer to operation context. More...

#include <XrdClCtx.hh>

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

Public Member Functions

 Ctx ()
 Default constructor. More...
 
 Ctx (const Ctx &ctx)
 Copy constructor. More...
 
 Ctx (Ctx &&ctx)
 Move constructor. More...
 
 Ctx (T &ctx)
 Constructor (from reference) More...
 
 Ctx (T *ctx)
 Constructor (from pointer) More...
 
T & operator* () const
 
T * operator-> () const
 
Ctxoperator= (T &ctx)
 Assignment operator (from reference) More...
 
Ctxoperator= (T *ctx)
 Assignment operator (from pointer) More...
 

Detailed Description

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

Utility class for storing a pointer to operation context.

Definition at line 38 of file XrdClCtx.hh.

Constructor & Destructor Documentation

◆ Ctx() [1/5]

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

Default constructor.

Definition at line 43 of file XrdClCtx.hh.

43  : std::shared_ptr<T*>( std::make_shared<T*>() )
44  {
45  }

◆ Ctx() [2/5]

template<typename T >
XrdCl::Ctx< T >::Ctx ( T *  ctx)
inline

Constructor (from pointer)

Definition at line 50 of file XrdClCtx.hh.

50  : std::shared_ptr<T*>( std::make_shared<T*>( ctx ) )
51  {
52  }

◆ Ctx() [3/5]

template<typename T >
XrdCl::Ctx< T >::Ctx ( T &  ctx)
inline

Constructor (from reference)

Definition at line 57 of file XrdClCtx.hh.

57  : std::shared_ptr<T*>( std::make_shared<T*>( &ctx ) )
58  {
59  }

◆ Ctx() [4/5]

template<typename T >
XrdCl::Ctx< T >::Ctx ( const Ctx< T > &  ctx)
inline

Copy constructor.

Definition at line 64 of file XrdClCtx.hh.

64  : std::shared_ptr<T*>( ctx )
65  {
66  }

◆ Ctx() [5/5]

template<typename T >
XrdCl::Ctx< T >::Ctx ( Ctx< T > &&  ctx)
inline

Move constructor.

Definition at line 71 of file XrdClCtx.hh.

71  : std::shared_ptr<T*>( std::move( ctx ) )
72  {
73  }

Member Function Documentation

◆ operator*()

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

Dereferencing operator. Note if Ctx is a null-reference this will trigger an exception

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

Definition at line 100 of file XrdClCtx.hh.

101  {
102  if( !bool( *this->get() ) ) throw std::logic_error( "XrdCl::Ctx contains no value!" );
103  return **this->get();
104  }

◆ operator->()

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

Dereferencing member operator. Note if Ctx is a null-reference this will trigger an exception

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

Definition at line 113 of file XrdClCtx.hh.

114  {
115  if( !bool( *this->get() ) ) throw std::logic_error( "XrdCl::Ctx contains no value!" );
116  return *this->get();
117  }

◆ operator=() [1/2]

template<typename T >
Ctx& XrdCl::Ctx< T >::operator= ( T &  ctx)
inline

Assignment operator (from reference)

Definition at line 87 of file XrdClCtx.hh.

88  {
89  *this->get() = &ctx;
90  return *this;
91  }

◆ operator=() [2/2]

template<typename T >
Ctx& XrdCl::Ctx< T >::operator= ( T *  ctx)
inline

Assignment operator (from pointer)

Definition at line 78 of file XrdClCtx.hh.

79  {
80  *this->get() = ctx;
81  return *this;
82  }

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