1 #include "BlockParameterGeneric.h"
\r
2 #include "GroupBlock.h"
\r
3 #include "FunctionalBlock.h"
\r
5 BlockParameterGeneric::BlockParameterGeneric() : BlockParameter() {
\r
6 userValue = defaultValue;
\r
9 BlockParameterGeneric::BlockParameterGeneric(AbstractBlock* _owner, const QString &_name, const QString &_type, const QString &_value) : BlockParameter(_owner, _name, _type, _value) {
\r
10 /* CAUTION: no check done on the type parameter !
\r
11 * It must never be "expression" but something that is numeric/boolean
\r
13 userValue = defaultValue;
\r
16 QVariant BlockParameterGeneric::getValue() {
\r
20 return defaultValue;
\r
23 bool BlockParameterGeneric::isGenericParameter() {
\r
27 void BlockParameterGeneric::setValue(const QString& _value) {
\r
28 userValue = QVariant(_value);
\r
32 bool BlockParameterGeneric::isValueSet() {
\r
33 if (userValue.isNull()) return false;
\r
37 bool BlockParameterGeneric::isDefaultValue() {
\r
38 if (userValue == defaultValue) return true;
\r
42 BlockParameter* BlockParameterGeneric::clone() {
\r
44 BlockParameter* block = new BlockParameterGeneric(owner,name,getTypeString(),defaultValue.toString());
\r
48 QString BlockParameterGeneric::toVHDL(int context, int flags) {
\r
53 if ((context == BlockParameter::Entity) || (context == BlockParameter::Component)) {
\r
55 QString formatValue = "%1 : %2 := %3";
\r
56 QString formatNoValue = "%1 : %2";
\r
57 if ((flags & BlockParameter::NoComma) == 0) {
\r
58 formatValue.append(";");
\r
59 formatNoValue.append(";");
\r
62 if (!userValue.isNull()) {
\r
63 ret = formatValue.arg(name).arg(getTypeString()).arg(userValue.toString());
\r
65 else if (!defaultValue.isNull()) {
\r
66 ret = formatValue.arg(name).arg(getTypeString()).arg(defaultValue.toString());
\r
69 ret = formatNoValue.arg(name).arg(getTypeString());
\r
72 else if (context == BlockParameter::Instance) {
\r
73 QString format = "%1 => %2";
\r
74 if ((flags & BlockParameter::NoComma) == 0) {
\r
77 AbstractBlock* parent = owner->getParent();
\r
78 BlockParameter* p = NULL;
\r
79 if (parent != NULL) {
\r
80 p = parent->getParameterFromName(name);
\r
83 /* the parent group has a generic parameter with the same
\r
86 ret = format.arg(name).arg(name);
\r
89 if (!userValue.isNull()) {
\r
90 ret = format.arg(name).arg(userValue.toString());
\r
92 else if (!defaultValue.isNull()) {
\r
93 ret = format.arg(name).arg(defaultValue.toString());
\r
97 ret = format.arg(name).arg("INVALID_VALUE");
\r