ns3::SatEnvVariables Class Reference

Class for environmental variables. More...

#include "satellite-env-variables.h"

+ Inheritance diagram for ns3::SatEnvVariables:
+ Collaboration diagram for ns3::SatEnvVariables:

Public Member Functions

 SatEnvVariables ()
 Constructor. More...
 
 ~SatEnvVariables ()
 Destructor. More...
 
void CreateDirectory (std::string path)
 Function for creating a directory. More...
 
void DoDispose ()
 Reset class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise. More...
 
void DoInitialize ()
 Initialize class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise. More...
 
std::string GetCurrentDateAndTime ()
 Returns current real world date and time. More...
 
std::string GetCurrentWorkingDirectory ()
 Function for getting the path to current working directory. More...
 
std::string GetDataPath ()
 Function for locating the data folder. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the type ID of instance. More...
 
std::string GetOutputPath ()
 Function for getting the simulation folder. More...
 
std::string GetPathToExecutable ()
 Function for getting the path to executable. More...
 
bool IsValidDirectory (std::string path)
 Function for checking if the directory exists. More...
 
bool IsValidFile (std::string pathToFile)
 Function for checking if the file exists. More...
 
std::string LocateDataDirectory ()
 Function for locating the data directory within the NS-3 simulator folder. More...
 
std::string LocateDirectory (std::string initialPath)
 Function for locating a specific directory within the NS-3 simulator folder. More...
 
std::string LocateFile (std::string initialPath)
 Function for locating a specific file within the NS-3 simulator folder. More...
 
void SetCurrentWorkingDirectory (std::string currentWorkingDirectory)
 Function for setting the path to current working directory. More...
 
void SetOutputPath (std::string outputPath)
 Method for setting the simulation output path. More...
 
void SetOutputVariables (std::string campaignName, std::string simTag, bool enableOutputOverwrite)
 Function for setting the output variables. More...
 
void SetPathToExecutable (std::string pathToExecutable)
 Function for setting the path to executable. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 NS-3 function for type id. More...
 

Private Member Functions

std::string AddToPath (std::string path, std::string stringToAdd)
 Function for forming the next level of a path. More...
 
void DumpRevisionDiff (std::string dataPath)
 
void DumpSimulationInformation ()
 Function for outputting the most essential simulation specific environmental information. More...
 
void ExecuteCommandAndReadOutput (std::string command, Ptr< SatOutputFileStreamStringContainer > outputContainer)
 Function for executing the command and inserting the output into a string container. More...
 
std::string FormOutputPath (std::string simRootPath, std::string campaignName, std::string simTag, std::string safetyTag)
 Function for forming the output path. More...
 
std::string InitializeOutputFolders (std::string campaignName, std::string simTag, bool enableOutputOverwrite)
 Function for forming the output path and directory structure. More...
 

Private Attributes

std::string m_campaignName
 Simulation campaign name. More...
 
std::string m_currentWorkingDirectory
 Path to current working directory. More...
 
std::string m_currentWorkingDirectoryFromAttribute
 Path to current working directory (attribute value) More...
 
std::string m_dataPath
 Default data path. More...
 
bool m_enableOutputOverwrite
 Enable simulation output overwrite. More...
 
bool m_enableSimInfoDiffOutput
 Is simulation information diff output enabled. More...
 
bool m_enableSimInfoOutput
 Is simulation information output enabled. More...
 
bool m_excludeDataFolderFromDiff
 Is data folder excluded from the simulation information diff. More...
 
bool m_isInitialized
 Flag for disposing and initializing. More...
 
bool m_isOutputPathInitialized
 Is output path initialized. More...
 
uint32_t m_levelsToCheck
 How many directory levels to check for data path. More...
 
std::string m_outputPath
 Result output path. More...
 
std::string m_pathToExecutable
 Path to executable. More...
 
std::string m_pathToExecutableFromAttribute
 Path to executable (attribute value) More...
 
std::string m_simRootPath
 Path to the simulation output root folder. More...
 
std::string m_simTag
 Tag related to the current simulation. More...
 

Detailed Description

Class for environmental variables.

The class is used for storing information on environmental variables, e.g., the current working directory and path to data folder. The class implements functionality for locating directories within the NS-3 simulator folder. Certain variables can be overwritten with attributes.

Definition at line 43 of file satellite-env-variables.h.

Constructor & Destructor Documentation

◆ SatEnvVariables()

ns3::SatEnvVariables::SatEnvVariables ( )

Constructor.

Definition at line 107 of file satellite-env-variables.cc.

◆ ~SatEnvVariables()

ns3::SatEnvVariables::~SatEnvVariables ( )

Destructor.

Definition at line 272 of file satellite-env-variables.cc.

Member Function Documentation

◆ AddToPath()

