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::isUserParameter() {
\r
30 bool BlockParameter::isGenericParameter() {
\r
34 bool BlockParameter::isWishboneParameter() {
\r
38 bool BlockParameter::isPortParameter() {
\r
42 void BlockParameter::setValue(const QString& _value) {
\r
43 defaultValue = QVariant(_value);
\r
46 bool BlockParameter::isValueSet() {
\r
47 if (defaultValue.isNull()) return false;
\r
51 QString BlockParameter::toVHDL(int context, int flags) {
\r
57 QString BlockParameter::getTypeString() {
\r
58 if (type == BlockParameter::Bit) {
\r
61 else if (type == BlockParameter::BitVector) {
\r
62 return "bit_vector";
\r
64 else if (type == BlockParameter::Boolean) {
\r
67 else if (type == BlockParameter::Integer) {
\r
70 else if (type == BlockParameter::Natural) {
\r
73 else if (type == BlockParameter::Positive) {
\r
76 else if (type == BlockParameter::Real) {
\r
79 else if (type == BlockParameter::Character) {
\r
82 else if (type == BlockParameter::String) {
\r
85 else if (type == BlockParameter::Time) {
\r
91 int BlockParameter::typeFromString(const QString &_type) {
\r
92 int ret = BlockParameter::Expression;
\r
94 if (_type == "string") {
\r
95 ret = BlockParameter::String;
\r
97 else if (_type == "expression") {
\r
98 ret = BlockParameter::Expression;
\r
100 else if (_type == "boolean") {
\r
101 ret = BlockParameter::Boolean;
\r
103 else if (_type == "integer") {
\r
104 ret = BlockParameter::Integer;
\r
106 else if (_type == "natural") {
\r
107 ret = BlockParameter::Natural;
\r
109 else if (_type == "positive") {
\r
110 ret = BlockParameter::Positive;
\r
112 else if (_type == "real") {
\r
113 ret = BlockParameter::Real;
\r
115 else if (_type == "time") {
\r
116 ret = BlockParameter::Time;
\r