Q2NS dev
ns-3 module
Loading...
Searching...
No Matches
q2ns::LambdaQMap Class Referencefinal

QMap implementation that wraps a user-provided lambda. More...

#include <q2ns-qmap.h>

Inheritance diagram for q2ns::LambdaQMap:
Collaboration diagram for q2ns::LambdaQMap:

Public Types

using SimpleFn = std::function< void(QNode &, std::shared_ptr< Qubit > &)>
 Simple callable type.
 
using AdvancedFn = std::function< void(QNode &, std::shared_ptr< Qubit > &, ns3::Ptr< ns3::UniformRandomVariable >, const QMapContext &)>
 Advanced callable type.
 

Public Member Functions

 LambdaQMap ()=default
 Default constructor.
 
 LambdaQMap (SimpleFn f)
 Construct from a simple callable.
 
 LambdaQMap (AdvancedFn f)
 Construct from an advanced callable.
 
QMapInstance Sample (ns3::Ptr< ns3::UniformRandomVariable > u, const QMapContext &ctx=QMapContext{}) const override
 Sample a per-transmission QMapInstance.
 
void Set (SimpleFn f)
 Replace the stored callable with a simple callable.
 
void Set (AdvancedFn f)
 Replace the stored callable with an advanced callable.
 
- Public Member Functions inherited from q2ns::QMap
 ~QMap () override=default
 Virtual destructor.
 

Static Public Member Functions

static ns3::TypeId GetTypeId ()
 Get the ns-3 TypeId.
 
- Static Public Member Functions inherited from q2ns::QMap
static ns3::TypeId GetTypeId ()
 Get the ns-3 TypeId.
 
static ns3::Ptr< QMapCompose (const ns3::Ptr< QMap > &a, const ns3::Ptr< QMap > &b)
 Compose two QMaps into one sequential composite QMap.
 
static ns3::Ptr< QMapCompose (const std::vector< ns3::Ptr< QMap > > &maps)
 Compose a sequence of QMaps into one sequential composite QMap.
 
static ns3::Ptr< QMapFromLambda (std::function< void(QNode &, std::shared_ptr< Qubit > &)> f)
 Build a QMap from a simple lambda.
 
static ns3::Ptr< QMapFromLambda (std::function< void(QNode &, std::shared_ptr< Qubit > &, ns3::Ptr< ns3::UniformRandomVariable >, const QMapContext &)> f)
 Build a QMap from an advanced lambda.
 
static double RateToProb (double rate_per_s, const ns3::Time &t)
 Convert a Poisson rate and elapsed time into an event probability.
 

Private Attributes

SimpleFn simple_ {}
 Simple callable, if configured.
 
AdvancedFn advanced_ {}
 Advanced callable, if configured.
 

Additional Inherited Members

- Protected Member Functions inherited from q2ns::QMap
double GetProb_ (const QMapContext &ctx) const
 Return the effective application probability for this transmission.
 
bool Bernoulli_ (ns3::Ptr< ns3::UniformRandomVariable > u, const QMapContext &ctx) const
 Perform one Bernoulli trial using the effective probability.
 
- Static Protected Member Functions inherited from q2ns::QMap
static void SetLost_ (Qubit &q)
 Mark a qubit lost through the standard registry-backed location path.
 
- Protected Attributes inherited from q2ns::QMap
double p_ = 0.0
 Direct per-transmission probability.
 
double rate_ = 0.0
 Poisson event rate in 1/s. Overrides p_ when positive.
 

Detailed Description

QMap implementation that wraps a user-provided lambda.

LambdaQMap can store either:

  • a simple callable that receives only node and qubit
  • an advanced callable that also receives the RNG source and QMapContext

If both are unset, sampling returns the identity map.

See also
QMap::FromLambda

Definition at line 217 of file q2ns-qmap.h.

Member Typedef Documentation

◆ AdvancedFn

using q2ns::LambdaQMap::AdvancedFn = std::function<void(QNode&, std::shared_ptr<Qubit>&, ns3::Ptr<ns3::UniformRandomVariable>, const QMapContext&)>

Advanced callable type.

Definition at line 227 of file q2ns-qmap.h.

◆ SimpleFn

using q2ns::LambdaQMap::SimpleFn = std::function<void(QNode&, std::shared_ptr<Qubit>&)>

Simple callable type.

Definition at line 222 of file q2ns-qmap.h.

Constructor & Destructor Documentation

◆ LambdaQMap() [1/3]

q2ns::LambdaQMap::LambdaQMap ( )
default

Default constructor.

◆ LambdaQMap() [2/3]

q2ns::LambdaQMap::LambdaQMap ( SimpleFn  f)
explicit

Construct from a simple callable.

Parameters
fSimple callable.

Definition at line 167 of file q2ns-qmap.cc.

◆ LambdaQMap() [3/3]

q2ns::LambdaQMap::LambdaQMap ( AdvancedFn  f)
explicit

Construct from an advanced callable.

Parameters
fAdvanced callable.

Definition at line 171 of file q2ns-qmap.cc.

Member Function Documentation

◆ GetTypeId()

ns3::TypeId q2ns::LambdaQMap::GetTypeId ( )
static

Get the ns-3 TypeId.

Returns
TypeId for q2ns::LambdaQMap.

Definition at line 157 of file q2ns-qmap.cc.

◆ Sample()

QMapInstance q2ns::LambdaQMap::Sample ( ns3::Ptr< ns3::UniformRandomVariable >  u,
const QMapContext ctx = QMapContext{} 
) const
overridevirtual

Sample a per-transmission QMapInstance.

Parameters
uUniform random source.
ctxPer-transmission context.
Returns
Sampled instance, or identity if no callable is configured.

Implements q2ns::QMap.

Definition at line 189 of file q2ns-qmap.cc.

References advanced_, and simple_.

◆ Set() [1/2]

void q2ns::LambdaQMap::Set ( AdvancedFn  f)

Replace the stored callable with an advanced callable.

Parameters
fAdvanced callable.

Definition at line 182 of file q2ns-qmap.cc.

References advanced_, and simple_.

◆ Set() [2/2]

void q2ns::LambdaQMap::Set ( SimpleFn  f)

Replace the stored callable with a simple callable.

Parameters
fSimple callable.

Definition at line 175 of file q2ns-qmap.cc.

References advanced_, and simple_.

Member Data Documentation

◆ advanced_

AdvancedFn q2ns::LambdaQMap::advanced_ {}
private

Advanced callable, if configured.

Definition at line 276 of file q2ns-qmap.h.

Referenced by Sample(), Set(), and Set().

◆ simple_

SimpleFn q2ns::LambdaQMap::simple_ {}
private

Simple callable, if configured.

Definition at line 275 of file q2ns-qmap.h.

Referenced by Sample(), Set(), and Set().


The documentation for this class was generated from the following files: