Class for environmental variables. More...
#include "satellite-env-variables.h"
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... | |
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.
ns3::SatEnvVariables::SatEnvVariables | ( | ) |
Constructor.
Definition at line 107 of file satellite-env-variables.cc.
ns3::SatEnvVariables::~SatEnvVariables | ( | ) |
Destructor.
Definition at line 272 of file satellite-env-variables.cc.
|
private |
Function for forming the next level of a path.
path | path |
stringToAdd | string to be added to the path |
Definition at line 533 of file satellite-env-variables.cc.
Referenced by FormOutputPath(), and InitializeOutputFolders().
void ns3::SatEnvVariables::CreateDirectory | ( | std::string | path | ) |
Function for creating a directory.
path | path to the directory to be created |
Definition at line 555 of file satellite-env-variables.cc.
Referenced by InitializeOutputFolders().
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.
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.
|
private |
dataPath |
Definition at line 641 of file satellite-env-variables.cc.
References ExecuteCommandAndReadOutput(), m_dataPath, and m_excludeDataFolderFromDiff.
Referenced by 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().
|
private |
Function for executing the command and inserting the output into a string container.
command | command to be executed |
outputContainer | pointer to output container |
Definition at line 585 of file satellite-env-variables.cc.
Referenced by DumpRevisionDiff(), and DumpSimulationInformation().
|
private |
Function for forming the output path.
simRootPath | simulation output root path |
campaignName | simulation campaign name |
simTag | simulation tag |
safetyTag | safety tag for avoiding overwrites |
Definition at line 506 of file satellite-env-variables.cc.
References AddToPath().
Referenced by InitializeOutputFolders().
std::string ns3::SatEnvVariables::GetCurrentDateAndTime | ( | ) |
Returns current real world date and time.
Definition at line 565 of file satellite-env-variables.cc.
Referenced by DumpSimulationInformation().
std::string ns3::SatEnvVariables::GetCurrentWorkingDirectory | ( | ) |
Function for getting the path to current working directory.
Definition at line 280 of file satellite-env-variables.cc.
References m_currentWorkingDirectory, and m_currentWorkingDirectoryFromAttribute.
|
inline |
Function for locating the data folder.
Definition at line 102 of file satellite-env-variables.h.
References m_dataPath.
Referenced by LocateDataDirectory().
|
virtual |
Get the type ID of instance.
Definition at line 102 of file satellite-env-variables.cc.
References GetTypeId().
std::string ns3::SatEnvVariables::GetOutputPath | ( | ) |
Function for getting 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.
std::string ns3::SatEnvVariables::GetPathToExecutable | ( | ) |
Function for getting the path to executable.
Definition at line 301 of file satellite-env-variables.cc.
References m_pathToExecutable, and m_pathToExecutableFromAttribute.
|
static |
NS-3 function for 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().
|
private |
Function for forming the output path and directory structure.
campaignName | simulation campaign name |
simTag | simulation tag |
enableOutputOverwrite | is simulation output overwrite enabled |
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().
bool ns3::SatEnvVariables::IsValidDirectory | ( | std::string | path | ) |
Function for checking if the directory exists.
Definition at line 321 of file satellite-env-variables.cc.
Referenced by DoInitialize(), InitializeOutputFolders(), LocateDirectory(), and SetOutputPath().
bool ns3::SatEnvVariables::IsValidFile | ( | std::string | pathToFile | ) |
Function for checking if the file exists.
Definition at line 342 of file satellite-env-variables.cc.
Referenced by LocateFile().
std::string ns3::SatEnvVariables::LocateDataDirectory | ( | ) |
Function for locating the data directory within the NS-3 simulator folder.
Definition at line 355 of file satellite-env-variables.cc.
References GetDataPath(), and LocateDirectory().
Referenced by DoInitialize().
std::string ns3::SatEnvVariables::LocateDirectory | ( | std::string | initialPath | ) |
Function for locating a specific directory within the NS-3 simulator folder.
initialPath | initial search path |
Definition at line 363 of file satellite-env-variables.cc.
References IsValidDirectory(), and m_levelsToCheck.
Referenced by DumpSimulationInformation(), InitializeOutputFolders(), and LocateDataDirectory().
std::string ns3::SatEnvVariables::LocateFile | ( | std::string | initialPath | ) |
Function for locating a specific file within the NS-3 simulator folder.
initialPath | initial search path for the file |
Definition at line 404 of file satellite-env-variables.cc.
References IsValidFile(), and m_levelsToCheck.
void ns3::SatEnvVariables::SetCurrentWorkingDirectory | ( | std::string | currentWorkingDirectory | ) |
Function for setting the path to current working directory.
currentWorkingDirectory | path to current working directory |
Definition at line 222 of file satellite-env-variables.cc.
References m_currentWorkingDirectory.
void ns3::SatEnvVariables::SetOutputPath | ( | std::string | outputPath | ) |
Method for setting the simulation output path.
The path must exist.
outputPath | The new output path. |
Definition at line 251 of file satellite-env-variables.cc.
References IsValidDirectory(), m_isOutputPathInitialized, and m_outputPath.
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.
campaignName | simulation campaign name |
simTag | simulation tag |
enableOutputOverwrite | is simulation output overwrite enabled |
Definition at line 259 of file satellite-env-variables.cc.
References InitializeOutputFolders(), m_campaignName, m_enableOutputOverwrite, and m_simTag.
void ns3::SatEnvVariables::SetPathToExecutable | ( | std::string | pathToExecutable | ) |
Function for setting the path to executable.
pathToExecutable | path to executable |
Definition at line 230 of file satellite-env-variables.cc.
References m_pathToExecutable.
|
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().
|
private |
Path to current working directory.
Definition at line 238 of file satellite-env-variables.h.
Referenced by DoDispose(), DoInitialize(), GetCurrentWorkingDirectory(), and SetCurrentWorkingDirectory().
|
private |
Path to current working directory (attribute value)
Definition at line 248 of file satellite-env-variables.h.
Referenced by GetCurrentWorkingDirectory(), and GetTypeId().
|
private |
Default data path.
Definition at line 263 of file satellite-env-variables.h.
Referenced by DumpRevisionDiff(), GetDataPath(), and GetTypeId().
|
private |
Enable simulation output overwrite.
Definition at line 288 of file satellite-env-variables.h.
Referenced by DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().
|
private |
Is simulation information diff output enabled.
Definition at line 303 of file satellite-env-variables.h.
Referenced by DumpSimulationInformation(), and GetTypeId().
|
private |
Is simulation information output enabled.
Definition at line 298 of file satellite-env-variables.h.
Referenced by DoInitialize(), and GetTypeId().
|
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().
|
private |
Flag for disposing and initializing.
Definition at line 313 of file satellite-env-variables.h.
Referenced by DoDispose(), and DoInitialize().
|
private |
Is output path initialized.
Definition at line 293 of file satellite-env-variables.h.
Referenced by DoDispose(), DoInitialize(), GetOutputPath(), InitializeOutputFolders(), and SetOutputPath().
|
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().
|
private |
Result output path.
Definition at line 268 of file satellite-env-variables.h.
Referenced by DumpSimulationInformation(), GetOutputPath(), InitializeOutputFolders(), and SetOutputPath().
|
private |
Path to executable.
Definition at line 243 of file satellite-env-variables.h.
Referenced by DoDispose(), DoInitialize(), GetPathToExecutable(), and SetPathToExecutable().
|
private |
Path to executable (attribute value)
Definition at line 253 of file satellite-env-variables.h.
Referenced by GetPathToExecutable(), and GetTypeId().
|
private |
Path to the simulation output root folder.
Definition at line 278 of file satellite-env-variables.h.
Referenced by InitializeOutputFolders().
|
private |
Tag related to the current simulation.
Definition at line 283 of file satellite-env-variables.h.
Referenced by DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().