From: Alex Rousskov Date: Tue, 1 Feb 2011 05:17:51 +0000 (-0700) Subject: Added forgotten StrandSearch sources. X-Git-Tag: take01~10^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33727f0b248982ef90c9f3f15f1f63a42c45e757;p=thirdparty%2Fsquid.git Added forgotten StrandSearch sources. --- diff --git a/src/ipc/StrandSearch.cc b/src/ipc/StrandSearch.cc new file mode 100644 index 0000000000..7568ed8c0a --- /dev/null +++ b/src/ipc/StrandSearch.cc @@ -0,0 +1,58 @@ +/* + * $Id$ + * + * DEBUG: section 54 Interprocess Communication + * + */ + + +#include "config.h" +#include "ipc/Messages.h" +#include "ipc/StrandSearch.h" +#include "ipc/TypedMsgHdr.h" + + +Ipc::StrandSearchRequest::StrandSearchRequest(): requestorId(-1), requestId(0) +{ +} + +Ipc::StrandSearchRequest::StrandSearchRequest(const TypedMsgHdr &hdrMsg): + requestorId(-1), requestId(0) +{ + hdrMsg.checkType(mtStrandSearchRequest); + hdrMsg.getPod(requestorId); + hdrMsg.getPod(requestId); + hdrMsg.getString(tag); +} + +void Ipc::StrandSearchRequest::pack(TypedMsgHdr &hdrMsg) const +{ + hdrMsg.setType(mtStrandSearchRequest); + hdrMsg.putPod(requestorId); + hdrMsg.putPod(requestId); + hdrMsg.putString(tag); +} + + +/* StrandSearchResponse */ + +Ipc::StrandSearchResponse::StrandSearchResponse(int aRequestId, + const Ipc::StrandCoord &aStrand): + requestId(aRequestId), strand(aStrand) +{ +} + +Ipc::StrandSearchResponse::StrandSearchResponse(const TypedMsgHdr &hdrMsg): + requestId(0) +{ + hdrMsg.checkType(mtStrandSearchResponse); + hdrMsg.getPod(requestId); + strand.unpack(hdrMsg); +} + +void Ipc::StrandSearchResponse::pack(TypedMsgHdr &hdrMsg) const +{ + hdrMsg.setType(mtStrandSearchResponse); + hdrMsg.putPod(requestId); + strand.pack(hdrMsg); +} diff --git a/src/ipc/StrandSearch.h b/src/ipc/StrandSearch.h new file mode 100644 index 0000000000..a249a5df5e --- /dev/null +++ b/src/ipc/StrandSearch.h @@ -0,0 +1,46 @@ +/* + * $Id$ + * + */ + +#ifndef SQUID_IPC_STRAND_SEARCH_H +#define SQUID_IPC_STRAND_SEARCH_H + +#include "ipc/forward.h" +#include "ipc/StrandCoord.h" +#include "SquidString.h" +#include + +namespace Ipc +{ + +/// asynchronous strand search request +class StrandSearchRequest +{ +public: + StrandSearchRequest(); + explicit StrandSearchRequest(const TypedMsgHdr &hdrMsg); ///< from recvmsg() + void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg() + +public: + int requestorId; ///< sender-provided return address + unsigned int requestId; ///< sender-provided for response:request matching + String tag; ///< set when looking for a matching StrandCoord::tag +}; + +/// asynchronous strand search response +class StrandSearchResponse +{ +public: + StrandSearchResponse(int requestId, const StrandCoord &strand); + explicit StrandSearchResponse(const TypedMsgHdr &hdrMsg); ///< from recvmsg() + void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg() + +public: + unsigned int requestId; ///< a copy of the StrandSearchRequest::requestId + StrandCoord strand; ///< answer matching StrandSearchRequest criteria +}; + +} // namespace Ipc; + +#endif /* SQUID_IPC_STRAND_SEARCH_H */