You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018-2023 KiCad Developers, see change_log.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef LIB_TREE_ITEM_H
  24. #define LIB_TREE_ITEM_H
  25. #include <map>
  26. #include <lib_id.h>
  27. #include <import_export.h>
  28. #include <eda_pattern_match.h>
  29. /**
  30. * A mix-in to provide polymorphism between items stored in libraries (symbols, aliases
  31. * and footprints).
  32. *
  33. * It is used primarily to drive the component tree for library browsing and editing.
  34. */
  35. class APIEXPORT LIB_TREE_ITEM
  36. {
  37. public:
  38. virtual ~LIB_TREE_ITEM()
  39. {
  40. }
  41. virtual LIB_ID GetLibId() const = 0;
  42. virtual wxString GetName() const = 0;
  43. virtual wxString GetLibNickname() const = 0;
  44. virtual wxString GetDescription() = 0;
  45. /**
  46. * Retrieves a key/value map of the fields on this item that should be exposed to the library
  47. * browser/chooser for displaying in columns, searching, etc
  48. */
  49. virtual void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) {}
  50. virtual std::vector<SEARCH_TERM> GetSearchTerms() { return std::vector<SEARCH_TERM>(); }
  51. /**
  52. * For items having aliases, IsRoot() indicates the principal item.
  53. */
  54. virtual bool IsRoot() const { return true; }
  55. /**
  56. * For items with footprint fields.
  57. */
  58. virtual wxString GetFootprint() { return wxEmptyString; }
  59. /**
  60. * The pin count for symbols or the unique pad count for footprints.
  61. */
  62. virtual int GetPinCount() { return 0; }
  63. /**
  64. * For items with units, return the number of units.
  65. */
  66. virtual int GetUnitCount() const { return 0; }
  67. /**
  68. * For items with units, return an identifier for unit x.
  69. */
  70. virtual wxString GetUnitReference( int aUnit ) { return wxEmptyString; }
  71. /**
  72. * For items with units, return a display name for unit x.
  73. */
  74. virtual wxString GetUnitDisplayName( int aUnit ) { return wxEmptyString; }
  75. /**
  76. * For items with units, return true if a display name is set for x.
  77. */
  78. virtual bool HasUnitDisplayName( int aUnit ) { return false; }
  79. };
  80. #endif //LIB_TREE_ITEM_H