LCOV - code coverage report
Current view: top level - resolve - resolver_interface.h (source / functions) Hit Total Coverage
Test: report.info Lines: 4 4 100.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 __RESOLVER_INTERFACE_H
      16                 :            : #define __RESOLVER_INTERFACE_H
      17                 :            : 
      18                 :            : #include <dns/message.h>
      19                 :            : 
      20                 :            : ///
      21                 :            : /// \file resolver_interface.h
      22                 :            : /// \short Interface to resolver.
      23                 :            : ///
      24                 :            : /// This file contains an interface for the resolver. By subclassing
      25                 :            : /// this abstract interface, other parts of the system can ask the
      26                 :            : /// resolver to do some resolving too.
      27                 :            : ///
      28                 :            : /// This is done by creating a subclass of ResolverInterface::Callback,
      29                 :            : /// which defines what to do with the result, and then calling resolve()
      30                 :            : /// on the ResolverInterface implementation.
      31                 :            : ///
      32                 :            : /// One default Callback subclass is provided right now, in
      33                 :            : /// resolver_callback.[h|cc], which calls resumse() on a given DNSServer
      34                 :            : ///
      35                 :            : 
      36                 :            : namespace isc {
      37                 :            : namespace resolve {
      38                 :            : 
      39                 :            : ///
      40                 :            : /// \short Abstract interface to the resolver.
      41                 :            : ///
      42                 :            : /// Abstract interface to the resolver. The NameserverAddressStore uses this
      43                 :            : /// to ask for addresses. It is here because resolver does not yet exist.
      44                 :            : ///
      45                 :            : /// It is abstract to allow tests pass dummy resolvers.
      46                 :            : ///
      47                 :         92 : class ResolverInterface {
      48                 :            :     public:
      49                 :            :         /// \short An abstract callback for when the resolver is done.
      50                 :            :         ///
      51                 :            :         /// You can pass an instance of a subclass of this (as a
      52                 :            :         /// CallbackPtr) to RecursiveQuery::sendQuery(), and when it
      53                 :            :         /// is done, it will either call success() if there is an
      54                 :            :         /// answer MessagePtr, or failure(), if the resolver was not
      55                 :            :         /// able to find anything.
      56                 :            :         ///
      57                 :            :         /// Note that a result Message does not necessarily contain
      58                 :            :         /// the actual answer (it could be a noerror/nodata response).
      59                 :        128 :         class Callback {
      60                 :            :             public:
      61                 :            :                 /// \short Some data arrived.
      62                 :            :                 virtual void success(const isc::dns::MessagePtr response) = 0;
      63                 :            :                 
      64                 :            :                 ///
      65                 :            :                 ///\short No data available.
      66                 :            :                 ///
      67                 :            :                 ///\todo Provide error reason (result of the
      68                 :            :                 ///      classification call, for instance? We'd also
      69                 :            :                 ///      need some way to say 'everything times out')
      70                 :            :                 ///
      71                 :            :                 virtual void failure() = 0;
      72                 :            : 
      73                 :            :                 /// \short Virtual destructor, so descendants are cleaned up
      74                 :        120 :                 virtual ~Callback() {};
      75                 :            :         };
      76                 :            : 
      77                 :            :         typedef boost::shared_ptr<Callback> CallbackPtr;
      78                 :            : 
      79                 :            :         ///
      80                 :            :         ///\short Ask a question.
      81                 :            :         ///
      82                 :            :         /// Asks the resolver a question. Once the answer is ready
      83                 :            :         /// the callback is called.
      84                 :            :         ///
      85                 :            :         /// \param question What to ask. The resolver will decide who.
      86                 :            :         /// \param callback What should happen when the answer is ready.
      87                 :            :         ///
      88                 :            :         virtual void resolve(const isc::dns::QuestionPtr& question,
      89                 :            :             const CallbackPtr& callback) = 0;
      90                 :            : 
      91                 :            :         /// \short Virtual destructor, so descendants are properly cleaned up
      92                 :         92 :         virtual ~ ResolverInterface() {}
      93                 :            : };
      94                 :            : 
      95                 :            : } // namespace nsas
      96                 :            : } // namespace isc
      97                 :            : 
      98                 :            : #endif //__RESOLVER_INTERFACE_H

Generated by: LCOV version 1.9