Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 10:11:00

0001 //------------------------------------------------------------------------------
0002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
0003 // Author: Lukasz Janyst <ljanyst@cern.ch>
0004 //------------------------------------------------------------------------------
0005 // XRootD is free software: you can redistribute it and/or modify
0006 // it under the terms of the GNU Lesser General Public License as published by
0007 // the Free Software Foundation, either version 3 of the License, or
0008 // (at your option) any later version.
0009 //
0010 // XRootD is distributed in the hope that it will be useful,
0011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 // GNU General Public License for more details.
0014 //
0015 // You should have received a copy of the GNU Lesser General Public License
0016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
0017 //------------------------------------------------------------------------------
0018 
0019 #ifndef __XRD_CL_MESSAGE_HH__
0020 #define __XRD_CL_MESSAGE_HH__
0021 
0022 #include "XrdCl/XrdClBuffer.hh"
0023 
0024 namespace XrdCl
0025 {
0026   //----------------------------------------------------------------------------
0027   //! The message representation used throughout the system
0028   //----------------------------------------------------------------------------
0029   class Message: public Buffer
0030   {
0031     public:
0032       //------------------------------------------------------------------------
0033       //! Constructor
0034       //------------------------------------------------------------------------
0035       Message( uint32_t size = 0 ):
0036         Buffer( size ), pIsMarshalled( false ), pSessionId(0), pVirtReqID( 0 )
0037       {
0038         if( size )
0039           Zero();
0040       }
0041 
0042       //------------------------------------------------------------------------
0043       //! Move Constructor
0044       //------------------------------------------------------------------------
0045       Message( Message && msg ):
0046         Buffer( std::move( msg ) ), pIsMarshalled( msg.pIsMarshalled ),
0047         pSessionId( std::move( msg.pSessionId ) ), pVirtReqID( msg.pVirtReqID )
0048       {
0049       }
0050 
0051       //------------------------------------------------------------------------
0052       //! Move assignment operator
0053       //------------------------------------------------------------------------
0054       Message& operator=( Message && msg )
0055       {
0056         Steal( std::move( msg ) );
0057         pIsMarshalled = msg.pIsMarshalled;
0058         pSessionId = std::move( msg.pSessionId );
0059         pVirtReqID = msg.pVirtReqID;
0060         return *this;
0061       }
0062 
0063       //------------------------------------------------------------------------
0064       //! Destructor
0065       //------------------------------------------------------------------------
0066       virtual ~Message() {}
0067 
0068       //------------------------------------------------------------------------
0069       //! Check if the message is marshalled
0070       //------------------------------------------------------------------------
0071       bool IsMarshalled() const
0072       {
0073         return pIsMarshalled;
0074       }
0075 
0076       //------------------------------------------------------------------------
0077       //! Set the marshalling status
0078       //------------------------------------------------------------------------
0079       void SetIsMarshalled( bool isMarshalled )
0080       {
0081         pIsMarshalled = isMarshalled;
0082       }
0083 
0084       //------------------------------------------------------------------------
0085       //! Set the description of the message
0086       //------------------------------------------------------------------------
0087       void SetDescription( const std::string &description )
0088       {
0089         pDescription = description;
0090       }
0091 
0092       //------------------------------------------------------------------------
0093       //! Get the description of the message
0094       //------------------------------------------------------------------------
0095       const std::string &GetDescription() const
0096       {
0097         return pDescription;
0098       }
0099 
0100       //------------------------------------------------------------------------
0101       //! Set the session ID which this message is meant for
0102       //------------------------------------------------------------------------
0103       void SetSessionId( uint64_t sessionId )
0104       {
0105         pSessionId = sessionId;
0106       }
0107 
0108       //------------------------------------------------------------------------
0109       //! Get the session ID the message is meant for
0110       //------------------------------------------------------------------------
0111       uint64_t GetSessionId() const
0112       {
0113         return pSessionId;
0114       }
0115 
0116       //------------------------------------------------------------------------
0117       //! Set virtual request ID for the message
0118       //------------------------------------------------------------------------
0119       void SetVirtReqID( uint16_t virtReqID )
0120       {
0121         pVirtReqID = virtReqID;
0122       }
0123 
0124       //------------------------------------------------------------------------
0125       //! Get virtual request ID for the message
0126       //------------------------------------------------------------------------
0127       uint16_t GetVirtReqID() const
0128       {
0129         return pVirtReqID;
0130       }
0131 
0132     private:
0133       bool         pIsMarshalled;
0134       uint64_t     pSessionId;
0135       std::string  pDescription;
0136       uint16_t     pVirtReqID;
0137   };
0138 }
0139 
0140 #endif // __XRD_CL_MESSAGE_HH__