1 #include "BlockParameter.h"
\r
3 BlockParameter::BlockParameter() {
\r
6 type = BlockParameter::String;
\r
7 defaultValue = QVariant();
\r
10 BlockParameter::BlockParameter(AbstractBlock* _owner, const QString &_name, const QString &_type, const QString &_value) {
\r
13 type = typeFromString(_type);
\r
14 defaultValue = QVariant(_value);
\r
17 BlockParameter::~BlockParameter(){
\r
21 QVariant BlockParameter::getValue() {
\r
22 return defaultValue;
\r
25 bool BlockParameter::getBooleanValue(bool* ok) {
\r
26 if (type == Boolean) {
\r
28 return getValue().toBool();
\r
34 int BlockParameter::getIntValue(bool* ok) {
\r
35 if ((type == Natural) || (type == Positive) || (type == Integer)) {
\r
37 return getValue().toInt();
\r
43 double BlockParameter::getDoubleValue(bool* ok) {
\r
44 if ((type == Real) || (type == Natural) || (type == Positive) || (type == Integer)) {
\r
46 return getValue().toDouble();
\r
52 QString BlockParameter::getStringValue() {
\r
53 return getValue().toString();
\r
56 bool BlockParameter::isUserParameter() {
\r
61 bool BlockParameter::isGenericParameter() {
\r
65 bool BlockParameter::isWishboneParameter() {
\r
69 bool BlockParameter::isPortParameter() {
\r
73 void BlockParameter::setValue(const QString& _value) {
\r
74 defaultValue = QVariant(_value);
\r
77 bool BlockParameter::isValueSet() {
\r
78 if (defaultValue.isNull()) return false;
\r
82 QString BlockParameter::toVHDL(int context, int flags) {
\r
88 QString BlockParameter::getTypeString() {
\r
89 if (type == BlockParameter::Bit) {
\r
92 else if (type == BlockParameter::BitVector) {
\r
93 return "bit_vector";
\r
95 else if (type == BlockParameter::Boolean) {
\r
98 else if (type == BlockParameter::Integer) {
\r
101 else if (type == BlockParameter::Natural) {
\r
104 else if (type == BlockParameter::Positive) {
\r
107 else if (type == BlockParameter::Real) {
\r
110 else if (type == BlockParameter::Character) {
\r
111 return "character";
\r
113 else if (type == BlockParameter::String) {
\r
116 else if (type == BlockParameter::Time) {
\r
119 return "undefined";
\r
122 int BlockParameter::typeFromString(const QString &_type) {
\r
123 int ret = BlockParameter::Expression;
\r
125 if (_type == "string") {
\r
126 ret = BlockParameter::String;
\r
128 else if (_type == "expression") {
\r
129 ret = BlockParameter::Expression;
\r
131 else if (_type == "boolean") {
\r
132 ret = BlockParameter::Boolean;
\r
134 else if (_type == "integer") {
\r
135 ret = BlockParameter::Integer;
\r
137 else if (_type == "natural") {
\r
138 ret = BlockParameter::Natural;
\r
140 else if (_type == "positive") {
\r
141 ret = BlockParameter::Positive;
\r
143 else if (_type == "real") {
\r
144 ret = BlockParameter::Real;
\r
146 else if (_type == "time") {
\r
147 ret = BlockParameter::Time;
\r