LCOV - code coverage report
Current view: top level - asiolink - io_message.h (source / functions) Hit Total Coverage
Test: report.info Lines: 1 5 20.0 %
Date: 2012-05-15 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #ifndef __IO_MESSAGE_H
      16                 :            : #define __IO_MESSAGE_H 1
      17                 :            : 
      18                 :            : // IMPORTANT NOTE: only very few ASIO headers files can be included in
      19                 :            : // this file.  In particular, asio.hpp should never be included here.
      20                 :            : // See the description of the namespace below.
      21                 :            : #include <unistd.h>             // for some network system calls
      22                 :            : 
      23                 :            : #include <functional>
      24                 :            : #include <string>
      25                 :            : 
      26                 :            : #include <exceptions/exceptions.h>
      27                 :            : 
      28                 :            : #include <asiolink/io_endpoint.h>
      29                 :            : #include <asiolink/io_socket.h>
      30                 :            : 
      31                 :            : namespace isc {
      32                 :            : namespace asiolink {
      33                 :            : 
      34                 :            : /// \brief The \c IOMessage class encapsulates an incoming message received
      35                 :            : /// on a socket.
      36                 :            : ///
      37                 :            : /// An \c IOMessage object represents a tuple of a chunk of data
      38                 :            : /// (a UDP packet or some segment of TCP stream), the socket over which the
      39                 :            : /// data is passed, the information about the other end point of the
      40                 :            : /// communication, and perhaps more.
      41                 :            : ///
      42                 :            : /// The current design and interfaces of this class is tentative.
      43                 :            : /// It only provides a minimal level of support that is necessary for
      44                 :            : /// the current implementation of the authoritative server.
      45                 :            : /// A future version of this class will definitely support more.
      46                 :            : class IOMessage {
      47                 :            :     ///
      48                 :            :     /// \name Constructors and Destructor
      49                 :            :     ///
      50                 :            : 
      51                 :            :     /// Note: The copy constructor and the assignment operator are
      52                 :            :     /// intentionally defined as private, making this class non-copyable.
      53                 :            :     //@{
      54                 :            : private:
      55                 :            :     IOMessage(const IOMessage& source);
      56                 :            :     IOMessage& operator=(const IOMessage& source);
      57                 :            : public:
      58                 :            :     /// \brief Constructor from message data
      59                 :            :     ///
      60                 :            :     /// This constructor needs to handle the ASIO \c ip::address class,
      61                 :            :     /// and is intended to be used within this wrapper implementation.
      62                 :            :     /// Once the \c IOMessage object is created, the application can
      63                 :            :     /// get access to the information via the wrapper interface such as
      64                 :            :     /// \c getRemoteAddress().
      65                 :            :     ///
      66                 :            :     /// This constructor never throws an exception.
      67                 :            :     ///
      68                 :            :     /// \param data A pointer to the message data.
      69                 :            :     /// \param data_size The size of the message data in bytes.
      70                 :            :     /// \param io_socket The socket over which the data is given.
      71                 :            :     /// \param remote_endpoint The other endpoint of the socket, that is,
      72                 :            :     /// the sender of the message.
      73                 :            :     IOMessage(const void* data, const size_t data_size,
      74                 :            :               const IOSocket& io_socket, const IOEndpoint& remote_endpoint) :
      75                 :            :         data_(data), data_size_(data_size), io_socket_(io_socket),
      76                 :        182 :         remote_endpoint_(remote_endpoint)
      77                 :            :     {}
      78                 :            :     //@}
      79                 :            : 
      80                 :            :     /// \brief Returns a pointer to the received data.
      81                 :          0 :     const void* getData() const { return (data_); }
      82                 :            : 
      83                 :            :     /// \brief Returns the size of the received data in bytes.
      84                 :          0 :     size_t getDataSize() const { return (data_size_); }
      85                 :            : 
      86                 :            :     /// \brief Returns the socket on which the message arrives.
      87                 :          0 :     const IOSocket& getSocket() const { return (io_socket_); }
      88                 :            : 
      89                 :            :     /// \brief Returns the endpoint that sends the message.
      90                 :          0 :     const IOEndpoint& getRemoteEndpoint() const { return (remote_endpoint_); }
      91                 :            : 
      92                 :            : private:
      93                 :            :     const void* data_;
      94                 :            :     const size_t data_size_;
      95                 :            :     const IOSocket& io_socket_;
      96                 :            :     const IOEndpoint& remote_endpoint_;
      97                 :            : };
      98                 :            : 
      99                 :            : 
     100                 :            : } // namespace asiolink
     101                 :            : } // namespace isc
     102                 :            : #endif // __IO_MESSAGE_H

Generated by: LCOV version 1.9