XRootD
XrdCl::ResponseHandler Class Reference

Handle an async response. More...

#include <XrdClXRootDResponses.hh>

+ Inheritance diagram for XrdCl::ResponseHandler:
+ Collaboration diagram for XrdCl::ResponseHandler:

Public Member Functions

virtual ~ResponseHandler ()
 
virtual void HandleResponse (XRootDStatus *status, AnyObject *response)
 
virtual void HandleResponseWithHosts (XRootDStatus *status, AnyObject *response, HostList *hostList)
 

Static Public Member Functions

static ResponseHandlerWrap (std::function< void(XRootDStatus &, AnyObject &)> func)
 
static ResponseHandlerWrap (std::function< void(XRootDStatus *, AnyObject *)> func)
 

Detailed Description

Handle an async response.

Definition at line 1126 of file XrdClXRootDResponses.hh.

Constructor & Destructor Documentation

◆ ~ResponseHandler()

virtual XrdCl::ResponseHandler::~ResponseHandler ( )
inlinevirtual

Definition at line 1129 of file XrdClXRootDResponses.hh.

1129 {}

Member Function Documentation

◆ HandleResponse()

virtual void XrdCl::ResponseHandler::HandleResponse ( XRootDStatus status,
AnyObject response 
)
inlinevirtual

Called when a response to associated request arrives or an error occurs

Parameters
statusstatus of the request
responsean object associated with the response (request dependent)

Reimplemented in XrdCl::ChunkHandler, XrdCl::PipelineHandler, XrdCl::FutureWrapper< void >, XrdCl::FutureWrapper< Response >, XrdCl::TaskWrapper< void, Return >, XrdCl::TaskWrapper< Response, Return >, XrdCl::UnpackXAttr, XrdCl::UnpackXAttrStatus, XrdCl::MetalinkReadHandler, XrdCl::SyncResponseHandler, XrdCl::EcPgReadResponseHandler, XrdCl::ZipListHandler, XrdPosixFile, XrdSsiEvent, XrdPosixFileRH, and XrdCl::PgReadSubstitutionHandler.

Definition at line 1156 of file XrdClXRootDResponses.hh.

1158  {
1159  (void)status; (void)response;
1160  }

Referenced by XrdCl::EcHandler::Close(), XrdCl::HttpFilePlugIn::Close(), XrdCl::ZipArchive::CloseArchive(), XrdCl::HttpFileSystemPlugIn::DirList(), XrdCl::PgReadSubstitutionHandler::HandleResponse(), XrdCl::ZipListHandler::HandleResponse(), XrdCl::EcPgReadResponseHandler::HandleResponse(), XrdCl::MetalinkReadHandler::HandleResponse(), XrdCl::UnpackXAttrStatus::HandleResponse(), XrdCl::UnpackXAttr::HandleResponse(), HandleResponseWithHosts(), XrdCl::HttpFileSystemPlugIn::MkDir(), XrdCl::HttpFileSystemPlugIn::Mv(), XrdCl::HttpFilePlugIn::Open(), XrdEc::Reader::Open(), XrdCl::ZipArchive::OpenArchive(), XrdCl::FileStateHandler::PgWrite(), XrdCl::HttpFilePlugIn::Read(), XrdCl::HttpFileSystemPlugIn::Rm(), XrdCl::HttpFileSystemPlugIn::RmDir(), XrdEc::ResponseJob::Run(), XrdCl::HttpFilePlugIn::Stat(), XrdCl::HttpFileSystemPlugIn::Stat(), XrdCl::HttpFilePlugIn::VectorRead(), XrdEc::Reader::VectorRead(), Wrap(), and XrdCl::HttpFilePlugIn::Write().

+ Here is the caller graph for this function:

◆ HandleResponseWithHosts()

virtual void XrdCl::ResponseHandler::HandleResponseWithHosts ( XRootDStatus status,
AnyObject response,
HostList hostList 
)
inlinevirtual

Called when a response to associated request arrives or an error occurs

