HAL
action_set_object_type.cpp
Go to the documentation of this file.
1
#include "
gui/user_action/action_set_object_type.h
"
2
3
#include "
gui/gui_globals.h
"
4
#include "
hal_core/netlist/gate_library/enums/pin_type.h
"
5
#include "
hal_core/netlist/module.h
"
6
#include "
hal_core/utilities/enums.h
"
7
8
namespace
hal
9
{
10
ActionSetObjectTypeFactory::ActionSetObjectTypeFactory
() :
UserActionFactory
(
"SetObjectType"
)
11
{
12
;
13
}
14
15
ActionSetObjectTypeFactory
*
ActionSetObjectTypeFactory::sFactory
=
new
ActionSetObjectTypeFactory
;
16
17
UserAction
*
ActionSetObjectTypeFactory::newAction
()
const
18
{
19
return
new
ActionSetObjectType
;
20
}
21
22
QString
ActionSetObjectType::tagname
()
const
23
{
24
return
ActionSetObjectTypeFactory::sFactory
->
tagname
();
25
}
26
27
void
ActionSetObjectType::addToHash
(
QCryptographicHash
& cryptoHash)
const
28
{
29
cryptoHash.
addData
(mObjectType.
toUtf8
());
30
}
31
32
void
ActionSetObjectType::writeToXml
(
QXmlStreamWriter
& xmlOut)
const
33
{
34
xmlOut.
writeTextElement
(
"type"
, mObjectType);
35
}
36
37
void
ActionSetObjectType::readFromXml
(
QXmlStreamReader
& xmlIn)
38
{
39
while
(xmlIn.
readNextStartElement
())
40
{
41
if
(xmlIn.
name
() ==
"type"
)
42
mObjectType = xmlIn.
readElementText
();
43
}
44
}
45
46
bool
ActionSetObjectType::exec
()
47
{
48
QString
oldType;
49
Module
* mod;
50
switch
(
mObject
.
type
())
51
{
52
case
UserActionObjectType::Module
:
53
mod =
gNetlist
->
get_module_by_id
(
mObject
.
id
());
54
if
(mod !=
nullptr
)
55
{
56
oldType =
QString::fromStdString
(mod->
get_type
());
57
mod->
set_type
(mObjectType.
toStdString
());
58
}
59
else
60
return
false
;
61
break
;
62
default
:
63
return
false
;
64
}
65
mUndoAction
=
new
ActionSetObjectType
(oldType);
66
mUndoAction
->
setObject
(
mObject
);
67
return
UserAction::exec
();
68
}
69
}
// namespace hal
action_set_object_type.h
hal::ActionSetObjectTypeFactory
UserActionFactory for ActionSetObjectType.
Definition:
action_set_object_type.h:61
hal::ActionSetObjectTypeFactory::newAction
UserAction * newAction() const
Definition:
action_set_object_type.cpp:17
hal::ActionSetObjectTypeFactory::sFactory
static ActionSetObjectTypeFactory * sFactory
Definition:
action_set_object_type.h:65
hal::ActionSetObjectTypeFactory::ActionSetObjectTypeFactory
ActionSetObjectTypeFactory()
Definition:
action_set_object_type.cpp:10
hal::ActionSetObjectType
Assigns a new type to a module.
Definition:
action_set_object_type.h:40
hal::ActionSetObjectType::readFromXml
void readFromXml(QXmlStreamReader &xmlIn) override
Definition:
action_set_object_type.cpp:37
hal::ActionSetObjectType::tagname
QString tagname() const override
Definition:
action_set_object_type.cpp:22
hal::ActionSetObjectType::ActionSetObjectType
ActionSetObjectType(const QString &type=QString())
Definition:
action_set_object_type.h:48
hal::ActionSetObjectType::addToHash
void addToHash(QCryptographicHash &cryptoHash) const override
Definition:
action_set_object_type.cpp:27
hal::ActionSetObjectType::exec
bool exec() override
Definition:
action_set_object_type.cpp:46
hal::ActionSetObjectType::writeToXml
void writeToXml(QXmlStreamWriter &xmlOut) const override
Definition:
action_set_object_type.cpp:32
hal::Module
Definition:
module.h:66
hal::Module::set_type
void set_type(const std::string &type)
Definition:
module.cpp:111
hal::Module::get_type
std::string get_type() const
Definition:
module.cpp:106
hal::Netlist::get_module_by_id
Module * get_module_by_id(u32 module_id) const
Definition:
netlist.cpp:613
hal::UserActionFactory
The UserActionFactory is the abstract base class for registration.
Definition:
user_action.h:225
hal::UserActionFactory::tagname
QString tagname() const
Definition:
user_action.h:242
hal::UserAction
The UserAction class is the abstract base class for user interactions.
Definition:
user_action.h:57
hal::UserAction::mUndoAction
UserAction * mUndoAction
Definition:
user_action.h:186
hal::UserAction::exec
virtual bool exec()
Definition:
user_action.cpp:23
hal::UserAction::setObject
virtual void setObject(const UserActionObject &obj)
Definition:
user_action.cpp:32
hal::UserAction::mObject
UserActionObject mObject
Definition:
user_action.h:183
hal::UserActionObject::id
u32 id() const
Definition:
user_action_object.h:97
hal::UserActionObject::type
UserActionObjectType::ObjectType type() const
Definition:
user_action_object.h:107
hal::UserActionObjectType::Module
@ Module
Definition:
user_action_object.h:51
enums.h
gui_globals.h
module.h
hal
Definition:
parser_liberty.cpp:10
hal::gNetlist
Netlist * gNetlist
Definition:
plugin_gui.cpp:80
pin_type.h
QCryptographicHash
QCryptographicHash::addData
void addData(const char *data, int length)
QString
QString::fromStdString
QString fromStdString(const std::string &str)
QString::toStdString
std::string toStdString() const const
QString::toUtf8
QByteArray toUtf8() const const
QXmlStreamReader
QXmlStreamReader::name
QStringRef name() const const
QXmlStreamReader::readElementText
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
QXmlStreamReader::readNextStartElement
bool readNextStartElement()
QXmlStreamWriter
QXmlStreamWriter::writeTextElement
void writeTextElement(const QString &qualifiedName, const QString &text)
plugins
gui
src
user_action
action_set_object_type.cpp
Generated on Fri Feb 14 2025 14:22:43 for HAL by
1.9.1