src/core/model/attribute-construction-list.h
author Tom Henderson <tomh@tomh.org>
Thu, 05 Feb 2015 13:02:44 -0800
changeset 11214 103f62fc7d58
parent 11136 03bf8fa63bda
permissions -rw-r--r--
small edits on previous commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     2
/*
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     3
 * Copyright (c) 2011 Mathieu Lacage
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     4
 *
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     8
 *
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    13
 *
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    17
 *
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    18
 * Authors: Mathieu Lacage <mathieu.lacage@gmail.com>
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    19
 */
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    20
#ifndef ATTRIBUTE_CONSTRUCTION_LIST_H
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    21
#define ATTRIBUTE_CONSTRUCTION_LIST_H
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    22
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    23
#include "attribute.h"
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    24
#include <list>
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    25
11136
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11035
diff changeset
    26
/**
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11035
diff changeset
    27
 * \file
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11035
diff changeset
    28
 * \ingroup object
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11035
diff changeset
    29
 * ns3::AttributeConstructionList declaration.
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11035
diff changeset
    30
 */
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11035
diff changeset
    31
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    32
namespace ns3 {
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    33
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    34
/**
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    35
 * \ingroup object
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    36
 * List of Attribute name, value and checker triples used
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    37
 * to construct Objects.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    38
 */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    39
class AttributeConstructionList
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    40
{
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    41
public:
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    42
  /** A single Attribute triple */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    43
  struct Item 
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    44
  {
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    45
    /** Checker used to validate serialized values. */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    46
    Ptr<const AttributeChecker> checker;
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    47
    /** The value of the Attribute. */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    48
    Ptr<AttributeValue> value;
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    49
    /** The name of the Attribute. */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    50
    std::string name;
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    51
  };
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    52
  /** Iterator type. */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    53
  typedef std::list<struct Item>::const_iterator CIterator;
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    54
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    55
  /** Constructor */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    56
  AttributeConstructionList ();
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    57
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    58
  /**
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    59
   * Add an Attribute to the list.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    60
   *
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    61
   * \param [in] name The Attribute name.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    62
   * \param [in] checker The checker to use for this Attribute.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    63
   * \param [in] value The AttributeValue to add.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    64
   */
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    65
  void Add (std::string name, Ptr<const AttributeChecker> checker,
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    66
            Ptr<AttributeValue> value);
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    67
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    68
  /**
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    69
   * Find an Attribute in the list from its AttributeChecker.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    70
   *
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    71
   * \param [in] checker The AttributeChecker to find.  Typically this is the
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    72
   *             AttributeChecker from TypeId::AttributeInformation.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    73
   * \returns The AttributeValue.
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    74
   */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    75
  Ptr<AttributeValue> Find (Ptr<const AttributeChecker> checker) const;
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    76
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    77
  /** \returns The first item in the list */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    78
  CIterator Begin (void) const;
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    79
  /** \returns The end of the list (iterator to one past the last). */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    80
  CIterator End (void) const;
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    81
  
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    82
private:
11035
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    83
4c13b42eabcd [Doxygen] Attribute implementation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 7399
diff changeset
    84
  /** The list of Items */
7399
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    85
  std::list<struct Item> m_list;
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    86
};
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    87
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    88
} // namespace ns3
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    89
520706f801e8 introduce Config::Reset
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
diff changeset
    90
#endif /* ATTRIBUTE_CONSTRUCTION_LIST_H */