std::string ns3::SatEnvVariables::AddToPath ( std::string  path,
std::string  stringToAdd 
)
private

Function for forming the next level of a path.

Parameters
pathpath
stringToAddstring to be added to the path
Returns
combined path

Definition at line 533 of file satellite-env-variables.cc.

Referenced by FormOutputPath(), and InitializeOutputFolders().

+ Here is the caller graph for this function:

◆ CreateDirectory()

void ns3::SatEnvVariables::CreateDirectory ( std::string  path)

Function for creating a directory.

Parameters
pathpath to the directory to be created

Definition at line 555 of file satellite-env-variables.cc.

Referenced by InitializeOutputFolders().

+ Here is the caller graph for this function:

◆ DoDispose()

void ns3::SatEnvVariables::DoDispose ( void  )

Reset class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise.

Definition at line 208 of file satellite-env-variables.cc.

References m_currentWorkingDirectory, m_isInitialized, m_isOutputPathInitialized, and m_pathToExecutable.

◆ DoInitialize()

void ns3::SatEnvVariables::DoInitialize ( void  )

Initialize class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise.

Definition at line 136 of file satellite-env-variables.cc.

References DumpSimulationInformation(), InitializeOutputFolders(), IsValidDirectory(), LocateDataDirectory(), m_campaignName, m_currentWorkingDirectory, m_enableOutputOverwrite, m_enableSimInfoOutput, m_isInitialized, m_isOutputPathInitialized, m_pathToExecutable, and m_simTag.

+ Here is the call graph for this function:

◆ DumpRevisionDiff()

void ns3::SatEnvVariables::DumpRevisionDiff ( std::string  dataPath)
private
Parameters
dataPath

Definition at line 641 of file satellite-env-variables.cc.

References ExecuteCommandAndReadOutput(), m_dataPath, and m_excludeDataFolderFromDiff.

Referenced by DumpSimulationInformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DumpSimulationInformation()

void ns3::SatEnvVariables::DumpSimulationInformation ( )
private

Function for outputting the most essential simulation specific environmental information.

Definition at line 611 of file satellite-env-variables.cc.

References DumpRevisionDiff(), ExecuteCommandAndReadOutput(), GetCurrentDateAndTime(), LocateDirectory(), m_enableSimInfoDiffOutput, and m_outputPath.

Referenced by DoInitialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExecuteCommandAndReadOutput()

void ns3::SatEnvVariables::ExecuteCommandAndReadOutput ( std::string  command,
Ptr< SatOutputFileStreamStringContainer outputContainer 
)
private

Function for executing the command and inserting the output into a string container.

Parameters
commandcommand to be executed
outputContainerpointer to output container

Definition at line 585 of file satellite-env-variables.cc.

Referenced by DumpRevisionDiff(), and DumpSimulationInformation().

+ Here is the caller graph for this function:

◆ FormOutputPath()

std::string ns3::SatEnvVariables::FormOutputPath ( std::string  simRootPath,
std::string  campaignName,
std::string  simTag,
std::string  safetyTag 
)
private

Function for forming the output path.

Parameters
simRootPathsimulation output root path
campaignNamesimulation campaign name
simTagsimulation tag
safetyTagsafety tag for avoiding overwrites
Returns
path to the created folder

Definition at line 506 of file satellite-env-variables.cc.

References AddToPath().

Referenced by InitializeOutputFolders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCurrentDateAndTime()

std::string ns3::SatEnvVariables::GetCurrentDateAndTime ( )

Returns current real world date and time.

Returns
date and time as a string

Definition at line 565 of file satellite-env-variables.cc.

Referenced by DumpSimulationInformation().

+ Here is the caller graph for this function:

◆ GetCurrentWorkingDirectory()

std::string ns3::SatEnvVariables::GetCurrentWorkingDirectory ( )

Function for getting the path to current working directory.

Returns
path to current working directory

Definition at line 280 of file satellite-env-variables.cc.

References m_currentWorkingDirectory, and m_currentWorkingDirectoryFromAttribute.

◆ GetDataPath()

std::string ns3::SatEnvVariables::GetDataPath ( )
inline

Function for locating the data folder.

Returns
path to data folder

Definition at line 102 of file satellite-env-variables.h.

References m_dataPath.

Referenced by LocateDataDirectory().

+ Here is the caller graph for this function:

◆ GetInstanceTypeId()

TypeId ns3::SatEnvVariables::GetInstanceTypeId ( void  ) const
virtual

Get the type ID of instance.

Returns
the object TypeId

Definition at line 102 of file satellite-env-variables.cc.

References GetTypeId().

+ Here is the call graph for this function:

◆ GetOutputPath()

std::string ns3::SatEnvVariables::GetOutputPath ( )

Function for getting the simulation folder.

Returns
path to the simulation folder

