![]() |
HAL
|
#include <project_manager.h>
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 ProjectDirectory & | get_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 ProjectManager * | instance () |
Static Public Attributes | |
static const std::string | s_project_file = ".project.json" |
Project manager class that handles opening, closing, and saving of projects.
Definition at line 47 of file project_manager.h.
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.
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.
[in] | path | - The path to the new project directory. |
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().
void hal::ProjectManager::dump | ( | ) | const |
Dump for debugging purpose
Definition at line 328 of file project_manager.cpp.
std::string hal::ProjectManager::get_filename | ( | const std::string & | serializer_name | ) |
Returns the relative path of the file to be parsed by an external serializer.
[in] | serializer_name | - The unique name of the serializer. |
Definition at line 61 of file project_manager.cpp.
Referenced by hal::PythonSerializer::deserialize(), hal::GroupingSerializer::deserialize(), hal::CommentManager::deserialize(), hal::GroupingColorSerializer::deserialize(), hal::ModuleColorSerializer::deserialize(), hal::project_manager_init(), hal::PythonSerializer::PythonSerializer(), hal::CommentManager::restore(), hal::GraphContextSerializer::restore(), hal::GroupingColorSerializer::restore(), and hal::ModuleColorSerializer::restore().
std::unique_ptr< Netlist > & hal::ProjectManager::get_netlist | ( | ) |
Returns parsed netlist which is (temporarily) owned by project manager.
Definition at line 169 of file project_manager.cpp.
Referenced by hal::netlist_factory::load_hal_project(), and hal::FileManager::openProject().
std::string hal::ProjectManager::get_netlist_filename | ( | ) | const |
Returns the path to the netlist file.
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().
const ProjectDirectory & hal::ProjectManager::get_project_directory | ( | ) | const |
Returns project directory.
Definition at line 91 of file project_manager.cpp.
Referenced by hal::FileManager::autosave(), hal::MainWindow::handleSaveTriggered(), hal::FileManager::importFile(), hal::FileManager::newProject(), hal::FileManager::openProject(), hal::project_manager_init(), hal::PythonSerializer::PythonSerializer(), hal::CommentManager::restore(), hal::GraphContextSerializer::restore(), hal::GroupingColorSerializer::restore(), hal::ModuleColorSerializer::restore(), hal::PythonSerializer::serialize_control(), and hal::netlist_serializer::serialize_to_file().
ProjectManager::ProjectStatus hal::ProjectManager::get_project_status | ( | ) | const |
Returns the current project status.
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().
|
static |
Returns the singleton instance which gets constructed upon first call.
Definition at line 37 of file project_manager.cpp.
Referenced by hal::PythonSerializer::deserialize(), hal::GroupingSerializer::deserialize(), hal::CommentManager::deserialize(), hal::GroupingColorSerializer::deserialize(), hal::ModuleColorSerializer::deserialize(), hal::NetLayoutJunctionEntries::dumpToFile(), hal::ExportProjectDialog::exportProject(), hal::ExportProjectDialog::ExportProjectDialog(), hal::PythonCodeEditor::getAbsFilename(), hal::netlist_factory::load_hal_project(), hal::project_manager_init(), hal::ProjectSerializer::ProjectSerializer(), hal::PythonSerializer::PythonSerializer(), hal::NetLayoutJunctionEntries::resetFile(), hal::CommentManager::restore(), hal::GraphContextSerializer::restore(), hal::GroupingColorSerializer::restore(), hal::ModuleColorSerializer::restore(), hal::PythonSerializer::serialize_control(), hal::netlist_serializer::serialize_to_file(), hal::PythonCodeEditor::setFilename(), and hal::ProjectSerializer::~ProjectSerializer().
bool hal::ProjectManager::open_project | ( | const std::string & | path = "" | ) |
Open the project specified by the provided directory path.
[in] | path | - The path to the project directory. Can be omitted if the path was previously set using ProjectManager::set_project_directory . |
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().
void hal::ProjectManager::register_serializer | ( | const std::string & | tagname, |
ProjectSerializer * | serializer | ||
) |
Registers an external serializer identified by unique tagname
[in] | tagname | unique tagname of serializer |
[in] | serializer | serializer instance which must be derived from ProjectSerializer |
Definition at line 44 of file project_manager.cpp.
References log_warning.
Referenced by hal::ProjectSerializer::ProjectSerializer().
bool hal::ProjectManager::remove_project_directory | ( | ) |
Remove the existing project directory and clear the path member variable.
true
on success, false
otherwise. Definition at line 117 of file project_manager.cpp.
Referenced by hal::FileManager::importFile(), and hal::project_manager_init().
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().
bool hal::ProjectManager::serialize_project | ( | Netlist * | netlist, |
bool | shadow = false |
||
) |
Serialize the netlist and all dependent data to the project directory.
[in] | netlist | - The netlist. |
[in] | shadow | - Set to true if function is called from autosave procedure, false otherwise. Defaults to false . |
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().
void hal::ProjectManager::set_gate_library_path | ( | const std::string & | gl_path | ) |
Set the path to the gate library file.
[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().
void hal::ProjectManager::set_project_directory | ( | const std::string & | path | ) |
Set path to the project directory.
[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().
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.
[in] | status | - The new project status value. |
Definition at line 124 of file project_manager.cpp.
Referenced by hal::project_manager_init().
void hal::ProjectManager::unregister_serializer | ( | const std::string & | tagname | ) |
Unregisters external serializer identified by tagname
[in] | tagname | unique tagname of serializer |
Definition at line 54 of file project_manager.cpp.
Referenced by hal::ProjectSerializer::~ProjectSerializer().
|
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().