src/core/boolean.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 3763 e46e361a4262
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2581
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
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: 2453
diff changeset
     2
/*
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
diff changeset
     3
 * Copyright (c) 2008 INRIA
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
diff changeset
     4
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
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: 2453
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: 2453
diff changeset
     7
 * published by the Free Software Foundation;
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
diff changeset
     8
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
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: 2453
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: 2453
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: 2453
diff changeset
    12
 * GNU General Public License for more details.
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
diff changeset
    13
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
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: 2453
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: 2453
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: 2453
diff changeset
    17
 *
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
diff changeset
    18
 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
31d4960dc31b add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2453
diff changeset
    19
 */
2453
57fe34e08d8d small typo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2452
diff changeset
    20
#ifndef BOOLEAN_H
57fe34e08d8d small typo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2452
diff changeset
    21
#define BOOLEAN_H
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
2438
e2ac9f9aeeb9 value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2437
diff changeset
    23
#include "attribute.h"
2451
8979f07befd5 value-helper.h -> attribute-helper.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2441
diff changeset
    24
#include "attribute-helper.h"
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
namespace ns3 {
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
2584
5011c132ed6c doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    28
/**
3182
61fe7fe81ebd Doxygen organization
Tom Henderson <tomh@tomh.org>
parents: 2965
diff changeset
    29
 * \ingroup attribute
61fe7fe81ebd Doxygen organization
Tom Henderson <tomh@tomh.org>
parents: 2965
diff changeset
    30
 *
2584
5011c132ed6c doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    31
 * \brief Hold a bool native type
5011c132ed6c doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    32
 *
2928
554e10cdc747 add doxygen anchors to avoid warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2584
diff changeset
    33
 * \anchor bool
554e10cdc747 add doxygen anchors to avoid warnings.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2584
diff changeset
    34
 *
2584
5011c132ed6c doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    35
 * This class can be used to hold bool variables
5011c132ed6c doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    36
 * which must go through the Attribute system.
5011c132ed6c doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2581
diff changeset
    37
 */
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    38
class BooleanValue : public AttributeValue
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
{
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
public:
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    41
  BooleanValue ();
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    42
  BooleanValue (bool value);
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
  void Set (bool value);
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
  bool Get (void) const;
3763
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    45
  template <typename T>
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    46
  bool GetAccessor (T &v) const;
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    47
  
2441
d4a91f8bb374 BooleanValue -> Boolean
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    48
  operator bool () const;
2372
bf4efb9359c6 attempt to perform correctly automatic conversions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2371
diff changeset
    49
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    50
  virtual Ptr<AttributeValue> Copy (void) const;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    51
  virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    52
  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
private:
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
  bool m_value;
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
};
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
3763
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    57
template <typename T>
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    58
bool BooleanValue::GetAccessor (T &v) const
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    59
{
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    60
  v = T (m_value);
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    61
  return true;
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    62
}
e46e361a4262 give attribute power to Callback.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3182
diff changeset
    63
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2928
diff changeset
    64
std::ostream & operator << (std::ostream &os, const BooleanValue &value);
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
2441
d4a91f8bb374 BooleanValue -> Boolean
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    66
ATTRIBUTE_CHECKER_DEFINE (Boolean);
d4a91f8bb374 BooleanValue -> Boolean
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    67
ATTRIBUTE_ACCESSOR_DEFINE (Boolean);
2371
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
} // namespace ns3
2118204a86e6 initial work on Value code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
2453
57fe34e08d8d small typo
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2452
diff changeset
    71
#endif /* BOOLEAN_H */