A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
qkd-control-container.h
Go to the documentation of this file.
1/*
2 * Copyright(c) 2020 DOTFEESA www.tk.etf.unsa.ba
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 *
7 *
8 * Author: Miralem Mehic <miralem.mehic@ieee.org>
9 */
10
11#ifndef QKD_CONTROL_CONTAINER_H
12#define QKD_CONTROL_CONTAINER_H
13
14#include <stdint.h>
15#include <vector>
16#include "ns3/qkd-control.h"
17
18namespace ns3 {
19
20/**
21 * @ingroup QKD
22 *
23 * @brief holds a vector of std::pair of Ptr<QKDControl> and interface index.
24 *
25 * Typically ns-3 QKDControls are installed on nodes using an QKD
26 * helper.
27 *
28 * @see QKDControl
29 */
31{
32public:
33 /**
34 * @brief Container Const Iterator for pairs of QKDControl smart pointer / Interface Index.
35 */
36 typedef std::vector<std::pair<Ptr<QKDControl>, uint32_t> >::const_iterator Iterator;
37
38 /**
39 * Create an empty QKDControlContainer.
40 */
42
43 /**
44 * Concatenate the entries in the other container with ours.
45 * @param other container
46 */
47 void Add(const QKDControlContainer& other);
48
49 /**
50 * @brief Get an iterator which refers to the first pair in the
51 * container.
52 *
53 * Pairs can be retrieved from the container in two ways. First,
54 * directly by an index into the container, and second, using an iterator.
55 * This method is used in the iterator method and is typically used in a
56 * for-loop to run through the pairs
57 *
58 * @code
59 * QKDControlContainer::Iterator i;
60 * for(i = container.Begin(); i != container.End(); ++i)
61 * {
62 * std::pair<Ptr<QKDControl>, uint32_t> pair = *i;
63 * method(pair.first, pair.second); // use the pair
64 * }
65 * @endcode
66 *
67 * @returns an iterator which refers to the first pair in the container.
68 */
69 Iterator Begin() const;
70
71 /**
72 * @brief Get an iterator which indicates past-the-last Node in the
73 * container.
74 *
75 * Nodes can be retrieved from the container in two ways. First,
76 * directly by an index into the container, and second, using an iterator.
77 * This method is used in the iterator method and is typically used in a
78 * for-loop to run through the Nodes
79 *
80 * @code
81 * NodeContainer::Iterator i;
82 * for(i = container.Begin(); i != container.End(); ++i)
83 * {
84 * std::pair<Ptr<QKDControl>, uint32_t> pair = *i;
85 * method(pair.first, pair.second); // use the pair
86 * }
87 * @endcode
88 *
89 * @returns an iterator which indicates an ending condition for a loop.
90 */
91 Iterator End() const;
92
93 /**
94 * @returns the number of Ptr<QKDControl> and interface pairs stored in this
95 * QKDControlContainer.
96 *
97 * Pairs can be retrieved from the container in two ways. First,
98 * directly by an index into the container, and second, using an iterator.
99 * This method is used in the direct method and is typically used to
100 * define an ending condition in a for-loop that runs through the stored
101 * Nodes
102 *
103 * @code
104 * uint32_t nNodes = container.GetN();
105 * for(uint32_t i = 0 i < nNodes; ++i)
106 * {
107 * std::pair<Ptr<QKDControl>, uint32_t> pair = container.Get(i);
108 * method(pair.first, pair.second); // use the pair
109 * }
110 * @endcode
111 *
112 * @returns the number of Ptr<Node> stored in this container.
113 */
114 uint32_t GetN() const;
115
116 /**
117 * Manually add an entry to the container consisting of a previously composed
118 * entry std::pair.
119 *
120 * @param ipInterfacePair the pair of a pointer to Ipv4 object and interface index of the Ipv4Interface to add to the container
121 */
123
124 /**
125 * Manually add an entry to the container consisting of a previously composed
126 * entry std::pair.
127 *
128 * @param ipInterfacePair the pair of a pointer to Ipv4 object and interface index of the Ipv4Interface to add to the container
129 */
131
132 /**
133 * Get the std::pair of an Ptr<QKDControl> and interface stored at the location
134 * specified by the index.
135 *
136 * @param i the index of the container entry to retrieve.
137 * @return the std::pair of a Ptr<QKDControl> and an interface index
138 *
139 */
140 std::pair<Ptr<QKDControl>, uint32_t> Get(uint32_t i) const;
141
142private:
143 /**
144 * @brief Container for pairs of QKDControl smart pointer / Interface Index.
145 */
146 typedef std::vector<std::pair<Ptr<QKDControl>,uint32_t> > InterfaceVector;
147
148 /**
149 * @brief List of QKD Encryptors and interfaces index.
150 */
152};
153
154} // namespace ns3
155
156#endif /* QKD_CONTROL_CONTAINER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
holds a vector of std::pair of Ptr<QKDControl> and interface index.
std::vector< std::pair< Ptr< QKDControl >, uint32_t > > InterfaceVector
Container for pairs of QKDControl smart pointer / Interface Index.
InterfaceVector m_list
List of QKD Encryptors and interfaces index.
std::vector< std::pair< Ptr< QKDControl >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of QKDControl smart pointer / Interface Index.
QKDControlContainer()
Create an empty QKDControlContainer.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
void Add(const QKDControlContainer &other)
Concatenate the entries in the other container with ours.
std::pair< Ptr< QKDControl >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<QKDControl> and interface stored at the location specified by the index.
Iterator Begin() const
Get an iterator which refers to the first pair in the container.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.