A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
boolean.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef BOOLEAN_H
20#define BOOLEAN_H
21
22#include "attribute-helper.h"
23#include "attribute.h"
24
25/**
26 * \file
27 * \ingroup attribute_Boolean
28 * ns3::BooleanValue attribute value declarations.
29 */
30
31namespace ns3
32{
33
34// Doxygen for this class is auto-generated by
35// utils/print-introspected-doxygen.h
37{
38 public:
40 BooleanValue(const bool& value);
41 void Set(bool value);
42 bool Get() const;
43 template <typename T>
44 bool GetAccessor(T& v) const;
45
46 /**
47 * Functor returning the value.
48 * \returns The value.
49 */
50 operator bool() const;
51
52 Ptr<AttributeValue> Copy() const override;
53 std::string SerializeToString(Ptr<const AttributeChecker> checker) const override;
54 bool DeserializeFromString(std::string value, Ptr<const AttributeChecker> checker) override;
55
56 private:
57 bool m_value;
58};
59
60template <typename T>
61bool
63{
64 v = T(m_value);
65 return true;
66}
67
68/**
69 * \ingroup attribute_Boolean
70 * Output streamer.
71 *
72 * The value is printed as "true" or "false".
73 *
74 * \param [in,out] os The stream.
75 * \param [in] value The BooleanValue to print.
76 * \returns The stream.
77 */
78std::ostream& operator<<(std::ostream& os, const BooleanValue& value);
79
82
83} // namespace ns3
84
85#endif /* BOOLEAN_H */
Attribute helper (ATTRIBUTE_ )macros definition.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Hold a value for an Attribute.
Definition: attribute.h:70
AttributeValue implementation for Boolean.
Definition: boolean.h:37
bool Get() const
Definition: boolean.cc:55
Ptr< AttributeValue > Copy() const override
Definition: boolean.cc:81
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition: boolean.cc:104
void Set(bool value)
Set the value.
Definition: boolean.cc:48
bool m_value
The stored Boolean instance.
Definition: boolean.h:57
bool GetAccessor(T &v) const
Access the Boolean value as type T.
Definition: boolean.h:62
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Definition: boolean.cc:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
#define ATTRIBUTE_CHECKER_DEFINE(type)
Declare the AttributeChecker class typeChecker and the MaketypeChecker function for class type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159