Kea  2.1.7-git
server.cc
Go to the documentation of this file.
1 // Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
8 
9 #include <database/server.h>
10 #include <exceptions/exceptions.h>
11 #include <boost/make_shared.hpp>
12 
13 using namespace isc::db;
14 using namespace isc::data;
15 
16 namespace isc {
17 namespace db {
18 
19 Server::Server(const ServerTag& tag, const std::string& description)
20  : BaseStampedElement(), server_tag_(tag), description_(description) {
21 
22  if (description_.length() > 65536) {
23  isc_throw(BadValue, "server description must not be longer than"
24  " 65536 characters");
25  }
26 }
27 
29 Server::create(const ServerTag& tag, const std::string& description) {
30  return (boost::make_shared<Server>(tag, description));
31 }
32 
35  ElementPtr result = Element::createMap();
36 
37  result->set("server-tag", Element::create(getServerTagAsText()));
38  result->set("description", Element::create(getDescription()));
39 
40  return (result);
41 }
42 
43 } // end of namespace isc::db
44 } // end of namespace isc
std::string getDescription() const
Returns the description of the server.
Definition: server.h:69
boost::shared_ptr< Server > ServerPtr
Shared pointer to the Server class.
Definition: server.h:19
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
Server(const data::ServerTag &tag, const std::string &description)
Constructor.
Definition: server.cc:19
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Represents a server tag.
Definition: server_tag.h:25
virtual data::ElementPtr toElement() const
Unparses server object.
Definition: server.cc:34
Defines the logger used by the top-level component of kea-lfc.
static ServerPtr create(const data::ServerTag &tag, const std::string &description="")
Factory function to be used to create an instance of the Server object.
Definition: server.cc:29
This class represents configuration element which is associated with database identifier and the modi...
std::string getServerTagAsText() const
Returns server tag as text.
Definition: server.h:61