Parameters
statusstatus of the request
responsean object associated with the response (request dependent)
hostListlist of hosts the request was redirected to

Reimplemented in XrdCl::PipelineHandler, XrdCl::RawWrapper, XrdCl::ExOpenFuncWrapper, XrdCl::FunctionWrapper< void >, XrdCl::FunctionWrapper< Response >, XrdCl::MetalinkOpenHandler, XrdCl::AssignLastURLHandler, XrdCl::AssignLBHandler, and XrdCl::NullResponseHandler.

Definition at line 1140 of file XrdClXRootDResponses.hh.

1143  {
1144  delete hostList;
1145  HandleResponse( status, response );
1146  }
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)

References HandleResponse().

Referenced by XrdCl::AssignLBHandler::HandleResponseWithHosts(), XrdCl::AssignLastURLHandler::HandleResponseWithHosts(), XrdCl::MetalinkOpenHandler::HandleResponseWithHosts(), XrdCl::RawWrapper::HandleResponseWithHosts(), XrdCl::LocalFileTask::Run(), XrdCl::ResponseJob::Run(), and XrdCl::FileStateHandler::Stat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Wrap() [1/2]

ResponseHandler * XrdCl::ResponseHandler::Wrap ( std::function< void(XRootDStatus &, AnyObject &)>  func)
static

Factory function for generating handler objects from lambdas

Parameters
func: the callback, must not throw
Returns
: ResponseHandler wrapper with the user callback

Definition at line 760 of file XrdClXRootDResponses.cc.

761  {
762  struct FuncHandler : public ResponseHandler
763  {
764  FuncHandler( std::function<void(XRootDStatus&, AnyObject&)> func ) : func( std::move( func ) )
765  {
766  }
767 
768  void HandleResponse( XRootDStatus *status, AnyObject *response )
769  {
770  // make sure the arguments will be released
771  std::unique_ptr<XRootDStatus> stptr( status );
772  std::unique_ptr<AnyObject> rspptr( response );
773  // if there is no response provide a null reference placeholder
774  static AnyObject nullref;
775  if( response == nullptr )
776  response = &nullref;
777  // call the user completion handler
778  func( *status, *response );
779  // check if this is a final respons
780  bool finalrsp = !( status->IsOK() && status->code == suContinue );
781  // deallocate the wrapper if final
782  if( finalrsp )
783  delete this;
784  }
785 
786  std::function<void(XRootDStatus&, AnyObject&)> func;
787  };
788 
789  return new FuncHandler( func );
790  }
const uint16_t suContinue
Definition: XrdClStatus.hh:39

References XrdCl::Status::code, HandleResponse(), XrdCl::Status::IsOK(), and XrdCl::suContinue.

Referenced by XrdCl::EcHandler::Close(), and XrdCl::FileStateHandler::PgWrite().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Wrap() [2/2]

ResponseHandler * XrdCl::ResponseHandler::Wrap ( std::function< void(XRootDStatus *, AnyObject *)>  func)
static

Factory function for generating handler objects from lambdas

Parameters
func: the callback, must not throw
Returns
: ResponseHandler wrapper with the user callback

Definition at line 792 of file XrdClXRootDResponses.cc.

793  {
794  struct FuncHandler : public ResponseHandler
795  {
796  FuncHandler( std::function<void(XRootDStatus*, AnyObject*)> func ) : func( std::move( func ) )
797  {
798  }
799 
800  void HandleResponse( XRootDStatus *status, AnyObject *response )
801  {
802  // check if this is a final respons
803  bool finalrsp = !( status->IsOK() && status->code == suContinue );
804  // call the user completion handler
805  func( status, response );
806  // deallocate the wrapper if final
807  if( finalrsp )
808  delete this;
809  }
810 
811  std::function<void(XRootDStatus*, AnyObject*)> func;
812  };
813 
814  return new FuncHandler( func );
815  }

References XrdCl::Status::code, HandleResponse(), XrdCl::Status::IsOK(), and XrdCl::suContinue.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: