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                                                            \ 
 
  200#define USED_BY_CMP_ENTITY( NAME )                                                                 \ 
  202    struct IsComp<NAME> : std::true_type                                                            \ 
 
 
  306    template <
typename Tr, 
typename Ta>
 
  312        if constexpr( std::is_enum_v<Ta> )
 
  313            r.m_ODBattributes.emplace( 
id, std::to_string( 
static_cast<int>( v ) ) );
 
 
  318    template <
typename Tr, 
typename Ta>
 
  323        if constexpr( std::is_enum_v<Ta> )
 
  324            r.m_ODBattributes.emplace( 
id, std::to_string( 
static_cast<int>( v ) ) );
 
 
  332    void WriteAttributes( std::ostream& ost, 
const std::string& prefix = 
"" ) 
const;
 
  339    size_t GetTextIndex( std::unordered_map<std::string, size_t>&     aMap,
 
  340                         std::vector<std::pair<size_t, std::string>>& aVec,
 
  341                         const std::string&                           aText );
 
  343    template <
typename T, 
unsigned int n>
 
  349    template <
typename T>
 
  355    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
 
size_t GetAttrTextNumber(const wxString &aName)
 
void AddUserDefAttribute(Tr &r, Ta v)
 
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 AddSystemAttribute(Tr &r, Ta v)
 
void WriteAttributesName(std::ostream &ost, const std::string &prefix="") const
 
std::unordered_map< std::string, size_t > m_attrTexts
 
void WriteAttributes(std::ostream &ost) const
 
virtual ~ATTR_RECORD_WRITER()=default
 
std::map< unsigned int, std::string > m_ODBattributes
 
ATTR_RECORD_WRITER()=default
 
wxString Double2String(double aVal)
 
#define DEFINE_OPTION_ATTR(NAME)
 
#define USED_BY_CMP_ENTITY(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)