The Sparta Modeling Framework
Loading...
Searching...
No Matches
File.hpp File Reference

Utilities for file I/O. More...

#include <cstdint>
#include <vector>
#include <string>

Go to the source code of this file.

Namespaces

namespace  sparta
 Macros for handling exponential backoff.
 

Functions

std::string sparta::utils::computeOutputFilename (const std::string &name, const std::string &location, uint32_t idx, const std::string &sim_name)
 Computes a filename based on the input name replacing it with one of several variables.
 
std::string sparta::utils::findArchitectureConfigFile (const std::vector< std::string > &search_dirs, const std::string &name)
 Look up the location of an architecture config file fiven a searchpp dir and a name refering to a config file OR directory within that dir.
 

Variables

static constexpr char sparta::utils::COUT_FILENAME [] = "1"
 
static constexpr char sparta::utils::CERR_FILENAME [] = "2"
 
static constexpr char sparta::utils::ARCH_OPTIONS_RESOLUTION_RULES []
 

Detailed Description

Utilities for file I/O.

Definition in file File.hpp.

Function Documentation

◆ computeOutputFilename()

std::string sparta::utils::computeOutputFilename ( const std::string &  name,
const std::string &  location,
uint32_t  idx,
const std::string &  sim_name 
)

Computes a filename based on the input name replacing it with one of several variables.

Todo:
Create a file manager
Note
Supported variables in report names include:
  • %l Location in device tree of report instantiation
  • %i Index of report instantiation
  • %p Host process ID
  • %t Timestamp/Date
  • %s Simulator name
Here is the call graph for this function:

◆ findArchitectureConfigFile()

std::string sparta::utils::findArchitectureConfigFile ( const std::vector< std::string > &  search_dirs,
const std::string &  name 
)

Look up the location of an architecture config file fiven a searchpp dir and a name refering to a config file OR directory within that dir.

Exceptions
SpartaExceptionif input cannot resolve to yaml file.
Parameters
[in]search_dirSearch directory
[in]nameName of config file (with or without prefix) or architecture dir name within arch search dir. Subclasses can add more advanced resolution of arch names to config files
Returns
Absolute path to architecture configuration file (x.yaml)
Here is the call graph for this function:

Variable Documentation

◆ ARCH_OPTIONS_RESOLUTION_RULES

constexpr char sparta::utils::ARCH_OPTIONS_RESOLUTION_RULES[]
staticconstexpr
Initial value:
=
"<arch> may be specified as a '.yaml'/'.yml' file in <arch-search-dir>. The yaml suffix is "
"not required and will be appended automatically if matchines files exists. If a directory "
"with a name matching <arch> exists in <arch-search-dir>, then the search continues into "
"that directory for a file named <arch>.yaml (or .yml). If no such file is found or there "
"was no directory name matching <arch> then, architecture config resolution fails."

Definition at line 55 of file File.hpp.

◆ CERR_FILENAME

constexpr char sparta::utils::CERR_FILENAME[] = "2"
staticconstexpr

Definition at line 22 of file File.hpp.

◆ COUT_FILENAME

constexpr char sparta::utils::COUT_FILENAME[] = "1"
staticconstexpr

Definition at line 21 of file File.hpp.