cmSourceGroup.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmSourceGroup_h
  11. #define cmSourceGroup_h
  12. #include "cmStandardIncludes.h"
  13. #include <cmsys/RegularExpression.hxx>
  14. class cmSourceFile;
  15. class cmSourceGroupInternals;
  16. /** \class cmSourceGroup
  17. * \brief Hold a group of sources as specified by a SOURCE_GROUP command.
  18. *
  19. * cmSourceGroup holds a regular expression and a list of files. When
  20. * local generators are about to generate the rules for a target's
  21. * files, the set of source groups is consulted to group files
  22. * together. A file is placed into the last source group that lists
  23. * the file by name. If no group lists the file, it is placed into
  24. * the last group whose regex matches it.
  25. */
  26. class cmSourceGroup
  27. {
  28. public:
  29. cmSourceGroup(const char* name, const char* regex,
  30. const char* parentName=0);
  31. cmSourceGroup(cmSourceGroup const& r);
  32. ~cmSourceGroup();
  33. cmSourceGroup& operator=(cmSourceGroup const&);
  34. /**
  35. * Set the regular expression for this group.
  36. */
  37. void SetGroupRegex(const char* regex);
  38. /**
  39. * Add a file name to the explicit list of files for this group.
  40. */
  41. void AddGroupFile(const char* name);
  42. /**
  43. * Add child to this sourcegroup
  44. */
  45. void AddChild(cmSourceGroup child);
  46. /**
  47. * Looks up child and returns it
  48. */
  49. cmSourceGroup *lookupChild(const char *name);
  50. /**
  51. * Get the name of this group.
  52. */
  53. const char* GetName() const;
  54. /**
  55. * Get the full path name for group.
  56. */
  57. const char* GetFullName() const;
  58. /**
  59. * Check if the given name matches this group's regex.
  60. */
  61. bool MatchesRegex(const char* name);
  62. /**
  63. * Check if the given name matches this group's explicit file list.
  64. */
  65. bool MatchesFiles(const char* name);
  66. /**
  67. * Check if the given name matches this group's explicit file list
  68. * in children.
  69. */
  70. cmSourceGroup *MatchChildrenFiles(const char *name);
  71. /**
  72. * Check if the given name matches this group's regex in children.
  73. */
  74. cmSourceGroup *MatchChildrenRegex(const char *name);
  75. /**
  76. * Assign the given source file to this group. Used only by
  77. * generators.
  78. */
  79. void AssignSource(const cmSourceFile* sf);
  80. /**
  81. * Get the list of the source files that have been assigned to this
  82. * source group.
  83. */
  84. const std::vector<const cmSourceFile*>& GetSourceFiles() const;
  85. std::vector<cmSourceGroup> const& GetGroupChildren() const;
  86. private:
  87. /**
  88. * The name of the source group.
  89. */
  90. std::string Name;
  91. // Full path to group
  92. std::string FullName;
  93. /**
  94. * The regular expression matching the files in the group.
  95. */
  96. cmsys::RegularExpression GroupRegex;
  97. /**
  98. * Set of file names explicitly added to this group.
  99. */
  100. std::set<cmStdString> GroupFiles;
  101. /**
  102. * Vector of all source files that have been assigned to
  103. * this group.
  104. */
  105. std::vector<const cmSourceFile*> SourceFiles;
  106. cmSourceGroupInternals* Internal;
  107. };
  108. #endif