HAL
hal::ProjectDirectory Class Reference

#include <project_directory.h>

Inheritance diagram for hal::ProjectDirectory:
Inheritance graph
Collaboration diagram for hal::ProjectDirectory:
Collaboration graph

Public Member Functions

 ProjectDirectory (const std::string &path=std::string())
 
std::filesystem::path get_default_filename (const std::string &extension=std::string()) const
 
std::filesystem::path get_filename (const std::string &relative_filename) const
 
std::filesystem::path get_shadow_filename (const std::string &extension=std::string()) const
 
std::filesystem::path get_shadow_dir () const
 
std::filesystem::path get_canonical_path () const
 
std::filesystem::path get_relative_file_path (const std::string &filename) const
 

Static Public Member Functions

static ProjectDirectory generate_random ()
 

Static Public Attributes

static const std::string s_shadow_dir = "autosave"
 

Friends

class ProjectManager
 

Detailed Description

Definition at line 37 of file project_directory.h.

Constructor & Destructor Documentation

◆ ProjectDirectory()

hal::ProjectDirectory::ProjectDirectory ( const std::string &  path = std::string())

ProjectDirectory constructor.

Parameters
path- Path to hal project. If path has an extension (like .v or .hal) the extension will be removed.

Definition at line 9 of file project_directory.cpp.

Referenced by generate_random().

Member Function Documentation

◆ generate_random()

ProjectDirectory hal::ProjectDirectory::generate_random ( )
static

Generate a directory name in current working directory which contains a four digit random number

Returns
Absolute path to directory

Definition at line 15 of file project_directory.cpp.

References ProjectDirectory().

Referenced by hal::project_manager_init().

◆ get_canonical_path()

std::filesystem::path hal::ProjectDirectory::get_canonical_path ( ) const

Project directories canonical path. Other than std::filesystem::canonical this method will return an empty path if no project path given.

Returns
Absolute canonical path to project directory

Definition at line 31 of file project_directory.cpp.

Referenced by get_default_filename(), get_filename(), get_relative_file_path(), get_shadow_dir(), hal::project_manager_init(), and hal::PythonSerializer::serialize_control().

◆ get_default_filename()

std::filesystem::path hal::ProjectDirectory::get_default_filename ( const std::string &  extension = std::string()) const

Returns the default file name which is a file with the same as the name as the project directory plus an extension.

Parameters
[in]extension- Extension of default file name. If empty, '.hal' is assumed.
Returns
Absolute path to file

Definition at line 38 of file project_directory.cpp.

References get_canonical_path(), and name.

Referenced by hal::ProjectManager::create_project_directory(), hal::FileManager::importFile(), hal::netlist_factory::load_netlist(), hal::FileManager::newProject(), hal::FileManager::openProject(), hal::project_manager_init(), and hal::ProjectManager::serialize_project().

◆ get_filename()

std::filesystem::path hal::ProjectDirectory::get_filename ( const std::string &  relative_filename) const

Returns absolute path to file within project directory

Parameters
[in]relative_filename- Relative file name in project directory.
Returns
Absolute path of file

Definition at line 47 of file project_directory.cpp.

References get_canonical_path().

Referenced by hal::ProjectManager::create_project_directory(), hal::project_manager_init(), and hal::PythonSerializer::PythonSerializer().

◆ get_relative_file_path()

std::filesystem::path hal::ProjectDirectory::get_relative_file_path ( const std::string &  filename) const

If filename is within project directory the relative file name will be returned. Otherwise this method will return parameter filename without modifications.

Parameters
[in]filename- Absolute path to file
Returns
Relative file name if file in project directory

Definition at line 74 of file project_directory.cpp.

References get_canonical_path(), and test::n.

Referenced by hal::project_manager_init().

◆ get_shadow_dir()

std::filesystem::path hal::ProjectDirectory::get_shadow_dir ( ) const

Get autosave directory path

Returns
Absolute path to autosave directory

Definition at line 67 of file project_directory.cpp.

References get_canonical_path(), and s_shadow_dir.

Referenced by hal::FileManager::autosave(), get_shadow_filename(), hal::FileManager::openProject(), and hal::project_manager_init().

◆ get_shadow_filename()

std::filesystem::path hal::ProjectDirectory::get_shadow_filename ( const std::string &  extension = std::string()) const

Similar to get_default_filename() but will return file name which is located in the autosave (aka shadow) directory.

Parameters
[in]extension- Extension of shadow file name. If empty '.hal' is assumed
Returns
Absolute path to file

Definition at line 58 of file project_directory.cpp.

References get_shadow_dir(), and name.

Referenced by hal::project_manager_init(), and hal::ProjectManager::serialize_project().

Friends And Related Function Documentation

◆ ProjectManager

friend class ProjectManager
friend

Definition at line 39 of file project_directory.h.

Member Data Documentation

◆ s_shadow_dir

const std::string hal::ProjectDirectory::s_shadow_dir = "autosave"
static

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