HAL
hal::ProjectManager Class Reference

#include <project_manager.h>

Collaboration diagram for hal::ProjectManager:
Collaboration graph

Public Types

enum  ProjectStatus { NONE , OPENED , SAVED }
 

Public Member Functions

void register_serializer (const std::string &tagname, ProjectSerializer *serializer)
 
void unregister_serializer (const std::string &tagname)
 
ProjectStatus get_project_status () const
 
void set_project_status (ProjectStatus status)
 
std::string get_filename (const std::string &serializer_name)
 
std::unique_ptr< Netlist > & get_netlist ()
 
void dump () const
 
void set_gate_library_path (const std::string &gl_path)
 
bool serialize_project (Netlist *netlist, bool shadow=false)
 
bool open_project (const std::string &path="")
 
const ProjectDirectoryget_project_directory () const
 
void set_project_directory (const std::string &path)
 
void restore_project_file_from_autosave ()
 
bool create_project_directory (const std::string &path)
 
bool remove_project_directory ()
 
std::string get_netlist_filename () const
 

Static Public Member Functions

static ProjectManagerinstance ()
 

Static Public Attributes

static const std::string s_project_file = ".project.json"
 

Detailed Description

Project manager class that handles opening, closing, and saving of projects.

Definition at line 47 of file project_manager.h.

Member Enumeration Documentation

◆ ProjectStatus

Represents the current status of the project.

Enumerator
NONE 

Represents the default state.

OPENED 

Represents an open project state.

SAVED 

Represents a saved project state.

Definition at line 53 of file project_manager.h.

Member Function Documentation

◆ create_project_directory()

bool hal::ProjectManager::create_project_directory ( const std::string &  path)

Create an empty project directory at the specified location. The project directory must not exist.

Parameters
[in]path- The path to the new project directory.
Returns
true on success, false otherwise.

Definition at line 96 of file project_manager.cpp.

References hal::ProjectDirectory::get_default_filename(), hal::ProjectDirectory::get_filename(), log_warning, and hal::ProjectDirectory::s_shadow_dir.

Referenced by hal::FileManager::importFile(), hal::FileManager::newProject(), and hal::project_manager_init().

◆ dump()

void hal::ProjectManager::dump ( ) const

Dump for debugging purpose

Definition at line 328 of file project_manager.cpp.

◆ get_filename()

std::string hal::ProjectManager::get_filename ( const std::string &  serializer_name)

◆ get_netlist()

std::unique_ptr< Netlist > & hal::ProjectManager::get_netlist ( )

Returns parsed netlist which is (temporarily) owned by project manager.

Returns
unique pointer to netlist

Definition at line 169 of file project_manager.cpp.

Referenced by hal::netlist_factory::load_hal_project(), and hal::FileManager::openProject().

◆ get_netlist_filename()

std::string hal::ProjectManager::get_netlist_filename ( ) const

Returns the path to the netlist file.

Returns
The netlist file path.

Definition at line 162 of file project_manager.cpp.

Referenced by hal::FileManager::importFile(), hal::FileManager::newProject(), hal::FileManager::openProject(), and hal::project_manager_init().

◆ get_project_directory()

◆ get_project_status()

ProjectManager::ProjectStatus hal::ProjectManager::get_project_status ( ) const

Returns the current project status.

Returns
The project status value.

Definition at line 129 of file project_manager.cpp.

Referenced by hal::FileManager::autosave(), hal::MainWindow::handleSaveTriggered(), hal::project_manager_init(), and hal::PythonSerializer::PythonSerializer().

◆ instance()

◆ open_project()

bool hal::ProjectManager::open_project ( const std::string &  path = "")

Open the project specified by the provided directory path.

Parameters
[in]path- The path to the project directory. Can be omitted if the path was previously set using ProjectManager::set_project_directory.
Returns
true on success, false otherwise.

Definition at line 69 of file project_manager.cpp.

References log_warning.

Referenced by hal::netlist_factory::load_hal_project(), hal::FileManager::openProject(), and hal::project_manager_init().

◆ register_serializer()

void hal::ProjectManager::register_serializer ( const std::string &  tagname,
ProjectSerializer serializer 
)

Registers an external serializer identified by unique tagname

Parameters
[in]tagnameunique tagname of serializer
[in]serializerserializer instance which must be derived from ProjectSerializer

Definition at line 44 of file project_manager.cpp.

References log_warning.

Referenced by hal::ProjectSerializer::ProjectSerializer().

◆ remove_project_directory()

bool hal::ProjectManager::remove_project_directory ( )

Remove the existing project directory and clear the path member variable.

Returns
true on success, false otherwise.

Definition at line 117 of file project_manager.cpp.

Referenced by hal::FileManager::importFile(), and hal::project_manager_init().

◆ restore_project_file_from_autosave()

void hal::ProjectManager::restore_project_file_from_autosave ( )

When copying files from autosave in project directory netlist filename needs to be adjusted.

Definition at line 174 of file project_manager.cpp.

References test::n, of, s_project_file, and hal::ProjectDirectory::s_shadow_dir.

Referenced by hal::FileManager::openProject().

◆ serialize_project()

bool hal::ProjectManager::serialize_project ( Netlist netlist,
bool  shadow = false 
)

Serialize the netlist and all dependent data to the project directory.

Parameters
[in]netlist- The netlist.
[in]shadow- Set to true if function is called from autosave procedure, false otherwise. Defaults to false.
Returns
true if serialization of the netlist was successful, false otherwise.

Definition at line 139 of file project_manager.cpp.

References hal::ProjectDirectory::get_default_filename(), hal::Netlist::get_gate_library(), hal::GateLibrary::get_path(), hal::ProjectDirectory::get_shadow_filename(), test_multiple::netlist, and hal::netlist_serializer::serialize_to_file().

Referenced by hal::FileManager::importFile(), hal::FileManager::newProject(), and hal::project_manager_init().

◆ set_gate_library_path()

void hal::ProjectManager::set_gate_library_path ( const std::string &  gl_path)

Set the path to the gate library file.

Parameters
[in]gl_path- The path to the gate library file.

Definition at line 134 of file project_manager.cpp.

Referenced by hal::project_manager_init().

◆ set_project_directory()

void hal::ProjectManager::set_project_directory ( const std::string &  path)

Set path to the project directory.

Parameters
[in]path- The path to the project directory.

Definition at line 86 of file project_manager.cpp.

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

◆ set_project_status()

void hal::ProjectManager::set_project_status ( ProjectStatus  status)

Set the current project status to a new value. Must be called when a project is closed.

Parameters
[in]status- The new project status value.

Definition at line 124 of file project_manager.cpp.

Referenced by hal::project_manager_init().

◆ unregister_serializer()

void hal::ProjectManager::unregister_serializer ( const std::string &  tagname)

Unregisters external serializer identified by tagname

Parameters
[in]tagnameunique tagname of serializer

Definition at line 54 of file project_manager.cpp.

Referenced by hal::ProjectSerializer::~ProjectSerializer().

Member Data Documentation

◆ s_project_file

const std::string hal::ProjectManager::s_project_file = ".project.json"
static

File name of project info file (mandatory for all hal projects)

Definition at line 217 of file project_manager.h.

Referenced by restore_project_file_from_autosave().


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