Apache log4cxx  Version 0.12.0
datagrampacket.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_HELPERS_DATAGRAM_PACKET
19 #define _LOG4CXX_HELPERS_DATAGRAM_PACKET
20 
21 #include <log4cxx/helpers/object.h>
23 
24 namespace log4cxx
25 {
26 namespace helpers
27 {
28 
36 class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
37 {
38  protected:
40  void* buf;
41 
43  int offset;
44 
46  int length;
47 
49  InetAddressPtr address;
50 
52  int port;
53 
54  public:
59 
62  DatagramPacket(void* buf, int length);
63 
67  DatagramPacket(void* buf, int length, InetAddressPtr address, int port);
68 
71  DatagramPacket(void* buf, int offset, int length);
72 
76  DatagramPacket(void* buf, int offset, int length, InetAddressPtr address,
77  int port);
78 
79  ~DatagramPacket();
80 
83  inline InetAddressPtr getAddress() const
84  {
85  return address;
86  }
87 
89  inline void* getData() const
90  {
91  return buf;
92  }
93 
96  inline int getLength() const
97  {
98  return length;
99  }
100 
103  inline int getOffset() const
104  {
105  return offset;
106  }
107 
110  inline int getPort() const
111  {
112  return port;
113  }
114 
115  inline void setAddress(InetAddressPtr address1)
116  {
117  this->address = address1;
118  }
119 
121  inline void setData(void* buf1)
122  {
123  this->buf = buf1;
124  }
125 
127  inline void setData(void* buf1, int offset1, int length1)
128  {
129  this->buf = buf1;
130  this->offset = offset1;
131  this->length = length1;
132  }
133 
135  inline void setLength(int length1)
136  {
137  this->length = length1;
138  }
139 
140  inline void setPort(int port1)
141  {
142  this->port = port1;
143  }
144 
145  private:
146  //
147  // prevent copy and assignment statements
149  DatagramPacket& operator=(const DatagramPacket&);
150 
151 }; // class DatagramPacket
153 } // namespace helpers
154 } // namespace log4cxx
155 
156 #endif // _LOG4CXX_HELPERS_DATAGRAM_PACKET
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
void * getData() const
Returns the data received or the data to be sent.
Definition: datagrampacket.h:89
int getOffset() const
Returns the offset of the data to be sent or the offset of the data received.
Definition: datagrampacket.h:103
int getLength() const
Returns the length of the data to be sent or the length of the data received.
Definition: datagrampacket.h:96
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
LOG4CXX_PTR_DEF(AppenderAttachableImpl)
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
int port
The UDP port number of the remote host.
Definition: datagrampacket.h:52
int offset
The offset of the data for this packet.
Definition: datagrampacket.h:43
int length
The length of the data for this packet.
Definition: datagrampacket.h:46
void setAddress(InetAddressPtr address1)
Definition: datagrampacket.h:115
void * buf
the data for this packet.
Definition: datagrampacket.h:40
int getPort() const
Returns the port number on the remote host to which this datagram is being sent or from which the dat...
Definition: datagrampacket.h:110
void setPort(int port1)
Definition: datagrampacket.h:140
base class for java-like objects.
Definition: object.h:101
void setLength(int length1)
Set the length for this packet.
Definition: datagrampacket.h:135
void setData(void *buf1)
Set the data buffer for this packet.
Definition: datagrampacket.h:121
This class represents a datagram packet.
Definition: datagrampacket.h:36
Definition: appender.h:32
void setData(void *buf1, int offset1, int length1)
Set the data buffer for this packet.
Definition: datagrampacket.h:127
InetAddressPtr address
The IP address for this packet.
Definition: datagrampacket.h:49