src/core/model/uinteger.cc
author Peter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 07 Jan 2015 15:43:53 -0800
changeset 11136 03bf8fa63bda
parent 10968 2d29fee2b7b8
child 11538 397bd6465dd9
permissions -rw-r--r--
[Doxygen] Files implementing attributes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2581
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     2
/*
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     3
 * Copyright (c) 2008 INRIA
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     4
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     7
 * published by the Free Software Foundation;
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     8
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    12
 * GNU General Public License for more details.
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    13
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    14
 * You should have received a copy of the GNU General Public License
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    15
 * along with this program; if not, write to the Free Software
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    17
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    18
 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2520
diff changeset
    19
 */
2455
8253e8353689 uint-value -> uinteger
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2439
diff changeset
    20
#include "uinteger.h"
2379
db1eb36bfaa4 forgot to add new files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "fatal-error.h"
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    22
#include "log.h"
2379
db1eb36bfaa4 forgot to add new files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <sstream>
db1eb36bfaa4 forgot to add new files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
11136
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    25
/**
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    26
 * \file
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    27
 * \ingroup attribute_Uinteger
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    28
 * Uinteger attribute value implementations.
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    29
 */
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    30
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9134
diff changeset
    31
namespace ns3 {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    32
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9134
diff changeset
    33
NS_LOG_COMPONENT_DEFINE ("Uinteger");
2379
db1eb36bfaa4 forgot to add new files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7169
diff changeset
    35
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (uint64_t,Uinteger);
2379
db1eb36bfaa4 forgot to add new files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    37
namespace internal {
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    38
11136
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    39
/**
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    40
 * \ingroup attribute_Uinteger
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    41
 * Make an Uinteger attribute checker with embedded numeric type name.
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    42
 *
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    43
 * \param min The minimum allowed value.
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    44
 * \param max The maximum allowed value.
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    45
 * \param name The original type name ("uint8_t", "uint16_t", _etc_.).
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    46
 * \returns The AttributeChecker.
03bf8fa63bda [Doxygen] Files implementing attributes.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    47
 */
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    48
Ptr<const AttributeChecker> MakeUintegerChecker (uint64_t min, uint64_t max, std::string name)
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    49
{
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    50
  NS_LOG_FUNCTION (min << max << name);
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    51
  struct Checker : public AttributeChecker
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    52
  {
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    53
    Checker (uint64_t minValue, uint64_t maxValue, std::string name)
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    54
      : m_minValue (minValue),
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    55
        m_maxValue (maxValue),
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    56
        m_name (name) {}
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    57
    virtual bool Check (const AttributeValue &value) const {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    58
      NS_LOG_FUNCTION (&value);
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    59
      const UintegerValue *v = dynamic_cast<const UintegerValue *> (&value);
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    60
      if (v == 0)
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    61
        {
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    62
          return false;
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    63
        }
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    64
      return v->Get () >= m_minValue && v->Get () <= m_maxValue;
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    65
    }
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
    66
    virtual std::string GetValueTypeName (void) const {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    67
      NS_LOG_FUNCTION_NOARGS ();
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
    68
      return "ns3::UintegerValue";
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    69
    }
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
    70
    virtual bool HasUnderlyingTypeInformation (void) const {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    71
      NS_LOG_FUNCTION_NOARGS ();
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    72
      return true;
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    73
    }
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
    74
    virtual std::string GetUnderlyingTypeInformation (void) const {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    75
      NS_LOG_FUNCTION_NOARGS ();
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    76
      std::ostringstream oss;
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
    77
      oss << m_name << " " << m_minValue << ":" << m_maxValue;
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    78
      return oss.str ();
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    79
    }
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    80
    virtual Ptr<AttributeValue> Create (void) const {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    81
      NS_LOG_FUNCTION_NOARGS ();
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    82
      return ns3::Create<UintegerValue> ();
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    83
    }
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    84
    virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const {
9134
7a750f032acd Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents: 7256
diff changeset
    85
      NS_LOG_FUNCTION (&source << &destination);
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    86
      const UintegerValue *src = dynamic_cast<const UintegerValue *> (&source);
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    87
      UintegerValue *dst = dynamic_cast<UintegerValue *> (&destination);
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    88
      if (src == 0 || dst == 0)
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    89
        {
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    90
          return false;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    91
        }
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    92
      *dst = *src;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2947
diff changeset
    93
      return true;
2520
a4896ebf6e1d introduce AttributeChecker::Create and use it instead of AttributeValue::Copy.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2455
diff changeset
    94
    }
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    95
    uint64_t m_minValue;
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
    96
    uint64_t m_maxValue;
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    97
    std::string m_name;
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    98
  } *checker = new Checker (min, max, name);
2436
23415bac7eaf Accessor -> AttributeAccessor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    99
  return Ptr<const AttributeChecker> (checker, false);
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
   100
}
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
   101
2599
fcc1728eb669 Add sufficient information to AttributeChecker to generate nice-looking doxygen documentation.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
   102
} // namespace internal
2428
9c8d27c408db move checker creation function to .cc file.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2427
diff changeset
   103
2379
db1eb36bfaa4 forgot to add new files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
} // namespace ns3