21#ifndef ENTITYFEATURES_H
22#define ENTITYFEATURES_H
26#include "boost/any.hpp"
33namespace LinguisticProcessing {
36#define DEFAULT_ATTRIBUTE "value"
37#define UNDEFLENGTH std::numeric_limits<uint64_t>::max()
38#define UNDEFPOSITION std::numeric_limits<uint64_t>::max()
47 template<
typename ValueType>
49 const ValueType& value):
51 m_value(
boost::any(value))
57 bool operator==(
const std::string& name)
const;
59 void setName(
const std::string& name) { m_name=name; }
60 void setValue(
const boost::any& val) { m_value=val; }
62 const std::string&
getName()
const {
return m_name; }
63 const boost::any&
getValue()
const {
return m_value; }
74 std::string getValueString()
const;
94 template<
typename ValueType>
95 void setFeature(
const std::string& name,
96 const ValueType& value);
98 template<
typename ValueType>
99 void addFeature(
const std::string& name,
100 const ValueType& value);
103 template<
typename ValueType>
105 const ValueType& value);
108 EntityFeatures::const_iterator find(
const std::string& featureName)
const;
109 EntityFeatures::iterator find(
const std::string& featureName);
110 EntityFeatures::const_iterator findLast(
const std::string& featureName)
const;
111 EntityFeatures::iterator findLast(
const std::string& featureName);
118 extern template LIMA_AUTOMATON_EXPORT void EntityFeatures::appendFeature<int>(
const std::string&,
const int& );
119 extern template LIMA_AUTOMATON_EXPORT void EntityFeatures::appendFeature<double>(
const std::string&,
const double& );
120 extern template LIMA_AUTOMATON_EXPORT void EntityFeatures::appendFeature<QString>(
const std::string&,
const QString& );
123template<
typename ValueType>
125 const ValueType& value)
130 EntityFeatures::iterator it=
find(name);
133 (*it).setValue(boost::any(value));
139 back().setName(name);
140 back().setValue(boost::any(value));
143template<
typename ValueType>
145 const ValueType& value)
150 back().setName(name);
151 back().setValue(boost::any(value));
#define LIMA_AUTOMATON_EXPORT
QDebug & operator<<(QDebug &qd, const std::string &str)
a generic feature that is defined by a name and a value, which can be of any type (use boost::any typ...
void setPosition(const uint64_t &pos)
const std::string & getName() const
void setLength(const uint64_t &val)
uint64_t getPosition() const
uint64_t getLength() const
EntityFeature(const std::string &name, const ValueType &value)
void setName(const std::string &name)
const boost::any & getValue() const
void setValue(const boost::any &val)
a list of generic features: each feature is unique (only one feature for a name)
void setFeature(const std::string &name, const ValueType &value)
void addFeature(const std::string &name, const ValueType &value)
void appendFeature(const std::string &name, const ValueType &value)
EntityFeatures::const_iterator find(const std::string &featureName) const
bool operator==(const Constraint &c1, const Constraint &c2)