A Discrete-Event Network Simulator
API
main-ptr.cc File Reference

Example program illustrating use of the ns3::Ptr smart pointer. More...

#include "ns3/command-line.h"
#include "ns3/object.h"
#include "ns3/ptr.h"
#include <iostream>
+ Include dependency graph for main-ptr.cc:

Go to the source code of this file.

Classes

class  PtrExample
 Example class illustrating use of Ptr. More...
 

Functions

static void ClearPtr ()
 Set g_ptr to NULL. More...
 
static Ptr< PtrExampleStorePtr (Ptr< PtrExample > p)
 Example Ptr manipulations. More...
 

Variables

static Ptr< PtrExampleg_ptr = nullptr
 Example Ptr global variable. More...
 

Detailed Description

Example program illustrating use of the ns3::Ptr smart pointer.

Definition in file main-ptr.cc.

Function Documentation

◆ ClearPtr()

static void ClearPtr ( )
static

Set g_ptr to NULL.

Definition at line 89 of file main-ptr.cc.

References g_ptr.

◆ StorePtr()

static Ptr<PtrExample> StorePtr ( Ptr< PtrExample p)
static

Example Ptr manipulations.

This function stores it's argument in the global variable g_ptr and returns the old value of g_ptr.

Parameters
[in]pA Ptr.
Returns
The prior value of g_ptr.

Definition at line 78 of file main-ptr.cc.

References g_ptr, and prev.

Variable Documentation

◆ g_ptr

Ptr<PtrExample> g_ptr = nullptr
static

Example Ptr global variable.

Definition at line 67 of file main-ptr.cc.

Referenced by ClearPtr(), and StorePtr().