Kea  2.1.7-git
stamped_element.cc
Go to the documentation of this file.
1 // Copyright (C) 2018-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 <cc/stamped_element.h>
10 
11 namespace isc {
12 namespace data {
13 
15  : BaseStampedElement(), server_tags_() {
16 }
17 
18 bool
19 StampedElement::hasServerTag(const ServerTag& server_tag) const {
20  return (server_tags_.count(server_tag) > 0);
21 }
22 
23 void
24 StampedElement::delServerTag(const std::string& server_tag) {
25  if (!server_tags_.erase(ServerTag(server_tag))) {
26  isc_throw(NotFound, "can't find server tag '" << server_tag << "' to delete");
27  }
28 }
29 
30 bool
33 }
34 
35 
38  ElementPtr metadata = Element::createMap();
40 
41  for (auto server_tag : server_tags_) {
42  tags->add(Element::create(server_tag.get()));
43  }
44 
45  metadata->set("server-tags", tags);
46  return (metadata);
47 }
48 
49 } // end of namespace isc::data
50 } // end of namespace isc
void delServerTag(const std::string &server_tag)
Deletes server tag.
bool hasServerTag(const ServerTag &server_tag) const
Checks if the element has the given server tag.
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition: data.cc:286
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition: data.cc:281
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Represents a server tag.
Definition: server_tag.h:25
bool hasAllServerTag() const
Checks if the element has &#39;all&#39; server tag.
Defines the logger used by the top-level component of kea-lfc.
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition: data.cc:241
This class represents configuration element which is associated with database identifier and the modi...
static std::string ALL
Server tag for all servers as text.
Definition: server_tag.h:29
A generic exception that is thrown when an object can not be found.
isc::data::ElementPtr getMetadata() const
Returns an object representing metadata to be returned with objects from the configuration backend...