Browse Source

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

Also udated copyright dates where applicable.
Marcin Siodelski 9 years ago
parent
commit
1f3ac9ac2b

+ 1 - 1
src/bin/perfdhcp/localized_option.h

@@ -1,4 +1,4 @@
-// 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

+ 3 - 2
src/lib/dhcp/option.cc

@@ -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);
 }
 

+ 36 - 1
src/lib/dhcp/option.h

@@ -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>

+ 1 - 1
src/lib/dhcp/option4_addrlst.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option4_addrlst.h

@@ -1,4 +1,4 @@
-// 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.

+ 1 - 1
src/lib/dhcp/option4_client_fqdn.cc

@@ -1,4 +1,4 @@
-// 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

+ 1 - 0
src/lib/dhcp/option4_client_fqdn.h

@@ -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

+ 1 - 1
src/lib/dhcp/option6_addrlst.cc

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/dhcp/option6_addrlst.h

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/dhcp/option6_client_fqdn.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option6_client_fqdn.h

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/dhcp/option6_ia.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option6_ia.h

@@ -1,4 +1,4 @@
-// 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

+ 1 - 1
src/lib/dhcp/option6_iaaddr.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option6_iaaddr.h

@@ -1,4 +1,4 @@
-// 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.

+ 1 - 1
src/lib/dhcp/option6_iaprefix.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option6_iaprefix.h

@@ -1,4 +1,4 @@
-// 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.

+ 1 - 1
src/lib/dhcp/option6_status_code.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option6_status_code.h

@@ -1,4 +1,4 @@
-// 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.

+ 1 - 1
src/lib/dhcp/option_custom.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option_custom.h

@@ -1,4 +1,4 @@
-// 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
@@ -79,6 +79,7 @@ public:
     OptionCustom(const OptionDefinition& def, Universe u,
                  OptionBufferConstIter first, OptionBufferConstIter last);
 
+    /// @brief Copies this option and returns a pointer to the copy.
     virtual OptionPtr clone() const;
 
     /// @brief Create new buffer and set its value as an IP address.

+ 3 - 1
src/lib/dhcp/option_int.h

@@ -1,4 +1,4 @@
-// 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
@@ -48,6 +48,7 @@ template<typename T>
 class OptionInt: public Option {
 private:
 
+    /// @brief Pointer to the option object for a specified type T.
     typedef boost::shared_ptr<OptionInt<T> > OptionIntTypePtr;
 
 public:
@@ -93,6 +94,7 @@ public:
         unpack(begin, end);
     }
 
+    /// @brief Copies this option and returns a pointer to the copy.
     virtual OptionPtr clone() const {
         return (cloneInternal<OptionInt<T> >());
     }

+ 3 - 1
src/lib/dhcp/option_int_array.h

@@ -1,4 +1,4 @@
-// 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
@@ -56,6 +56,7 @@ template<typename T>
 class OptionIntArray: public Option {
 private:
 
+    /// @brief Pointer to the option type for the specified T.
     typedef boost::shared_ptr<OptionIntArray<T> > OptionIntArrayTypePtr;
 
 public:
@@ -120,6 +121,7 @@ public:
         unpack(begin, end);
     }
 
+    /// @brief Copies this option and returns a pointer to the copy.
     virtual OptionPtr clone() const {
         return (cloneInternal<OptionIntArray<T> >());
     }

+ 1 - 0
src/lib/dhcp/option_opaque_data_tuples.h

@@ -62,6 +62,7 @@ public:
                            OptionBufferConstIter begin,
                            OptionBufferConstIter end);
 
+    /// @brief Copies this option and returns a pointer to the copy.
     OptionPtr clone() const;
 
     /// @brief Renders option into the buffer in the wire format.

+ 1 - 1
src/lib/dhcp/option_string.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option_string.h

@@ -1,4 +1,4 @@
-// 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
@@ -56,6 +56,7 @@ public:
     OptionString(const Option::Universe u, const uint16_t type,
                  OptionBufferConstIter begin, OptionBufferConstIter end);
 
+    /// @brief Copies this option and returns a pointer to the copy.
     OptionPtr clone() const;
 
     /// @brief Returns length of the whole option, including header.

+ 1 - 1
src/lib/dhcp/option_vendor.cc

@@ -1,4 +1,4 @@
-// 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

+ 2 - 1
src/lib/dhcp/option_vendor.h

@@ -1,4 +1,4 @@
-// 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
@@ -50,6 +50,7 @@ public:
     OptionVendor(Option::Universe u, OptionBufferConstIter begin,
                  OptionBufferConstIter end);
 
+    /// @brief Copies this option and returns a pointer to the copy.
     OptionPtr clone() const;
 
     /// @brief Writes option in wire-format to buf, returns pointer to first

+ 1 - 1
src/lib/dhcp/option_vendor_class.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-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

+ 2 - 1
src/lib/dhcp/option_vendor_class.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-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
@@ -69,6 +69,7 @@ public:
     OptionVendorClass(Option::Universe u, OptionBufferConstIter begin,
                       OptionBufferConstIter end);
 
+    /// @brief Copies this option and returns a pointer to the copy.
     OptionPtr clone() const;
 
     /// @brief Renders option into the buffer in the wire format.