Class for environmental variables. More...
#include "satellite-env-variables.h"
Public Member Functions | |
| SatEnvVariables () | |
| Constructor. | |
| ~SatEnvVariables () | |
| Destructor. | |
| void | CreateDirectory (std::string path) |
| Function for creating a directory. | |
| void | DoDispose () |
| Reset class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise. | |
| void | DoInitialize () |
| Initialize class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise. | |
| std::string | GetCurrentDateAndTime () |
| Returns current real world date and time. | |
| std::string | GetCurrentWorkingDirectory () |
| Function for getting the path to current working directory. | |
| std::string | GetDataPath () |
| Function for locating the data folder. | |
| std::string | GetOutputPath () |
| Function for getting the simulation folder. | |
| std::string | GetPathToExecutable () |
| Function for getting the path to executable. | |
| bool | IsValidDirectory (std::string path) |
| Function for checking if the directory exists. | |
| bool | IsValidFile (std::string pathToFile) |
| Function for checking if the file exists. | |
| std::string | LocateDataDirectory () |
| Function for locating the data directory within the NS-3 simulator folder. | |
| std::string | LocateDirectory (std::string initialPath) |
| Function for locating a specific directory within the NS-3 simulator folder. | |
| std::string | LocateFile (std::string initialPath) |
| Function for locating a specific file within the NS-3 simulator folder. | |
| virtual void | NotifyConstructionCompleted () override |
| Notifier called once the ObjectBase is fully constructed. | |
| void | SetCurrentWorkingDirectory (std::string currentWorkingDirectory) |
| Function for setting the path to current working directory. | |
| void | SetOutputPath (std::string outputPath) |
| Method for setting the simulation output path. | |
| void | SetOutputVariables (std::string campaignName, std::string simTag, bool enableOutputOverwrite) |
| Function for setting the output variables. | |
| void | SetPathToExecutable (std::string pathToExecutable) |
| Function for setting the path to executable. | |
Static Public Member Functions | |
| static Ptr< SatEnvVariables > | GetInstance () |
| static TypeId | GetTypeId (void) |
| NS-3 function for type id. | |
Private Member Functions | |
| std::string | AddToPath (std::string path, std::string stringToAdd) |
| Function for forming the next level of a path. | |
| void | DumpRevisionDiff (std::string dataPath) |
| void | DumpSimulationInformation () |
| Function for outputting the most essential simulation specific environmental information. | |
| void | ExecuteCommandAndReadOutput (std::string command, Ptr< SatOutputFileStreamStringContainer > outputContainer) |
| Function for executing the command and inserting the output into a string container. | |
| std::string | FormOutputPath (std::string simRootPath, std::string campaignName, std::string simTag, std::string safetyTag) |
| Function for forming the output path. | |
| std::string | InitializeOutputFolders (std::string campaignName, std::string simTag, bool enableOutputOverwrite) |
| Function for forming the output path and directory structure. | |
Private Attributes | |
| std::string | m_campaignName |
| Simulation campaign name. | |
| std::string | m_currentWorkingDirectory |
| Path to current working directory. | |
| std::string | m_currentWorkingDirectoryFromAttribute |
| Path to current working directory (attribute value). | |
| std::string | m_dataPath |
| Default data path. | |
| bool | m_enableOutputOverwrite |
| Enable simulation output overwrite. | |
| bool | m_enableSimInfoDiffOutput |
| Is simulation information diff output enabled. | |
| bool | m_enableSimInfoOutput |
| Is simulation information output enabled. | |
| bool | m_excludeDataFolderFromDiff |
| Is data folder excluded from the simulation information diff. | |
| bool | m_isInitialized |
| Flag for disposing and initializing. | |
| bool | m_isOutputPathInitialized |
| Is output path initialized. | |
| uint32_t | m_levelsToCheck |
| How many directory levels to check for data path. | |
| std::string | m_outputPath |
| Result output path. | |
| std::string | m_pathToExecutable |
| Path to executable. | |
| std::string | m_pathToExecutableFromAttribute |
| Path to executable (attribute value). | |
| std::string | m_simRootPath |
| Path to the simulation output root folder. | |
| std::string | m_simTag |
| Tag related to the current simulation. | |
Static Private Attributes | |
| static Ptr< SatEnvVariables > | m_instance = nullptr |
| Instance of SatEnvVariables used for singleton template. | |
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 103 of file satellite-env-variables.cc.
References m_campaignName, m_currentWorkingDirectory, m_currentWorkingDirectoryFromAttribute, m_dataPath, m_enableOutputOverwrite, m_enableSimInfoDiffOutput, m_enableSimInfoOutput, m_excludeDataFolderFromDiff, m_isInitialized, m_isOutputPathInitialized, m_levelsToCheck, m_outputPath, m_pathToExecutable, m_pathToExecutableFromAttribute, m_simRootPath, and m_simTag.
| ns3::SatEnvVariables::~SatEnvVariables | ( | ) |
Destructor.
Definition at line 281 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 542 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 564 of file satellite-env-variables.cc.
Referenced by InitializeOutputFolders().
| void ns3::SatEnvVariables::DoDispose | ( | ) |
Reset class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise.
Definition at line 217 of file satellite-env-variables.cc.
References m_currentWorkingDirectory, m_isInitialized, m_isOutputPathInitialized, and m_pathToExecutable.
| void ns3::SatEnvVariables::DoInitialize | ( | ) |
Initialize class NOTICE: this function is meant to me used only in test cases, where issues with singletons might arise.
Definition at line 145 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 649 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 620 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 594 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 515 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 574 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 289 of file satellite-env-variables.cc.
References m_currentWorkingDirectory, and m_currentWorkingDirectoryFromAttribute.
|
inline |
Function for locating the data folder.
Definition at line 108 of file satellite-env-variables.h.
References m_dataPath.
Referenced by LocateDataDirectory().
|
static |
Definition at line 135 of file satellite-env-variables.cc.
References m_instance.
Referenced by ns3::SatAntennaGainPatternContainer::SatAntennaGainPatternContainer(), SatFrameAllocatorTestCase::SatFrameAllocatorTestCase(), ns3::SatFwdLinkChannelEstimationErrorContainer::SatFwdLinkChannelEstimationErrorContainer(), ns3::SatHelper::SatHelper(), ns3::SatLinkResults::SatLinkResults(), ns3::SatLinkResultsPlot::SatLinkResultsPlot(), ns3::SatRtnLinkChannelEstimationErrorContainer::SatRtnLinkChannelEstimationErrorContainer(), ns3::SatWaveformConf::SatWaveformConf(), ns3::SatCompositeSinrOutputTraceContainer::AddNode(), ns3::SatFadingInputTraceContainer::AddNode(), ns3::SatFadingOutputTraceContainer::AddNode(), ns3::SatInterferenceInputTraceContainer::AddNode(), ns3::SatInterferenceOutputTraceContainer::AddNode(), ns3::SatRxCnoInputTraceContainer::AddNode(), ns3::SatRxPowerInputTraceContainer::AddNode(), ns3::SatRxPowerOutputTraceContainer::AddNode(), ns3::SatLog::CreateLog(), ns3::SimulationHelper::CreateSatScenario(), GeoCoordinateTestCase::DoRun(), Pm1::DoRun(), SatAntennaPatternTestCase::DoRun(), SatBaseTestCase::DoRun(), SatBasicEstimatorAverageTestCase::DoRun(), SatBasicEstimatorLastTestCase::DoRun(), SatBasicEstimatorMinTestCase::DoRun(), SatConstantInterferenceTestCase::DoRun(), SatConstellationTest1::DoRun(), SatConstellationTest2::DoRun(), SatConstellationTest3::DoRun(), SatConstellationTest4::DoRun(), SatCraTest1::DoRun(), SatCrdsaTest1::DoRun(), SatCtrlMsgContDelOffTestCase::DoRun(), SatCtrlMsgContDelOnTestCase::DoRun(), SatDvbRcs2WaveformTableTestCase::DoRun(), SatDvbS2BbFrameConfTestCase::DoRun(), SatFadingExternalInputTraceTestCase::DoRun(), SatFrameAllocatorTestCase::DoRun(), SatFreeSpaceLossTestCase::DoRun(), SatFwdArqTestCase::DoRun(), SatFwdChannelEstimationErrorTestCase::DoRun(), SatGseTestCase::DoRun(), SatHandoverTest1::DoRun(), SatHandoverTest2::DoRun(), SatLoraCbrTestCase::DoRun(), SatLoraConstellationFirstWindowTestCase::DoRun(), SatLoraConstellationHandoverTestCase::DoRun(), SatLoraFirstWindowTestCase::DoRun(), SatLoraOutOfWindowWindowNoRetransmissionTestCase::DoRun(), SatLoraOutOfWindowWindowTestCase::DoRun(), SatLoraRegenerativeCbrTestCase::DoRun(), SatLoraRegenerativeFirstWindowTestCase::DoRun(), SatLoraRegenerativeOutOfWindowWindowNoRetransmissionTestCase::DoRun(), SatLoraRegenerativeOutOfWindowWindowTestCase::DoRun(), SatLoraRegenerativeSecondWindowTestCase::DoRun(), SatLoraSecondWindowTestCase::DoRun(), SatMobilityList1TestCase::DoRun(), SatMobilityList2TestCase::DoRun(), SatMobilityObserverTestCase::DoRun(), SatMobilityRandomTestCase::DoRun(), SatNcrTest1::DoRun(), SatNcrTest2::DoRun(), SatNcrTest3::DoRun(), SatPeriodicControlMessageTest1::DoRun(), SatPerPacketFwdLinkFullTestCase::DoRun(), SatPerPacketFwdLinkUserTestCase::DoRun(), SatPerPacketInterferenceTestCase::DoRun(), SatPerPacketRtnLinkFullTestCase::DoRun(), SatPerPacketRtnLinkUserTestCase::DoRun(), SatRegenerationTest1::DoRun(), SatRegenerationTest2::DoRun(), SatRegenerationTest3::DoRun(), SatRegenerationTest4::DoRun(), SatRegenerationTest5::DoRun(), SatRegenerationTest6::DoRun(), SatRegenerationTest7::DoRun(), SatRegenerationTest8::DoRun(), SatRleTestCase::DoRun(), SatRtnArqTestCase::DoRun(), SatRtnChannelEstimationErrorTestCase::DoRun(), SatSeqNoTestCase::DoRun(), SatSlottedAlohaTest1::DoRun(), ScenarioCreationFull::DoRun(), ScenarioCreationLarger::DoRun(), ScenarioCreationSimple::DoRun(), ScenarioCreationUser::DoRun(), SimpleUnicast1::DoRun(), SimpleUnicast2::DoRun(), SimpleUnicast3::DoRun(), SimpleUnicast4::DoRun(), SimpleUnicast5::DoRun(), SimpleUnicast6::DoRun(), SimpleUnicast7::DoRun(), SimpleUnicast8::DoRun(), ns3::SatHelper::EnableCreationTraces(), ns3::SatStatsHelper::GetOutputPath(), ns3::SimulationHelperConf::GetTypeId(), ns3::SatHelper::LoadConstellationTopology(), ns3::SatHelper::LoadMobileUtFromFile(), ns3::SatHelper::LoadMobileUtFromFile(), ns3::SatHelper::LoadMobileUTsFromFolder(), ns3::SimulationHelper::LoadScenario(), ns3::SatFadingExternalInputTraceContainer::NotifyConstructionCompleted(), ns3::SatHelper::NotifyConstructionCompleted(), ns3::SatPacketTrace::NotifyConstructionCompleted(), ns3::SimulationHelper::SetupOutputPath(), and ns3::SimulationHelper::StoreAttributesToFile().
| std::string ns3::SatEnvVariables::GetOutputPath | ( | ) |
Function for getting the simulation folder.
Definition at line 247 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 310 of file satellite-env-variables.cc.
References m_pathToExecutable, and m_pathToExecutableFromAttribute.
|
static |
NS-3 function for type id.
Definition at line 48 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.
|
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 454 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 330 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 351 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 364 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 372 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 413 of file satellite-env-variables.cc.
References IsValidFile(), and m_levelsToCheck.
|
overridevirtual |
Notifier called once the ObjectBase is fully constructed.
This method is invoked once all member attributes have been initialized. Subclasses can override this method to be notified of this event but if they do this, they must chain up to their parent's NotifyConstructionCompleted method.
Definition at line 125 of file satellite-env-variables.cc.
| 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 231 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 260 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 268 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 239 of file satellite-env-variables.cc.
References m_pathToExecutable.
|
private |
Simulation campaign name.
Affects the simulation output folder.
Definition at line 279 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().
|
private |
Path to current working directory.
Definition at line 244 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoDispose(), DoInitialize(), GetCurrentWorkingDirectory(), and SetCurrentWorkingDirectory().
|
private |
Path to current working directory (attribute value).
Definition at line 254 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), GetCurrentWorkingDirectory(), and GetTypeId().
|
private |
Default data path.
Definition at line 269 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DumpRevisionDiff(), GetDataPath(), and GetTypeId().
|
private |
Enable simulation output overwrite.
Definition at line 294 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().
|
private |
Is simulation information diff output enabled.
Definition at line 309 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DumpSimulationInformation(), and GetTypeId().
|
private |
Is simulation information output enabled.
Definition at line 304 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoInitialize(), and GetTypeId().
|
private |
Is data folder excluded from the simulation information diff.
Definition at line 314 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DumpRevisionDiff(), and GetTypeId().
|
staticprivate |
Instance of SatEnvVariables used for singleton template.
Definition at line 324 of file satellite-env-variables.h.
Referenced by GetInstance().
|
private |
Flag for disposing and initializing.
Definition at line 319 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoDispose(), and DoInitialize().
|
private |
Is output path initialized.
Definition at line 299 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoDispose(), DoInitialize(), GetOutputPath(), InitializeOutputFolders(), and SetOutputPath().
|
private |
How many directory levels to check for data path.
Definition at line 264 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), LocateDirectory(), and LocateFile().
|
private |
Result output path.
Definition at line 274 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DumpSimulationInformation(), GetOutputPath(), InitializeOutputFolders(), and SetOutputPath().
|
private |
Path to executable.
Definition at line 249 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoDispose(), DoInitialize(), GetPathToExecutable(), and SetPathToExecutable().
|
private |
Path to executable (attribute value).
Definition at line 259 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), GetPathToExecutable(), and GetTypeId().
|
private |
Path to the simulation output root folder.
Definition at line 284 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), and InitializeOutputFolders().
|
private |
Tag related to the current simulation.
Definition at line 289 of file satellite-env-variables.h.
Referenced by SatEnvVariables(), DoInitialize(), GetOutputPath(), GetTypeId(), and SetOutputVariables().