HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::DotViewerFactory Class Reference

#include </home/runner/work/hal/hal/plugins/dot_viewer/include/dot_viewer/dot_viewer_factory.h>

Inheritance diagram for hal::DotViewerFactory:
Inheritance graph
Collaboration diagram for hal::DotViewerFactory:
Collaboration graph

Public Member Functions

 DotViewerFactory (const QString &name)
 
void restoreDotViewer (const std::filesystem::path &loaddir, const std::string &jsonfile)
 
ExternalContentWidgetcontentFactory () const
 
std::string serialize (Netlist *netlist, const std::filesystem::path &savedir, bool isAutosave) override
 
void deserialize (Netlist *netlist, const std::filesystem::path &loaddir) override
 
void restore ()
 
- Public Member Functions inherited from hal::ContentFactory
 ContentFactory (const QString &nam=QString())
 
QString name () const
 

Detailed Description

Creates DotViewer widgets on demand and restores the DOT files that were open when the project was last saved.

Definition at line 36 of file dot_viewer_factory.h.

Constructor & Destructor Documentation

◆ DotViewerFactory()

hal::DotViewerFactory::DotViewerFactory ( const QString name)

Construct a new factory.

Parameters
[in]name- The name that the created content widget is registered under.

Definition at line 16 of file dot_viewer_factory.cpp.

Member Function Documentation

◆ contentFactory()

ExternalContentWidget * hal::DotViewerFactory::contentFactory ( ) const
virtual

Create a new DOT viewer widget.

Returns
The created widget.

Implements hal::ContentFactory.

Definition at line 20 of file dot_viewer_factory.cpp.

References QString::isEmpty(), hal::DotViewer::loadDotFile(), and hal::ContentFactory::name().

◆ deserialize()

void hal::DotViewerFactory::deserialize ( Netlist netlist,
const std::filesystem::path &  loaddir 
)
overridevirtual

Read back the .dot file that was displayed when the project was saved.

Parameters
[in]netlist- The netlist of the project.
[in]loaddir- The project directory to load from.

Implements hal::ProjectSerializer.

Definition at line 57 of file dot_viewer_factory.cpp.

References hal::ProjectManager::get_filename(), hal::ProjectManager::instance(), hal::ProjectSerializer::m_name, and restoreDotViewer().

◆ restore()

void hal::DotViewerFactory::restore ( )

◆ restoreDotViewer()

void hal::DotViewerFactory::restoreDotViewer ( const std::filesystem::path &  loaddir,
const std::string &  jsonfile 
)

Restore the DOT viewer from the state that was stored in the given project file.

Parameters
[in]loaddir- The project directory to load from.
[in]jsonfile- The name of the file within the project directory that holds the stored state.

Definition at line 65 of file dot_viewer_factory.cpp.

References QDir::absoluteFilePath(), QJsonObject::contains(), QJsonDocument::fromJson(), QString::fromStdString(), hal::ProjectManager::get_project_directory(), hal::DotViewer::getDotviewerInstance(), hal::ProjectManager::instance(), QString::isEmpty(), hal::DotViewer::loadDotFile(), QJsonDocument::object(), QFile::open(), QIODevice::readAll(), and QIODevice::ReadOnly.

Referenced by deserialize(), and restore().

◆ serialize()

std::string hal::DotViewerFactory::serialize ( Netlist netlist,
const std::filesystem::path &  savedir,
bool  isAutosave 
)
overridevirtual

Store the .dot file that is currently displayed so that it can be restored with the project.

Parameters
[in]netlist- The netlist of the project.
[in]savedir- The project directory to save to.
[in]isAutosave- true if the call was issued by the autosave, false otherwise.
Returns
The name of the written file, an empty string if nothing was written.

Implements hal::ProjectSerializer.

Definition at line 35 of file dot_viewer_factory.cpp.

References QDir::absoluteFilePath(), QJsonDocument::Compact, hal::DotViewer::creatorPlugin(), hal::DotViewer::filename(), QString::fromStdString(), hal::ProjectManager::get_project_directory(), hal::ProjectDirectory::get_relative_file_path(), hal::DotViewer::getDotviewerInstance(), hal::ProjectManager::instance(), QFile::open(), QString::toStdString(), QIODevice::write(), and QIODevice::WriteOnly.


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