wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
FileHandler Class Reference

Handler for file operation commands (load, save, export, etc.). More...

#include <FileHandler.h>

Inheritance diagram for FileHandler:
[legend]

Public Member Functions

 FileHandler (MainWindow *mainWindow, const MCPValidator *validator)
QJsonObject handleCommand (const QString &command, const QJsonObject &params, const QJsonValue &requestId) override
Public Member Functions inherited from BaseHandler
QString availableInputPorts (GraphicElement *element) const
QString availableOutputPorts (GraphicElement *element) const
 BaseHandler (MainWindow *mainWindow, const MCPValidator *validator)
QJsonObject createErrorResponse (const QString &error, const QJsonValue &requestId=QJsonValue(), int code=JsonRpcError::InternalError) const
QJsonObject createSuccessResponse (const QJsonObject &result={}, const QJsonValue &requestId=QJsonValue()) const
Scene * currentScene ()
const Scene * currentScene () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool inputPortByLabel (GraphicElement *element, const QString &label, int &portIndex, QString &errorMsg) const
bool outputPortByLabel (GraphicElement *element, const QString &label, int &portIndex, QString &errorMsg) const
template<typename Fn>
QJsonObject tryCommand (Fn &&fn, const QString &action, const QJsonValue &requestId=QJsonValue())
 Wraps fn in a try/catch, returning an error response on exception.
GraphicElement * validatedElement (const QJsonObject &params, const QString &paramName, QString &errorMsg)
 Validates paramName in params, looks up the element, and returns it.
bool validateElementId (int elementId, const QString &paramName, QString &errorMsg) const
bool validateNonEmptyString (const QJsonValue &value, const QString &paramName, QString &errorMsg) const
bool validateNonNegativeInteger (const QJsonValue &value, const QString &paramName, QString &errorMsg) const
bool validateNumeric (const QJsonValue &value, const QString &paramName, QString &errorMsg) const
bool validateParameters (const QJsonObject &params, const QStringList &required) const
bool validatePortRange (GraphicElement *element, int portIndex, bool isOutput, const QString &paramName, QString &errorMsg) const
bool validatePositiveInteger (const QJsonValue &value, const QString &paramName, QString &errorMsg) const
virtual ~BaseHandler ()=default

Additional Inherited Members

Protected Member Functions inherited from BaseHandler
QString availablePorts (GraphicElement *element, bool isOutput) const
Protected Attributes inherited from BaseHandler
MainWindow * m_mainWindow
const MCPValidator * m_validator

Detailed Description

Handler for file operation commands (load, save, export, etc.).

Handles all file-related MCP commands including circuit loading, saving, tab management, and image export operations.

Definition at line 15 of file FileHandler.h.

Constructor & Destructor Documentation

◆ FileHandler()

FileHandler::FileHandler ( MainWindow * mainWindow,
const MCPValidator * validator )
explicit

Definition at line 32 of file FileHandler.cpp.

References BaseHandler::BaseHandler().

Member Function Documentation

◆ handleCommand()

QJsonObject FileHandler::handleCommand ( const QString & command,
const QJsonObject & params,
const QJsonValue & requestId )
overridevirtual

Implements BaseHandler.

Definition at line 37 of file FileHandler.cpp.

References BaseHandler::createErrorResponse(), and JsonRpcError::MethodNotFound.


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