Definition at line 238 of file satellite-env-variables.cc.

References InitializeOutputFolders(), m_campaignName, m_enableOutputOverwrite, m_isOutputPathInitialized, m_outputPath, and m_simTag.

+ Here is the call graph for this function:

◆ GetPathToExecutable()

std::string ns3::SatEnvVariables::GetPathToExecutable ( )

Function for getting the path to executable.

Returns
path to executable

Definition at line 301 of file satellite-env-variables.cc.

References m_pathToExecutable, and m_pathToExecutableFromAttribute.

◆ GetTypeId()

TypeId ns3::SatEnvVariables::GetTypeId ( void  )
static

NS-3 function for type id.

Returns
type id

Definition at line 46 of file satellite-env-variables.cc.

References m_campaignName, m_currentWorkingDirectoryFromAttribute, m_dataPath, m_enableOutputOverwrite, m_enableSimInfoDiffOutput, m_enableSimInfoOutput, m_excludeDataFolderFromDiff, m_pathToExecutableFromAttribute, and m_simTag.

Referenced by GetInstanceTypeId().

+ Here is the caller graph for this function:

◆ InitializeOutputFolders()

std::string ns3::SatEnvVariables::InitializeOutputFolders ( std::string  campaignName,
std::string  simTag,
bool  enableOutputOverwrite 
)
private

Function for forming the output path and directory structure.

Parameters
campaignNamesimulation campaign name
simTagsimulation tag
enableOutputOverwriteis simulation output overwrite enabled
Returns
path to the created folder

Definition at line 445 of file satellite-env-variables.cc.

References AddToPath(), CreateDirectory(), FormOutputPath(), IsValidDirectory(), LocateDirectory(), m_isOutputPathInitialized, m_outputPath, and m_simRootPath.

Referenced by DoInitialize(), GetOutputPath(), and SetOutputVariables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsValidDirectory()

bool ns3::SatEnvVariables::IsValidDirectory ( std::string  path)

Function for checking if the directory exists.

Returns
does the directory exist

Definition at line 321 of file satellite-env-variables.cc.

Referenced by DoInitialize(), InitializeOutputFolders(), LocateDirectory(), and SetOutputPath().

+ Here is the caller graph for this function:

◆ IsValidFile()

bool ns3::SatEnvVariables::IsValidFile ( std::string  pathToFile)

Function for checking if the file exists.

Returns
does the file exist

Definition at line 342 of file satellite-env-variables.cc.

Referenced by LocateFile().

+ Here is the caller graph for this function:

◆ LocateDataDirectory()

std::string ns3::SatEnvVariables::LocateDataDirectory ( )

Function for locating the data directory within the NS-3 simulator folder.

Returns
path to the data directory

Definition at line 355 of file satellite-env-variables.cc.

References GetDataPath(), and LocateDirectory().

Referenced by DoInitialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LocateDirectory()

std::string ns3::SatEnvVariables::LocateDirectory ( std::string  initialPath)

Function for locating a specific directory within the NS-3 simulator folder.

Parameters
initialPathinitial search path
Returns
path to the located directory

Definition at line 363 of file satellite-env-variables.cc.

References IsValidDirectory(), and m_levelsToCheck.

Referenced by DumpSimulationInformation(), InitializeOutputFolders(), and LocateDataDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LocateFile()

std::string ns3::SatEnvVariables::LocateFile ( std::string  initialPath)

Function for locating a specific file within the NS-3 simulator folder.

Parameters
initialPathinitial search path for the file
Returns
path to the located file

Definition at line 404 of file satellite-env-variables.cc.

References IsValidFile(), and m_levelsToCheck.

+ Here is the call graph for this function:

◆ SetCurrentWorkingDirectory()

void ns3::SatEnvVariables::SetCurrentWorkingDirectory ( std::string  currentWorkingDirectory)

Function for setting the path to current working directory.

Parameters
currentWorkingDirectorypath to current working directory

Definition at line 222 of file satellite-env-variables.cc.

References m_currentWorkingDirectory.

◆ SetOutputPath()

void ns3::SatEnvVariables::SetOutputPath ( std::string  outputPath)

Method for setting the simulation output path.

The path must exist.

Parameters
outputPathThe new output path.

Definition at line 251 of file satellite-env-variables.cc.

References IsValidDirectory(), m_isOutputPathInitialized, and m_outputPath.

+ Here is the call graph for this function:

◆ SetOutputVariables()

void ns3::SatEnvVariables::SetOutputVariables ( std::string  campaignName,
std::string  simTag,
bool  enableOutputOverwrite 
)

Function for setting the output variables.

The function also creates the output folder based on the new variables. NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise. In any other case the class attributes should be used instead.

Parameters
campaignNamesimulation campaign name
simTagsimulation tag
enableOutputOverwriteis simulation output overwrite enabled

