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 _XFROUT_CLIENT_H
16 : : #define _XFROUT_CLIENT_H
17 : :
18 : : #include <stdint.h>
19 : :
20 : : #include <string>
21 : :
22 : : #include <exceptions/exceptions.h>
23 : :
24 : : namespace isc {
25 : : namespace xfr {
26 : :
27 : : struct XfroutClientImpl;
28 : :
29 : 10 : class XfroutError: public Exception {
30 : : public:
31 : 2 : XfroutError(const char *file, size_t line, const char *what):
32 [ + - ][ + - ]: 10 : isc::Exception(file, line, what) {}
[ + - ]
33 : : };
34 : :
35 : : /// \brief The AbstractXfroutClient class is an abstract base class that
36 : : /// defines the interfaces of XfroutClient.
37 : : ///
38 : : /// The intended primary usage of abstraction is to allow tests for the
39 : : /// user class of XfroutClient without requiring actual communication.
40 : : class AbstractXfroutClient {
41 : : ///
42 : : /// \name Constructors, Assignment Operator and Destructor.
43 : : ///
44 : : /// Note: The copy constructor and the assignment operator are
45 : : /// intentionally defined as private to make it explicit that this is a
46 : : /// pure base class.
47 : : //@{
48 : : private:
49 : : AbstractXfroutClient(const AbstractXfroutClient& source);
50 : : AbstractXfroutClient& operator=(const AbstractXfroutClient& source);
51 : : protected:
52 : : /// \brief The default constructor.
53 : : ///
54 : : /// This is intentionally defined as \c protected as this base class should
55 : : /// never be instantiated (except as part of a derived class).
56 : 96 : AbstractXfroutClient() {}
57 : : public:
58 : : /// \brief The destructor.
59 : 96 : virtual ~AbstractXfroutClient() {}
60 : : //@}
61 : : virtual void connect() = 0;
62 : : virtual void disconnect() = 0;
63 : : virtual int sendXfroutRequestInfo(int tcp_sock, const void* msg_data,
64 : : uint16_t msg_len) = 0;
65 : : };
66 : :
67 : : class XfroutClient : public AbstractXfroutClient {
68 : : public:
69 : : XfroutClient(const std::string& file);
70 : : ~XfroutClient();
71 : : private:
72 : : // make this class non copyable
73 : : XfroutClient(const XfroutClient& source);
74 : : XfroutClient& operator=(const XfroutClient& source);
75 : : public:
76 : : virtual void connect();
77 : : virtual void disconnect();
78 : : virtual int sendXfroutRequestInfo(int tcp_sock, const void* msg_data,
79 : : uint16_t msg_len);
80 : : private:
81 : : XfroutClientImpl* impl_;
82 : : };
83 : :
84 : : } // End for namespace xfr
85 : : } // End for namespace isc
86 : :
87 : : #endif
88 : :
89 : : // Local Variables:
90 : : // mode: c++
91 : : // End:
|