1 // RequestHandler.cpp 2 3 #include "Compatibility.h" 4 #include "RequestHandler.h" 5 6 // constructor RequestHandler()7RequestHandler::RequestHandler() 8 : RequestVisitor(), 9 fChannels() 10 { 11 } 12 13 // destructor ~RequestHandler()14RequestHandler::~RequestHandler() 15 { 16 } 17 18 // HandleRequest 19 status_t HandleRequest(Request * request,RequestChannel * channel)20RequestHandler::HandleRequest(Request* request, RequestChannel* channel) 21 { 22 if (!request) 23 return B_BAD_VALUE; 24 status_t error = fChannels.Set(channel); 25 if (error != B_OK) 26 return error; 27 ThreadLocalUnsetter _(fChannels); 28 return request->Accept(this); 29 } 30 31 // VisitAny 32 status_t VisitAny(Request * request)33RequestHandler::VisitAny(Request* request) 34 { 35 // unexpected request 36 return B_BAD_DATA; 37 } 38 39 // GetChannel 40 RequestChannel* GetChannel() const41RequestHandler::GetChannel() const 42 { 43 return (RequestChannel*)fChannels.Get(); 44 } 45 46