Definition at line 259 of file satellite-env-variables.cc.

References InitializeOutputFolders(), m_campaignName, m_enableOutputOverwrite, and m_simTag.

+ Here is the call graph for this function:

◆ SetPathToExecutable()

void ns3::SatEnvVariables::SetPathToExecutable ( std::string  pathToExecutable)

Function for setting the path to executable.

Parameters
pathToExecutablepath to executable

Definition at line 230 of file satellite-env-variables.cc.

References m_pathToExecutable.

Member Data Documentation

◆ m_campaignName

std::string ns3::SatEnvVariables::m_campaignName
private

Simulation campaign name.

Affects the simulation output folder.

Definition at line 273 of file satellite-env-variables.h.

Referenced by DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().

◆ m_currentWorkingDirectory

std::string ns3::SatEnvVariables::m_currentWorkingDirectory
private

Path to current working directory.

Definition at line 238 of file satellite-env-variables.h.

Referenced by DoDispose(), DoInitialize(), GetCurrentWorkingDirectory(), and SetCurrentWorkingDirectory().

◆ m_currentWorkingDirectoryFromAttribute

std::string ns3::SatEnvVariables::m_currentWorkingDirectoryFromAttribute
private

Path to current working directory (attribute value)

Definition at line 248 of file satellite-env-variables.h.

Referenced by GetCurrentWorkingDirectory(), and GetTypeId().

◆ m_dataPath

std::string ns3::SatEnvVariables::m_dataPath
private

Default data path.

Definition at line 263 of file satellite-env-variables.h.

Referenced by DumpRevisionDiff(), GetDataPath(), and GetTypeId().

◆ m_enableOutputOverwrite

bool ns3::SatEnvVariables::m_enableOutputOverwrite
private

Enable simulation output overwrite.

Definition at line 288 of file satellite-env-variables.h.

Referenced by DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().

◆ m_enableSimInfoDiffOutput

bool ns3::SatEnvVariables::m_enableSimInfoDiffOutput
private

Is simulation information diff output enabled.

Definition at line 303 of file satellite-env-variables.h.

Referenced by DumpSimulationInformation(), and GetTypeId().

◆ m_enableSimInfoOutput

bool ns3::SatEnvVariables::m_enableSimInfoOutput
private

Is simulation information output enabled.

Definition at line 298 of file satellite-env-variables.h.

Referenced by DoInitialize(), and GetTypeId().

◆ m_excludeDataFolderFromDiff

bool ns3::SatEnvVariables::m_excludeDataFolderFromDiff
private

Is data folder excluded from the simulation information diff.

Definition at line 308 of file satellite-env-variables.h.

Referenced by DumpRevisionDiff(), and GetTypeId().

◆ m_isInitialized

bool ns3::SatEnvVariables::m_isInitialized
private

Flag for disposing and initializing.

Definition at line 313 of file satellite-env-variables.h.

Referenced by DoDispose(), and DoInitialize().

◆ m_isOutputPathInitialized

bool ns3::SatEnvVariables::m_isOutputPathInitialized
private

Is output path initialized.

Definition at line 293 of file satellite-env-variables.h.

Referenced by DoDispose(), DoInitialize(), GetOutputPath(), InitializeOutputFolders(), and SetOutputPath().

◆ m_levelsToCheck

uint32_t ns3::SatEnvVariables::m_levelsToCheck
private

How many directory levels to check for data path.

Definition at line 258 of file satellite-env-variables.h.

Referenced by LocateDirectory(), and LocateFile().

◆ m_outputPath

std::string ns3::SatEnvVariables::m_outputPath
private

Result output path.

Definition at line 268 of file satellite-env-variables.h.

Referenced by DumpSimulationInformation(), GetOutputPath(), InitializeOutputFolders(), and SetOutputPath().

◆ m_pathToExecutable

std::string ns3::SatEnvVariables::m_pathToExecutable
private

Path to executable.

Definition at line 243 of file satellite-env-variables.h.

Referenced by DoDispose(), DoInitialize(), GetPathToExecutable(), and SetPathToExecutable().

◆ m_pathToExecutableFromAttribute

std::string ns3::SatEnvVariables::m_pathToExecutableFromAttribute
private

Path to executable (attribute value)

Definition at line 253 of file satellite-env-variables.h.

Referenced by GetPathToExecutable(), and GetTypeId().

◆ m_simRootPath

std::string ns3::SatEnvVariables::m_simRootPath
private

Path to the simulation output root folder.

Definition at line 278 of file satellite-env-variables.h.

Referenced by InitializeOutputFolders().

◆ m_simTag

std::string ns3::SatEnvVariables::m_simTag
private

Tag related to the current simulation.

Definition at line 283 of file satellite-env-variables.h.

Referenced by DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().


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