21#ifndef _ATTRIBUTE_PROVIDER_H_
22#define _ATTRIBUTE_PROVIDER_H_
44template <
typename T, TYPE AttrType>
54template <
typename T,
unsigned int N>
57 static constexpr unsigned int digits = N;
89template <
typename Tag,
template <
typename,
unsigned int>
class Attr,
TYPE AttrType,
unsigned int N>
95template <
typename Tag,
template <
typename>
class Attr,
TYPE AttrType>
136#define DEFINE_ATTR( Tag, Attr, AttrType, AttrName, ... ) \
140 constexpr const char Tag##_name[] = AttrName; \
141 using Tag = Attribute<Tag##_t, Attr, AttrType, __VA_ARGS__>::TYPE; \
143 struct AttributeName<Tag> \
145 static constexpr const char* name = Tag##_name; \
148#define DEFINE_ATTR_SIMPLE( Tag, Attr, AttrType, AttrName ) \
152 constexpr const char Tag##_name[] = AttrName; \
153 using Tag = AttributeSimple<Tag##_t, Attr, AttrType>::TYPE; \
155 struct AttributeName<Tag> \
157 static constexpr const char* name = Tag##_name; \
161#define DEFINE_FLOAT_ATTR( NAME, N ) DEFINE_ATTR( NAME, FloatAttribute, TYPE::FLOAT, #NAME, N )
163#define DEFINE_BOOLEAN_ATTR( NAME ) \
164 DEFINE_ATTR_SIMPLE( NAME, BooleanAttribute, TYPE::BOOLEAN, #NAME )
166#define DEFINE_TEXT_ATTR( NAME ) DEFINE_ATTR_SIMPLE( NAME, TextAttribute, TYPE::TEXT, #NAME )
168#define DEFINE_OPTION_ATTR( NAME ) \
173 struct AttributeSimple<NAME##_t, OPTION_Attribute, TYPE::OPTION>; \
175 struct AttributeName<NAME> \
177 static constexpr const char* name = #NAME; \
182#define USED_BY_FEATURE_ENTITY( NAME ) \
184 struct IsFeature<NAME> : std::true_type \
188#define USED_BY_NET_ENTITY( NAME ) \
190 struct IsNet<NAME> : std::true_type \
194#define USED_BY_PKG_ENTITY( NAME ) \
196 struct IsPkg<NAME> : std::true_type \
288 template <
typename Tr,
typename Ta>
293 if constexpr( std::is_enum_v<Ta> )
294 r.attributes.emplace(
id, std::to_string(
static_cast<int>( v ) ) );
302 void WriteAttributes( std::ostream& ost,
const std::string& prefix =
"" )
const;
309 size_t GetTextIndex( std::unordered_map<std::string, size_t>& aMap,
310 std::vector<std::pair<size_t, std::string>>& aVec,
311 const std::string& aText );
313 template <
typename T,
unsigned int n>
319 template <
typename T>
325 template <
typename T>
void WriteAttributesText(std::ostream &ost, const std::string &prefix="") const
std::vector< std::pair< size_t, std::string > > m_attrTextVec
std::vector< std::pair< size_t, std::string > > m_attrNameVec
virtual ~ATTR_MANAGER()=default
size_t GetTextIndex(std::unordered_map< std::string, size_t > &aMap, std::vector< std::pair< size_t, std::string > > &aVec, const std::string &aText)
std::string AttrValue2String(ODB_ATTR::FloatAttribute< T, n > a)
void WriteAttributes(std::ostream &ost, const std::string &prefix="") const
void AddFeatureAttribute(Tr &r, Ta v)
size_t GetAttrTextNumber(const wxString &aName)
std::unordered_map< std::string, size_t > m_attrNames
size_t GetAttrNameNumber(const wxString &name)
std::string AttrValue2String(ODB_ATTR::BooleanAttribute< T > a)
std::string AttrValue2String(ODB_ATTR::TextAttribute< T > a)
void WriteAttributesName(std::ostream &ost, const std::string &prefix="") const
std::unordered_map< std::string, size_t > m_attrTexts
std::map< unsigned int, std::string > attributes
void WriteAttributes(std::ostream &ost) const
virtual ~ATTR_RECORD_WRITER()=default
ATTR_RECORD_WRITER()=default
wxString Double2String(double aVal)
#define DEFINE_OPTION_ATTR(NAME)
#define DEFINE_FLOAT_ATTR(NAME, N)
#define DEFINE_BOOLEAN_ATTR(NAME)
#define DEFINE_TEXT_ATTR(NAME)
#define USED_BY_FEATURE_ENTITY(NAME)
@ SMD
Smd pad, appears on the solder paste layer (default)
@ MECHANICAL
a pad used for mechanical support
constexpr AttributeBase(T v)
static constexpr TYPE type
static constexpr unsigned int digits
constexpr TextAttribute(const std::string &t)