Commit 1f3ac9ac authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[4497] Documented Option::clone() in all option classes.

Also udated copyright dates where applicable.
parent eb2ccff4
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2016 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
......
......@@ -74,8 +74,7 @@ Option::operator=(const Option& rhs) {
OptionPtr
Option::clone() const {
OptionPtr option(new Option(*this));
return (option);
return (cloneInternal<Option>());
}
void
......@@ -214,6 +213,8 @@ Option::getOptionsCopy(OptionCollection& options_copy) const {
local_options.insert(std::make_pair(it->second->getType(),
copy));
}
// All options copied successfully, so assign them to the output
// parameter.
options_copy.swap(local_options);
}
......
......@@ -144,10 +144,31 @@ public:
Option(Universe u, uint16_t type, OptionBufferConstIter first,
OptionBufferConstIter last);
Option(const Option& option);
/// @brief Copy constructor.
///
/// This constructor makes a deep copy of the option and all of the
/// suboptions. It calls @ref getOptionsCopy to deep copy suboptions.
///
/// @param source Option to be copied.
Option(const Option& source);
/// @brief Assignment operator.
///
/// The assignment operator performs a deep copy of the option and
/// its suboptions. It calls @ref getOptionsCopy to deep copy
/// suboptions.
///
/// @param rhs Option to be assigned.
Option& operator=(const Option& rhs);
/// @brief Copies this option and returns a pointer to the copy.
///
/// This function must be overriden in the derived classes to make
/// a copy of the derived type. The simplest way to do it is by
/// calling @ref copyInternal function with an appropriate template
/// parmater.
///
/// @return Pointer to the copy of the option.
virtual OptionPtr clone() const;
/// @brief returns option universe (V4 or V6)
......@@ -263,6 +284,11 @@ public:
return (options_);
}
/// @brief Performs deep copy of suboptions.
///
/// This method calls @ref clone method to deep copy each option.
///
/// @param [out] options_copy Container where copied options are stored.
void getOptionsCopy(OptionCollection& options_copy) const;
/// Attempts to delete first suboption of requested type
......@@ -372,6 +398,15 @@ public:
protected:
/// @brief Copies this option and returns a pointer to the copy.
///
/// The deep copy of the option is performed by calling copy
/// constructor of the option of a given type. Derived classes call
/// this method in the implementations of @ref clone methods to
/// create a copy of the option of their type.
///
/// @tparam OptionType Type of the option of which a clone should
/// be created.
template<typename OptionType>
OptionPtr cloneInternal() const {
boost::shared_ptr<OptionType>
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......@@ -80,6 +80,7 @@ public:
Option4AddrLst(uint8_t type, OptionBufferConstIter first,
OptionBufferConstIter last);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// @brief Writes option in a wire-format to a buffer.
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......
......@@ -219,6 +219,7 @@ public:
/// @brief Copy constructor
Option4ClientFqdn(const Option4ClientFqdn& source);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// @brief Destructor
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -140,6 +140,7 @@ public:
/// @brief Copy constructor
Option6ClientFqdn(const Option6ClientFqdn& source);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// @brief Destructor
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......@@ -39,6 +39,7 @@ public:
Option6IA(uint16_t type, OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// Writes option in wire-format to buf, returns pointer to first unused
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2016 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
......@@ -46,6 +46,7 @@ public:
Option6IAAddr(uint32_t type, OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// @brief Writes option in wire-format.
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -74,6 +74,7 @@ public:
Option6IAPrefix(uint32_t type, OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// @brief Writes option in wire-format.
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......@@ -37,6 +37,7 @@ public:
/// @param end Iterator to end of option data (first byte after option end).
Option6StatusCode(OptionBufferConstIter begin, OptionBufferConstIter end);
/// @brief Copies this option and returns a pointer to the copy.
virtual OptionPtr clone() const;
/// @brief Writes option in wire-format.
......
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2016 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment