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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef BOOLEAN_H
9#define BOOLEAN_H
10
11#include "attribute-helper.h"
12#include "attribute.h"
13
14/**
15 * \file
16 * \ingroup attribute_Boolean
17 * ns3::BooleanValue attribute value declarations.
18 */
19
20namespace ns3
21{
22
23// Doxygen for this class is auto-generated by
24// utils/print-introspected-doxygen.h
26{
27 public:
29 BooleanValue(const bool& value);
30 void Set(bool value);
31 bool Get() const;
32 template <typename T>
33 bool GetAccessor(T& v) const;
34
35 /**
36 * Functor returning the value.
37 * \returns The value.
38 */
39 operator bool() const;
40
41 Ptr<AttributeValue> Copy() const override;
42 std::string SerializeToString(Ptr<const AttributeChecker> checker) const override;
43 bool DeserializeFromString(std::string value, Ptr<const AttributeChecker> checker) override;
44
45 private:
46 bool m_value;
47};
48
49template <typename T>
50bool
52{
53 v = T(m_value);
54 return true;
55}
56
57/**
58 * \ingroup attribute_Boolean
59 * Output streamer.
60 *
61 * The value is printed as "true" or "false".
62 *
63 * \param [in,out] os The stream.
64 * \param [in] value The BooleanValue to print.
65 * \returns The stream.
66 */
67std::ostream& operator<<(std::ostream& os, const BooleanValue& value);
68
71
72} // namespace ns3
73
74#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:59
AttributeValue implementation for Boolean.
Definition boolean.h:26
bool Get() const
Definition boolean.cc:44
Ptr< AttributeValue > Copy() const override
Definition boolean.cc:70
bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker) override
Definition boolean.cc:93
void Set(bool value)
Set the value.
Definition boolean.cc:37
bool m_value
The stored Boolean instance.
Definition boolean.h:46
bool GetAccessor(T &v) const
Access the Boolean value as type T.
Definition boolean.h:51
std::string SerializeToString(Ptr< const AttributeChecker > checker) const override
Definition boolean.cc:78
Smart pointer class similar to boost::intrusive_ptr.
#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:148