summaryrefslogtreecommitdiffstats
path: root/src/lib/database/server.h
blob: 8ca8a436fc7c5b568199e7a20d51784091079b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef DB_SERVER_H
#define DB_SERVER_H

#include <cc/base_stamped_element.h>
#include <cc/cfg_to_element.h>
#include <cc/server_tag.h>
#include <boost/shared_ptr.hpp>
#include <string>

namespace isc {
namespace db {

class Server;

/// @brief Shared pointer to the @c Server class.
typedef boost::shared_ptr<Server> ServerPtr;

/// @brief Represents information about a Kea server in the database.
///
/// The configuration backend holds the information about the servers
/// for which the backend holds the configuration information. The
/// information includes the server tag (unique name), server description
/// provided by the administrator and the metadata.
///
/// This class extends the base class with the server description field.
class Server : public data::BaseStampedElement,  public data::CfgToElement {
public:

    /// @brief Constructor.
    ///
    /// @param tag server tag.
    /// @param description server description.
    Server(const data::ServerTag& tag, const std::string& description);

    /// @brief Factory function to be used to create an instance of the
    /// @c Server object.
    ///
    /// @param tag server tag.
    /// @param description server description.
    ///
    /// @return Pointer to the server instance.
    /// @throw BadValue if the server tag exceeds 256 characters or the
    /// description exceeds 65536 characters.
    static ServerPtr create(const data::ServerTag& tag,
                            const std::string& description = "");

    /// @brief Returns server tag.
    data::ServerTag getServerTag() const {
        return (server_tag_);
    }

    /// @brief Returns server tag as text.
    ///
    /// @return Server tag as text.
    std::string getServerTagAsText() const {
        return (server_tag_.get());
    }

    /// @brief Returns the description of the server.
    ///
    /// @return Description of the server or an empty string if no
    /// description was specified.
    std::string getDescription() const {
        return (description_);
    }

    /// @brief Unparses server object.
    ///
    /// @return A pointer to unparsed server configuration.
    virtual data::ElementPtr toElement() const;

private:

    /// @brief Server tag.
    data::ServerTag server_tag_;

    /// @brief Description of the server.
    std::string description_;
};

} // end of namespace isc::db
} // end of namespace isc

#endif // DB_SERVER_H