FAST  3.2.0
Framework for Heterogeneous Medical Image Computing and Visualization
Attribute.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "FASTExport.hpp"
4 #include <string>
5 #include <memory>
6 #include <vector>
7 
8 namespace fast {
9 
11 
12 class FAST_EXPORT AttributeValue {
13  public:
14  virtual ~AttributeValue() {};
15 };
16 
17 #define CREATE_ATTRIBUTE_VALUE_OBJECT(NAME, TYPE) \
18 class AttributeValue##NAME : public AttributeValue { \
19  public: \
20  AttributeValue##NAME(TYPE value) : mValue(value) {}; \
21  TYPE get() { \
22  return mValue; \
23  } \
24  private: \
25  TYPE mValue; \
26 }; \
27 
28 CREATE_ATTRIBUTE_VALUE_OBJECT(String, std::string)
31 CREATE_ATTRIBUTE_VALUE_OBJECT(Boolean, bool)
32 
33 
34 class FAST_EXPORT Attribute {
35  public:
36  Attribute(std::string id, std::string name, std::string description, AttributeType type) :
37  mID(id), mName(name), mDescription(description), mType(type) {
38  }
39 
40  void setValue(std::shared_ptr<AttributeValue> value) {
41  if(mValues.size() == 0) {
42  mValues.push_back(value);
43  } else {
44  mValues[0] = value;
45  }
46  }
47 
48  std::shared_ptr<AttributeValue> getValue() const {
49  return mValues.at(0);
50  }
51 
52  void setValues(std::vector<std::shared_ptr<AttributeValue>> values) {
53  mValues = values;
54  }
55 
56  std::vector<std::shared_ptr<AttributeValue>> getValues() const {
57  return mValues;
58  }
59 
60  std::string getName() const {
61  return mName;
62  }
63 
64  std::string getID() const {
65  return mID;
66  }
67 
69  return mType;
70  }
71 
72  void parseInput(std::string input);
73  private:
74  void parseBooleanInput(std::string input);
75  void parseStringInput(std::string input);
76  void parseFloatInput(std::string input);
77  void parseIntegerInput(std::string input);
78 
79  std::string mID;
80  std::string mName;
81  std::string mDescription;
82  AttributeType mType;
83  std::vector<std::shared_ptr<AttributeValue> > mValues;
84 };
85 
86 } // end namespace fast
87 
fast::Attribute::setValue
void setValue(std::shared_ptr< AttributeValue > value)
Definition: Attribute.hpp:40
fast::AttributeType
AttributeType
Definition: Attribute.hpp:10
fast::Attribute::Attribute
Attribute(std::string id, std::string name, std::string description, AttributeType type)
Definition: Attribute.hpp:36
fast::Attribute::getID
std::string getID() const
Definition: Attribute.hpp:64
fast::Attribute::getValues
std::vector< std::shared_ptr< AttributeValue > > getValues() const
Definition: Attribute.hpp:56
fast::Attribute::getType
AttributeType getType() const
Definition: Attribute.hpp:68
fast::ATTRIBUTE_TYPE_STRING
@ ATTRIBUTE_TYPE_STRING
Definition: Attribute.hpp:10
fast::Attribute::setValues
void setValues(std::vector< std::shared_ptr< AttributeValue >> values)
Definition: Attribute.hpp:52
fast::Attribute
Definition: Attribute.hpp:34
fast
Definition: AffineTransformation.hpp:7
fast::ATTRIBUTE_TYPE_BOOLEAN
@ ATTRIBUTE_TYPE_BOOLEAN
Definition: Attribute.hpp:10
fast::Attribute::getValue
std::shared_ptr< AttributeValue > getValue() const
Definition: Attribute.hpp:48
CREATE_ATTRIBUTE_VALUE_OBJECT
#define CREATE_ATTRIBUTE_VALUE_OBJECT(NAME, TYPE)
Definition: Attribute.hpp:17
fast::ATTRIBUTE_TYPE_INTEGER
@ ATTRIBUTE_TYPE_INTEGER
Definition: Attribute.hpp:10
fast::ATTRIBUTE_TYPE_FLOAT
@ ATTRIBUTE_TYPE_FLOAT
Definition: Attribute.hpp:10
fast::Attribute::getName
std::string getName() const
Definition: Attribute.hpp:60
fast::AttributeValue::~AttributeValue
virtual ~AttributeValue()
Definition: Attribute.hpp:14
fast::AttributeValue
Definition: Attribute.hpp:12