XRootD
XrdClMessage.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_MESSAGE_HH__
20 #define __XRD_CL_MESSAGE_HH__
21 
22 #include "XrdCl/XrdClBuffer.hh"
23 #include "XrdOuc/XrdOucUtils.hh"
25 
26 namespace XrdCl
27 {
28  //----------------------------------------------------------------------------
30  //----------------------------------------------------------------------------
31  class Message: public Buffer
32  {
33  public:
34  //------------------------------------------------------------------------
36  //------------------------------------------------------------------------
37  Message( uint32_t size = 0 ):
38  Buffer( size ), pIsMarshalled( false ), pSessionId(0), pVirtReqID( 0 )
39  {
40  if( size )
41  Zero();
42  }
43 
44  //------------------------------------------------------------------------
46  //------------------------------------------------------------------------
47  Message( Message && msg ):
48  Buffer( std::move( msg ) ), pIsMarshalled( msg.pIsMarshalled ),
49  pSessionId( std::move( msg.pSessionId ) ), pVirtReqID( msg.pVirtReqID )
50  {
51  }
52 
53  //------------------------------------------------------------------------
55  //------------------------------------------------------------------------
57  {
58  Steal( std::move( msg ) );
59  pIsMarshalled = msg.pIsMarshalled;
60  pSessionId = std::move( msg.pSessionId );
61  pVirtReqID = msg.pVirtReqID;
62  return *this;
63  }
64 
65  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  virtual ~Message() {}
69 
70  //------------------------------------------------------------------------
72  //------------------------------------------------------------------------
73  bool IsMarshalled() const
74  {
75  return pIsMarshalled;
76  }
77 
78  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  void SetIsMarshalled( bool isMarshalled )
82  {
83  pIsMarshalled = isMarshalled;
84  }
85 
86  //------------------------------------------------------------------------
88  //------------------------------------------------------------------------
89  void SetDescription( const std::string &description )
90  {
91  pDescription = description;
92  pObfuscatedDescription = obfuscateAuth(description);
93  }
94 
95  //------------------------------------------------------------------------
97  //------------------------------------------------------------------------
98  const std::string &GetDescription() const
99  {
100  return pDescription;
101  }
102 
103  //------------------------------------------------------------------------
105  //------------------------------------------------------------------------
106  const std::string & GetObfuscatedDescription() const
107  {
108  return pObfuscatedDescription;
109  }
110 
111  //------------------------------------------------------------------------
113  //------------------------------------------------------------------------
114  void SetSessionId( uint64_t sessionId )
115  {
116  pSessionId = sessionId;
117  }
118 
119  //------------------------------------------------------------------------
121  //------------------------------------------------------------------------
122  uint64_t GetSessionId() const
123  {
124  return pSessionId;
125  }
126 
127  //------------------------------------------------------------------------
129  //------------------------------------------------------------------------
130  void SetVirtReqID( uint16_t virtReqID )
131  {
132  pVirtReqID = virtReqID;
133  }
134 
135  //------------------------------------------------------------------------
137  //------------------------------------------------------------------------
138  uint16_t GetVirtReqID() const
139  {
140  return pVirtReqID;
141  }
142 
143  private:
144  bool pIsMarshalled;
145  uint64_t pSessionId;
146  std::string pDescription;
147  uint16_t pVirtReqID;
148  std::string pObfuscatedDescription;
149  };
150 }
151 
152 #endif // __XRD_CL_MESSAGE_HH__
std::string obfuscateAuth(const std::string &input)
Binary blob representation.
Definition: XrdClBuffer.hh:34
void Steal(Buffer &&buffer)
Definition: XrdClBuffer.hh:249
void Zero()
Zero.
Definition: XrdClBuffer.hh:124
The message representation used throughout the system.
Definition: XrdClMessage.hh:32
virtual ~Message()
Destructor.
Definition: XrdClMessage.hh:68
const std::string & GetObfuscatedDescription() const
Get the description of the message with authz parameter obfuscated.
const std::string & GetDescription() const
Get the description of the message.
Definition: XrdClMessage.hh:98
void SetDescription(const std::string &description)
Set the description of the message.
Definition: XrdClMessage.hh:89
void SetSessionId(uint64_t sessionId)
Set the session ID which this message is meant for.
void SetVirtReqID(uint16_t virtReqID)
Set virtual request ID for the message.
void SetIsMarshalled(bool isMarshalled)
Set the marshalling status.
Definition: XrdClMessage.hh:81
bool IsMarshalled() const
Check if the message is marshalled.
Definition: XrdClMessage.hh:73
uint16_t GetVirtReqID() const
Get virtual request ID for the message.
Message(Message &&msg)
Move Constructor.
Definition: XrdClMessage.hh:47
Message & operator=(Message &&msg)
Move assignment operator.
Definition: XrdClMessage.hh:56
Message(uint32_t size=0)
Constructor.
Definition: XrdClMessage.hh:37
uint64_t GetSessionId() const
Get the session ID the message is meant for.