13 #ifndef mitkGenericLookupTable_h
14 #define mitkGenericLookupTable_h
21 #include <itkDataObject.h>
26 #include <nlohmann/json.hpp>
30 template <
typename T>
class GenericLookupTable;
94 throw std::range_error(
"id does not exist in the lookup table");
130 template <
typename T>
137 template <
typename T>
154 #define mitkSpecializeGenericLookupTable(LookupTableName, Type) \
156 class MITKCORE_EXPORT LookupTableName : public GenericLookupTable<Type> \
160 typedef LookupTableName Self; \
161 typedef GenericLookupTable<Type> Superclass; \
162 virtual const char *GetNameOfClass() const { return #LookupTableName; } \
163 LookupTableName() {} \
164 LookupTableName(const LookupTableName &) = default; \
165 virtual Superclass &operator=(const Superclass &other) { return Superclass::operator=(other); } \
166 virtual ~LookupTableName() {} \
169 MITKCORE_EXPORT std::ostream &operator<<(std::ostream &stream, const LookupTableName & );
177 #define mitkSpecializeGenericLookupTableOperator(LookupTableName) \
179 std::ostream &mitk::operator<<(std::ostream &stream, const LookupTableName &l) \
182 typedef LookupTableName::LookupTableType::const_iterator IterType; \
183 IterType e = l.GetLookupTable().end(); \
184 IterType b = l.GetLookupTable().begin(); \
186 for (IterType i = b; i != e; ++i) \
192 stream << i->first << " -> " << i->second; \
194 return stream << "]"; \
Template class for generating lookup-tables.
std::map< IdentifierType, ValueType > LookupTableType
bool ValueExists(IdentifierType id) const
Check if a value exists for the given identifier.
GenericLookupTable(const GenericLookupTable &)=default
Copy constructor.
bool operator!=(const Self &lookupTable) const
Inequality comparison operator.
virtual const char * GetNameOfClass() const
Return the class name as a string.
const LookupTableType & GetLookupTable() const
Get the underlying lookup table map.
ValueType GetTableValue(IdentifierType id) const
Get the value for the given identifier.
LookupTableType m_LookupTable
void SetTableValue(IdentifierType id, ValueType value)
Set the value for the given identifier.
GenericLookupTable()
Default constructor.
bool operator==(const Self &lookupTable) const
Equality comparison operator.
virtual Self & operator=(const Self &other)
Assignment operator.
virtual ~GenericLookupTable()
Virtual destructor.
unsigned int IdentifierType
Convenience header that includes all MITK numeric types.
Find image slices visible on a given plane.
void from_json(const nlohmann::json &, GenericLookupTable< T > &)
Deserialize a GenericLookupTable from JSON.
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
Serialize a GenericLookupTable to JSON.